diff --git a/src/appstore.js b/src/appstore.js index 00aaaf05b..599881d74 100644 --- a/src/appstore.js +++ b/src/appstore.js @@ -86,8 +86,6 @@ async function getApiServerOrigin() { async function setApiServerOrigin(origin) { assert.strictEqual(typeof origin, 'string'); - - console.log('API SERVER', origin) await settings.set(settings.API_SERVER_ORIGIN_KEY, origin); } diff --git a/src/routes/test/provision-test.js b/src/routes/test/provision-test.js index e7aee85c5..0ccf5d1ec 100644 --- a/src/routes/test/provision-test.js +++ b/src/routes/test/provision-test.js @@ -7,7 +7,9 @@ const common = require('./common.js'); -const expect = require('expect.js'), +const appstore = require('../../appstore.js'), + expect = require('expect.js'), + nock = require('nock'), superagent = require('../../superagent.js'), timers = require('timers/promises'); @@ -120,6 +122,18 @@ describe('Provision', function () { }); describe('Activation', function () { + let scope1; + before(async function () { + scope1 = nock(await appstore.getApiServerOrigin()) + .post('/api/v1/register_cloudron3', (body) => typeof body.domain === 'string' && typeof body.version === 'string') + .times(1000) + .reply(201, { cloudronId: '32', cloudronToken: 'xx' }); + }); + after(function () { + scope1.persist(false); + nock.cleanAll(); + }); + it('device is in first time mode', async function () { const response = await superagent.get(`${serverUrl}/api/v1/provision/status`); expect(response.status).to.equal(200); @@ -224,7 +238,7 @@ describe('Provision', function () { expect(response.status).to.eql(405); // route unavailable post activation }); - it('seutp fails after activation', async function () { + it('setup fails after activation', async function () { const response = await superagent.post(`${serverUrl}/api/v1/provision/setup`) .send({ domainConfig: { provider: 'noop', domain: DOMAIN, adminFqdn: 'my.' + DOMAIN, config: {}, tlsConfig: { provider: 'fallback' } } }) .ok(() => true); diff --git a/src/test/provision-test.js b/src/test/provision-test.js index 58e8d08aa..21ca32b19 100644 --- a/src/test/provision-test.js +++ b/src/test/provision-test.js @@ -17,7 +17,10 @@ describe('Provision', function () { const { domainSetup, auditSource, cleanup } = common; describe('Activate', function () { - before(domainSetup); + before(async function () { + await domainSetup(); + if (!nock.isActive()) nock.activate(); + }); after(cleanup); it('cannot activate when appstore unreachable', async function () {