diff --git a/test/behaviors/caching.spec-int.js b/test/behaviors/caching.spec-int.js index c67c885..c36eb46 100644 --- a/test/behaviors/caching.spec-int.js +++ b/test/behaviors/caching.spec-int.js @@ -1,31 +1,21 @@ -import { before, describe, it } from 'mocha'; +import { describe, it } from 'mocha'; import { expect } from 'chai'; import supertest from 'supertest'; import integration from './_integration.spec-int.js'; -describe('BehaviorCpCode', () => { +describe('BehaviorCaching', () => { - let opts; - before( (done) => { - integration.behaviorConfig().then( (data) => { - opts = data['cpCode.papi.json']; - done(); - }); - }); - - describe('cpCode header', () => { + describe('caching header', () => { let request = supertest(integration.urlPrefix); it('should return the expected header', (done) => { - let header = opts.value.id + (opts.value.name ? '_' + opts.value.name.replace(' ', '_') : ''); - request - .get(integration.behaviorTestUrl('cpCode.papi.json')) + .get(integration.behaviorTestUrl('caching.papi.json')) .expect(200) .end(function (err, res) { - expect(res.headers['x-aka-cpcode']).to.equal(header); + expect(res.headers['x-accel-expires']).to.equal('7200'); done(); }); diff --git a/test/behaviors/gzipResponse.spec-int.js b/test/behaviors/gzipResponse.spec-int.js index 94641d3..e431fe1 100644 --- a/test/behaviors/gzipResponse.spec-int.js +++ b/test/behaviors/gzipResponse.spec-int.js @@ -1,33 +1,23 @@ import { describe, it } from 'mocha'; +import { expect } from 'chai'; import supertest from 'supertest'; import integration from './_integration.spec-int.js'; -describe('BehaviorDenyAccess', () => { +describe('BehaviorGzipResponse', () => { - describe('denyAccess enabled', () => { + describe('gzip header', () => { let request = supertest(integration.urlPrefix); - it('should return denied status code', (done) => { + it('should return the expected header', (done) => { request - .get(integration.behaviorTestUrl('denyAccess.enabled.papi.json')) - .expect(401) - .end(done); - - }); - }); - - describe('denyAccess disabled', () => { - - let request = supertest(integration.urlPrefix); - - it('should NOT return denied status code', (done) => { - - request - .get(integration.behaviorTestUrl('denyAccess.disabled.papi.json')) + .get(integration.behaviorTestUrl('gzipResponse.papi.json')) .expect(200) - .end(done); + .end(function (err, res) { + expect(res.headers['x-aka-gzipresponse']).to.equal('TODO_this_request_should_be_gzipped_by_proxy'); + done(); + }); }); }); diff --git a/test/behaviors/modifyOutgoingResponseHeader.spec-int.js b/test/behaviors/modifyOutgoingResponseHeader.spec-int.js index e431fe1..1f75f7d 100644 --- a/test/behaviors/modifyOutgoingResponseHeader.spec-int.js +++ b/test/behaviors/modifyOutgoingResponseHeader.spec-int.js @@ -3,19 +3,19 @@ import { expect } from 'chai'; import supertest from 'supertest'; import integration from './_integration.spec-int.js'; -describe('BehaviorGzipResponse', () => { +describe('BehaviorModifyOutgoingResponseHeader', () => { - describe('gzip header', () => { + describe('response header', () => { let request = supertest(integration.urlPrefix); it('should return the expected header', (done) => { request - .get(integration.behaviorTestUrl('gzipResponse.papi.json')) + .get(integration.behaviorTestUrl('modifyOutgoingResponseHeader.papi.json')) .expect(200) .end(function (err, res) { - expect(res.headers['x-aka-gzipresponse']).to.equal('TODO_this_request_should_be_gzipped_by_proxy'); + expect(res.headers['strict-transport-security']).to.equal('max-age=31536000'); done(); }); diff --git a/test/behaviors/redirect.path.papi.json b/test/behaviors/redirect.path.papi.json index 539a310..9c77337 100644 --- a/test/behaviors/redirect.path.papi.json +++ b/test/behaviors/redirect.path.papi.json @@ -2,7 +2,8 @@ "queryString" : "APPEND", "responseCode" : 301, "destinationHostname" : "SAME_AS_REQUEST", - "destinationPath" : "/testredirect", + "destinationPath" : "OTHER", + "destinationPathOther": "/testredirect", "destinationProtocol" : "HTTPS", "mobileDefaultChoice" : "DEFAULT" } \ No newline at end of file diff --git a/test/behaviors/redirect.spec-int.js b/test/behaviors/redirect.spec-int.js index e431fe1..bef3ef4 100644 --- a/test/behaviors/redirect.spec-int.js +++ b/test/behaviors/redirect.spec-int.js @@ -3,19 +3,38 @@ import { expect } from 'chai'; import supertest from 'supertest'; import integration from './_integration.spec-int.js'; -describe('BehaviorGzipResponse', () => { +describe('BehaviorRedirect', () => { - describe('gzip header', () => { + describe('redirect to specific path on current domain', () => { let request = supertest(integration.urlPrefix); - it('should return the expected header', (done) => { + it('should redirect to the correct location', (done) => { request - .get(integration.behaviorTestUrl('gzipResponse.papi.json')) - .expect(200) + .get(integration.behaviorTestUrl('redirect.path.papi.json')) + .expect(301) .end(function (err, res) { - expect(res.headers['x-aka-gzipresponse']).to.equal('TODO_this_request_should_be_gzipped_by_proxy'); + expect(res.headers['location']).to.equal('https://localhost/testredirect?nocache=true'); + done(); + }); + + }); + }); + + describe('redirect http to https', () => { + + let request = supertest(integration.urlPrefix.replace('https', 'http')); + + it('should redirect to the correct location', (done) => { + + request + .get(integration.behaviorTestUrl('redirect.https.papi.json')) + .expect(301) + .end(function (err, res) { + expect(res.headers['location']).to.equal( + integration.urlPrefix + integration.behaviorTestUrl('redirect.https.papi.json') + ); done(); });