akamai-nginx
Version:
generate nginx config from akamai property
52 lines (35 loc) • 2 kB
JavaScript
;
var _mocha = require('mocha');
var _chai = require('chai');
var _supertest = require('supertest');
var _supertest2 = _interopRequireDefault(_supertest);
var _integrationSpecInt = require('../_integration.spec-int.js');
var _integrationSpecInt2 = _interopRequireDefault(_integrationSpecInt);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
(0, _mocha.describe)('BehaviorRedirect', function () {
var opts = void 0;
(0, _mocha.before)(function (done) {
_integrationSpecInt2.default.config().then(function (papiOpts) {
opts = papiOpts.behavior['redirect.path.papi.json'];
done();
});
});
(0, _mocha.describe)('redirect to specific path on current domain', function () {
var request = (0, _supertest2.default)(_integrationSpecInt2.default.urlPrefix);
(0, _mocha.it)('should redirect to the correct location', function (done) {
request.get(_integrationSpecInt2.default.testUrl('redirect.path.papi.json')).expect(opts.responseCode).end(function (err, res) {
(0, _chai.expect)(res.headers['location']).to.equal(_integrationSpecInt2.default.urlPrefix + opts.destinationPathOther + '?nocache=true', 'redirect location not set correctly');
done();
});
});
});
(0, _mocha.describe)('redirect http to https', function () {
var request = (0, _supertest2.default)(_integrationSpecInt2.default.urlPrefix.replace('https', 'http'));
(0, _mocha.it)('should redirect to the correct location', function (done) {
request.get(_integrationSpecInt2.default.testUrl('redirect.https.papi.json')).expect(301).end(function (err, res) {
(0, _chai.expect)(res.headers['location']).to.equal(_integrationSpecInt2.default.urlPrefix + _integrationSpecInt2.default.testUrl('redirect.https.papi.json'));
done();
});
});
});
});