123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- var chakram = require("./../setup.js").chakram;
- var expect = chakram.expect;
- // obviously, I took this shamelessly and without further verification from stack overflow
- // https://stackoverflow.com/a/17871737
- var REGEX_IPV6_ADDRESS = /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/;
- describe("www/nginx", function () {
- before(function () {
- var s = chakram.getRequestSettings();
- s.followRedirect = false;
- s.baseUrl = '';
- chakram.setRequestSettings(s);
- });
- describe("dedyn host", function () {
- before(function () {
- chakram.setRequestHeader('Host', 'dedyn.' + process.env.DESECSTACK_DOMAIN);
- });
- it("redirects to the desec host", function () {
- [
- 'https://' + process.env.DESECSTACK_IPV4_REAR_PREFIX16 + '.0.128/',
- 'http://' + process.env.DESECSTACK_IPV4_REAR_PREFIX16 + '.0.128/',
- 'https://[' + process.env.DESECSTACK_IPV6_ADDRESS + ']/',
- 'http://[' + process.env.DESECSTACK_IPV6_ADDRESS + ']/',
- ].forEach(function (url) {
- var response = chakram.get(url);
- expect(response).to.have.status(301);
- expect(response).to.have.header('Location', 'https://desec.' + process.env.DESECSTACK_DOMAIN + '/');
- });
- return chakram.wait();
- });
- });
- describe("checkip.dedyn host", function () {
- before(function () {
- chakram.setRequestHeader('Host', 'checkip.dedyn.' + process.env.DESECSTACK_DOMAIN);
- });
- describe("contacted through SSL/TLS", function () {
- it('returns the ipv4 address when contacted through ipv4', function () {
- var response = chakram.get('https://' + process.env.DESECSTACK_IPV4_REAR_PREFIX16 + '.0.128/');
- return expect(response).to.have.body(process.env.DESECSTACK_IPV4_REAR_PREFIX16 + '.0.127');
- });
- it('returns an ipv6 address when contacted through ipv6', function () {
- var response = chakram.get('https://[' + process.env.DESECSTACK_IPV6_ADDRESS + ']/');
- // it's hard to find out which IPv6 address we actually expect here
- // and as we are inside the docker network anyway (that is, we are
- // topologically not in the same place as the end user), it's hard
- // if the correct address is returned. Hence, we will stick to some
- // simple tests.
- expect(response).to.have.body(REGEX_IPV6_ADDRESS);
- return chakram.wait();
- });
- });
- describe("contacted without encryption", function () {
- it('redirects to SSL/TLS when contacted through ipv4', function () {
- var response = chakram.get('http://' + process.env.DESECSTACK_IPV4_REAR_PREFIX16 + '.0.128/');
- expect(response).to.have.status(301);
- expect(response).to.have.header('Location', 'https://checkip.dedyn.' + process.env.DESECSTACK_DOMAIN + '/');
- return chakram.wait();
- });
- it('redirects to SSL/TLS when contacted through ipv6', function () {
- var response = chakram.get('http://[' + process.env.DESECSTACK_IPV6_ADDRESS + ']/');
- expect(response).to.have.status(301);
- expect(response).to.have.header('Location', 'https://checkip.dedyn.' + process.env.DESECSTACK_DOMAIN + '/');
- return chakram.wait();
- });
- });
- });
- describe("checkipv4.dedyn host", function () {
- before(function () {
- chakram.setRequestHeader('Host', 'checkipv4.dedyn.' + process.env.DESECSTACK_DOMAIN);
- });
- it('returns the ipv4 address when contacted through ipv4', function () {
- var response = chakram.get('https://' + process.env.DESECSTACK_IPV4_REAR_PREFIX16 + '.0.128/');
- return expect(response).to.have.body(process.env.DESECSTACK_IPV4_REAR_PREFIX16 + '.0.127');
- });
- it('redirects to SSL/TLS when concated without encryption', function () {
- var response = chakram.get('http://' + process.env.DESECSTACK_IPV4_REAR_PREFIX16 + '.0.128/');
- expect(response).to.have.status(301);
- expect(response).to.have.header('Location', 'https://checkipv4.dedyn.' + process.env.DESECSTACK_DOMAIN + '/');
- return chakram.wait();
- });
- it('closes the connection when contacted through ipv6', function () {
- var response = chakram.get('https://[' + process.env.DESECSTACK_IPV6_ADDRESS + ']/');
- return expect(response).to.not.have.a.body();
- });
- });
- describe("checkipv6.dedyn host", function () {
- before(function () {
- chakram.setRequestHeader('Host', 'checkipv6.dedyn.' + process.env.DESECSTACK_DOMAIN);
- });
- it('closes the connection when contacted through ipv4', function () {
- var response = chakram.get('https://' + process.env.DESECSTACK_IPV4_REAR_PREFIX16 + '.0.128/');
- return expect(response).to.not.have.a.body();
- });
- it('redirects to SSL/TLS when concated without encryption', function () {
- var response = chakram.get('http://[' + process.env.DESECSTACK_IPV6_ADDRESS + ']/');
- expect(response).to.have.status(301);
- expect(response).to.have.header('Location', 'https://checkipv6.dedyn.' + process.env.DESECSTACK_DOMAIN + '/');
- return chakram.wait();
- });
- it('returns an ipv6 address when contacted through ipv6', function () {
- var response = chakram.get('https://[' + process.env.DESECSTACK_IPV6_ADDRESS + ']/');
- // it's hard to find out which IPv6 address we actually expect here
- // and as we are inside the docker network anyway (that is, we are
- // topologically not in the same place as the end user), it's hard
- // if the correct address is returned. Hence, we will stick to some
- // simple tests.
- expect(response).to.have.body(REGEX_IPV6_ADDRESS);
- return chakram.wait();
- });
- });
- describe("desec host", function () {
- before(function () {
- chakram.setRequestHeader('Host', 'desec.' + process.env.DESECSTACK_DOMAIN);
- });
- it("is alive", function () {
- var response = chakram.get('https://www/');
- return expect(response).to.have.status(200);
- });
- });
- });
|