diff --git a/src/routes/test/server-test.js b/src/routes/test/server-test.js index b419fdc1a..fd4e8249a 100644 --- a/src/routes/test/server-test.js +++ b/src/routes/test/server-test.js @@ -37,19 +37,19 @@ function setup(done) { var scope2 = nock(config.apiServerOrigin()).post('/api/v1/boxes/' + config.fqdn() + '/setup/done?setupToken=somesetuptoken').reply(201, {}); superagent.post(SERVER_URL + '/api/v1/cloudron/activate') - .query({ setupToken: 'somesetuptoken' }) - .send({ username: USERNAME, password: PASSWORD, email: EMAIL }) - .end(function (error, result) { - expect(result).to.be.ok(); - expect(result.statusCode).to.eql(201); - expect(scope1.isDone()).to.be.ok(); - expect(scope2.isDone()).to.be.ok(); + .query({ setupToken: 'somesetuptoken' }) + .send({ username: USERNAME, password: PASSWORD, email: EMAIL }) + .end(function (error, result) { + expect(result).to.be.ok(); + expect(result.statusCode).to.eql(201); + expect(scope1.isDone()).to.be.ok(); + expect(scope2.isDone()).to.be.ok(); - // stash token for further use - token = result.body.token; + // stash token for further use + token = result.body.token; - callback(); - }); + callback(); + }); } ], done); } @@ -72,11 +72,11 @@ describe('REST API', function () { .set('content-type', 'application/json') .send('some invalid non-strict json') .end(function (error, result) { - expect(result.statusCode).to.equal(400); - expect(result.body.message).to.be('Failed to parse body'); + expect(result.statusCode).to.equal(400); + expect(result.body.message).to.be('Failed to parse body'); - done(); - }); + done(); + }); }); it('does not crash with invalid string', function (done) { @@ -85,9 +85,9 @@ describe('REST API', function () { .set('content-type', 'application/x-www-form-urlencoded') .send('some string') .end(function (error, result) { - expect(result.statusCode).to.equal(400); + expect(result.statusCode).to.equal(400); - done(); - }); + done(); + }); }); }); diff --git a/src/test/dns-test.js b/src/test/dns-test.js index c7431c8a5..6f10ae36c 100644 --- a/src/test/dns-test.js +++ b/src/test/dns-test.js @@ -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); diff --git a/src/test/server-test.js b/src/test/server-test.js index 5352245ca..9fa2e53a0 100644 --- a/src/test/server-test.js +++ b/src/test/server-test.js @@ -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) {