More test fixing

This commit is contained in:
Girish Ramakrishnan
2017-11-27 18:05:16 -08:00
parent 68c26c1d12
commit e6eb54d572
3 changed files with 64 additions and 62 deletions
+28 -27
View File
@@ -15,12 +15,11 @@ var async = require('async'),
expect = require('expect.js'),
nock = require('nock'),
settings = require('../settings.js'),
domains = require('../domains.js'),
util = require('util');
var DOMAIN_0 = {
domain: 'example.com',
zoneName: 'example.com',
domain: 'example-dns-test.com',
zoneName: 'example-dns-test.com',
config: {}
};
@@ -343,30 +342,7 @@ describe('dns provider', function () {
// do not clear this with [] but .length = 0 so we don't loose the reference in mockery
var awsAnswerQueue = [];
var AWS_HOSTED_ZONES = {
HostedZones: [{
Id: '/hostedzone/Z34G16B38TNZ9L',
Name: config.zoneName() + '.',
CallerReference: '305AFD59-9D73-4502-B020-F4E6F889CB30',
ResourceRecordSetCount: 2,
ChangeInfo: {
Id: '/change/CKRTFJA0ANHXB',
Status: 'INSYNC'
}
}, {
Id: '/hostedzone/Z3OFC3B6E8YTA7',
Name: 'cloudron.us.',
CallerReference: '0B37F2DE-21A4-E678-BA32-3FC8AF0CF635',
Config: {},
ResourceRecordSetCount: 2,
ChangeInfo: {
Id: '/change/C2682N5HXP0BZ5',
Status: 'INSYNC'
}
}],
IsTruncated: false,
MaxItems: '100'
};
var AWS_HOSTED_ZONES = null;
before(function (done) {
DOMAIN_0.config = {
@@ -375,6 +351,31 @@ describe('dns provider', function () {
secretAccessKey: 'unused'
};
AWS_HOSTED_ZONES = {
HostedZones: [{
Id: '/hostedzone/Z34G16B38TNZ9L',
Name: config.zoneName() + '.',
CallerReference: '305AFD59-9D73-4502-B020-F4E6F889CB30',
ResourceRecordSetCount: 2,
ChangeInfo: {
Id: '/change/CKRTFJA0ANHXB',
Status: 'INSYNC'
}
}, {
Id: '/hostedzone/Z3OFC3B6E8YTA7',
Name: 'cloudron.us.',
CallerReference: '0B37F2DE-21A4-E678-BA32-3FC8AF0CF635',
Config: {},
ResourceRecordSetCount: 2,
ChangeInfo: {
Id: '/change/C2682N5HXP0BZ5',
Status: 'INSYNC'
}
}],
IsTruncated: false,
MaxItems: '100'
};
function mockery (queue) {
return function(options, callback) {
expect(options).to.be.an(Object);
+18 -17
View File
@@ -25,6 +25,7 @@ describe('Server', function () {
before(function () {
config._reset();
config.setFqdn('example-server-test.com');
config.set('provider', 'notcaas'); // otherwise, cron sets a caas timer for heartbeat causing the test to not quit
});
@@ -92,22 +93,22 @@ describe('Server', function () {
superagent.get(SERVER_URL + '/api/v1/cloudron/status', function (err, res) {
expect(err).to.not.be.ok();
expect(res.statusCode).to.equal(200);
expect(res.body.version).to.equal('0.5.0');
expect(res.body.version).to.equal('1.1.1-test');
done();
});
});
it('status route is GET', function (done) {
superagent.post(SERVER_URL + '/api/v1/cloudron/status')
.end(function (err, res) {
expect(res.statusCode).to.equal(404);
.end(function (err, res) {
expect(res.statusCode).to.equal(404);
superagent.get(SERVER_URL + '/api/v1/cloudron/status')
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
done();
superagent.get(SERVER_URL + '/api/v1/cloudron/status')
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
done();
});
});
});
});
});
@@ -228,21 +229,21 @@ describe('Server', function () {
.set('Access-Control-Request-Headers', 'accept, origin, x-superagented-with')
.set('Origin', 'http://localhost')
.end(function (error, res) {
expect(res.headers['access-control-allow-methods']).to.be('GET, PUT, DELETE, POST, OPTIONS');
expect(res.headers['access-control-allow-credentials']).to.be('false');
expect(res.headers['access-control-allow-headers']).to.be('accept, origin, x-superagented-with'); // mirrored from superagent
expect(res.headers['access-control-allow-origin']).to.be('http://localhost'); // mirrors from superagent
done();
});
expect(res.headers['access-control-allow-methods']).to.be('GET, PUT, DELETE, POST, OPTIONS');
expect(res.headers['access-control-allow-credentials']).to.be('false');
expect(res.headers['access-control-allow-headers']).to.be('accept, origin, x-superagented-with'); // mirrored from superagent
expect(res.headers['access-control-allow-origin']).to.be('http://localhost'); // mirrors from superagent
done();
});
});
it('does not crash for malformed origin', function (done) {
superagent('OPTIONS', SERVER_URL + '/api/v1/cloudron/status')
.set('Origin', 'foobar')
.end(function (error, res) {
expect(res.statusCode).to.be(405);
done();
});
expect(res.statusCode).to.be(405);
done();
});
});
after(function (done) {