replace with custom superagent based on fetch API

This commit is contained in:
Girish Ramakrishnan
2025-02-14 17:26:54 +01:00
parent 68a08b1f62
commit 8e58349bfa
66 changed files with 1086 additions and 1031 deletions
+10 -10
View File
@@ -8,7 +8,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent'),
superagent = require('../../superagent.js'),
timers = require('timers/promises'),
tokens = require('../../tokens.js');
@@ -26,7 +26,7 @@ describe('API', function () {
.send('some invalid non-strict json')
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
expect(response.body.message).to.be('Failed to parse body');
});
@@ -37,7 +37,7 @@ describe('API', function () {
.send('some string')
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
});
@@ -47,7 +47,7 @@ describe('API', function () {
.auth(owner.username, owner.password)
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('cannot get userInfo with invalid token (token length)', async function () {
@@ -55,7 +55,7 @@ describe('API', function () {
.query({ access_token: 'x' + owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
@@ -63,7 +63,7 @@ describe('API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/users/${user.id}`)
.set('Authorization', 'Bearer ' + owner.token);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.username).to.equal(user.username.toLowerCase());
expect(response.body.email).to.equal(user.email.toLowerCase());
});
@@ -73,7 +73,7 @@ describe('API', function () {
.set('Authorization', 'Bearer ' + 'x' + owner.token)
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('cannot get userInfo with expired token', async function () {
@@ -85,20 +85,20 @@ describe('API', function () {
lastUsedTime: null
};
let result = await tokens.add(token2);
const result = await tokens.add(token2);
token2.id = result.id;
token2.accessToken = result.accessToken;
const response = await superagent.get(`${serverUrl}/api/v1/users/${user.id}`)
.set('Authorization', 'Bearer ' + token2.accessToken);
expect(response.statusCode).to.be(200);
expect(response.status).to.be(200);
await timers.setTimeout(3000); // wait for token to expire
const response2 = await superagent.get(`${serverUrl}/api/v1/users/${user.id}`)
.set('Authorization', 'Bearer ' + token2.accessToken)
.ok(() => true);
expect(response2.statusCode).to.be(401);
expect(response2.status).to.be(401);
});
});
+9 -9
View File
@@ -8,7 +8,7 @@
const applinks = require('../../applinks.js'),
common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('AppLinks API', function () {
const { setup, cleanup, serverUrl, owner } = common;
@@ -22,7 +22,7 @@ describe('AppLinks API', function () {
const response = await superagent.post(`${serverUrl}/api/v1/applinks`)
.query({ access_token: owner.token })
.send({ label: 'Berlin', tags: ['city'], upstreamUri: 'https://www.berlin.de', accessRestriction: null });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
expect(response.body.id).to.be.ok();
applinkId = response.body.id;
@@ -32,14 +32,14 @@ describe('AppLinks API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/applinks/random`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('cannot get valid applink', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/applinks/${applinkId}`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.upstreamUri).to.be('https://www.berlin.de');
});
@@ -47,7 +47,7 @@ describe('AppLinks API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/applinks/${applinkId}/icon`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.headers['content-type']).to.be('application/octet-stream');
});
@@ -55,7 +55,7 @@ describe('AppLinks API', function () {
const response = await superagent.post(`${serverUrl}/api/v1/applinks/${applinkId}`)
.query({ access_token: owner.token })
.send({ tags: ['city', 'germany'] });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
const result = await applinks.get(applinkId);
expect(result.tags).to.eql(['city', 'germany']);
@@ -64,7 +64,7 @@ describe('AppLinks API', function () {
it('can list applinks', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/applinks`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.applinks.length).to.equal(1);
expect(response.body.applinks[0].upstreamUri).to.be('https://www.berlin.de');
});
@@ -73,14 +73,14 @@ describe('AppLinks API', function () {
const response = await superagent.del(`${serverUrl}/api/v1/applinks/random`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('can del applink', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/applinks/${applinkId}`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
const result = await applinks.get(applinkId);
expect(result).to.be(null);
+7 -7
View File
@@ -8,7 +8,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('App Passwords', function () {
const { setup, cleanup, serverUrl, user } = common;
@@ -23,7 +23,7 @@ describe('App Passwords', function () {
.send({ name: 'my-device', identifier: 'someapp' })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('cannot add app password without name', async function () {
@@ -32,7 +32,7 @@ describe('App Passwords', function () {
.send({ identifier: 'someapp' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
let pwd;
@@ -41,7 +41,7 @@ describe('App Passwords', function () {
.query({ access_token: user.token })
.send({ name: 'my-device', identifier: 'someapp' });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
expect(response.body.password).to.be.a('string');
pwd = response.body;
});
@@ -50,7 +50,7 @@ describe('App Passwords', function () {
const response = await superagent.get(`${serverUrl}/api/v1/app_passwords`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.appPasswords).to.be.an(Array);
expect(response.body.appPasswords.length).to.be(1);
expect(response.body.appPasswords[0].name).to.be('my-device');
@@ -63,7 +63,7 @@ describe('App Passwords', function () {
const response = await superagent.get(`${serverUrl}/api/v1/app_passwords/${pwd.id}`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.name).to.be('my-device');
expect(response.body.identifier).to.be('someapp');
expect(response.body.hashedPassword).to.be(undefined);
@@ -74,7 +74,7 @@ describe('App Passwords', function () {
const response = await superagent.del(`${serverUrl}/api/v1/app_passwords/${pwd.id}`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
});
});
+102 -102
View File
@@ -24,7 +24,7 @@ const apps = require('../../apps.js'),
safe = require('safetydance'),
server = require('../../server.js'),
settings = require('../../settings.js'),
superagent = require('superagent'),
superagent = require('../../superagent.js'),
tokens = require('../../tokens.js'),
url = require('url');
@@ -97,7 +97,7 @@ function waitForTask(taskId, callback) {
.end(function (error, result) {
process.stdout.write('.');
if (!result || result.statusCode !== 200) return retryCallback(null, new Error('Bad result'));
if (!result || result.status !== 200) return retryCallback(null, new Error('Bad result'));
if (result.body.active) return retryCallback(new Error('Still active'));
@@ -113,7 +113,7 @@ function waitForSetup(done) {
async.retry({ times: 5, interval: 4000 }, function (retryCallback) {
superagent.get(SERVER_URL + '/api/v1/cloudron/status')
.end(function (error, result) {
if (!result || result.statusCode !== 200) return retryCallback(new Error('Bad result'));
if (!result || result.status !== 200) return retryCallback(new Error('Bad result'));
if (!result.body.setup.active && result.body.setup.errorMessage === '' && result.body.adminFqdn) return retryCallback();
@@ -146,7 +146,7 @@ function startBox(done) {
.send({ domainConfig: DOMAIN_0 })
.end(function (error, result) {
expect(result).to.be.ok();
expect(result.statusCode).to.eql(200);
expect(result.status).to.eql(200);
waitForSetup(callback);
});
@@ -157,7 +157,7 @@ function startBox(done) {
.send({ username: USERNAME, password: PASSWORD, email: EMAIL })
.end(function (error, result) {
expect(result).to.be.ok();
expect(result.statusCode).to.eql(201);
expect(result.status).to.eql(201);
// stash for further use
token = result.body.token;
@@ -171,7 +171,7 @@ function startBox(done) {
.query({ access_token: token })
.send({ username: USERNAME_1, email: EMAIL_1, invite: false })
.end(async function (err, res) {
expect(res.statusCode).to.equal(201);
expect(res.status).to.equal(201);
user_1_id = res.body.id;
token_1 = hat(8 * 32);
@@ -236,7 +236,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
expect(res.body.message).to.eql('appStoreId or manifest is required');
done();
});
@@ -247,7 +247,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ manifest: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
expect(res.body.message).to.eql('appStoreId or manifest is required');
done();
});
@@ -258,7 +258,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ manifest: 'epic' })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
expect(res.body.message).to.eql('manifest must be an object');
done();
});
@@ -269,7 +269,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ manifest: null, appStoreId: '' })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
expect(res.body.message).to.eql('appStoreId or manifest is required');
done();
});
@@ -280,7 +280,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send('garbage')
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -290,7 +290,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ manifest: APP_MANIFEST, subdomain: 'some', accessRestriction: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
expect(res.body.message).to.eql('domain is required');
done();
});
@@ -301,7 +301,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ manifest: APP_MANIFEST, subdomain: 'some', accessRestriction: null, domain: 'doesnotexist.com' })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
expect(res.body.message).to.eql('No such domain');
done();
});
@@ -312,7 +312,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ manifest: APP_MANIFEST, subdomain: 42, accessRestriction: null, domain: DOMAIN_0.domain })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
expect(res.body.message).to.eql('subdomain is required');
done();
});
@@ -323,7 +323,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ manifest: APP_MANIFEST, subdomain: 'my', accessRestriction: null, domain: DOMAIN_0.domain })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
expect(res.body.message).to.contain('my is reserved');
done();
});
@@ -334,7 +334,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ manifest: APP_MANIFEST, subdomain: constants.SMTP_SUBDOMAIN, accessRestriction: null, domain: DOMAIN_0.domain })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
expect(res.body.message).to.contain(constants.SMTP_SUBDOMAIN + ' is reserved');
done();
});
@@ -345,7 +345,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ manifest: APP_MANIFEST, subdomain: APP_SUBDOMAIN, portBindings: 23, accessRestriction: null, domain: DOMAIN_0.domain })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
expect(res.body.message).to.contain('portBindings must be an object');
done();
});
@@ -356,7 +356,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ manifest: APP_MANIFEST, subdomain: APP_SUBDOMAIN, portBindings: {}, domain: DOMAIN_0.domain })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
expect(res.body.message).to.contain('accessRestriction is required');
done();
});
@@ -367,7 +367,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ manifest: APP_MANIFEST, subdomain: APP_SUBDOMAIN, portBindings: {}, accessRestriction: '', domain: DOMAIN_0.domain })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
expect(res.body.message).to.contain('accessRestriction is required');
done();
});
@@ -378,7 +378,7 @@ xdescribe('App API', function () {
.query({ access_token: token_1 })
.send({ manifest: APP_MANIFEST, subdomain: APP_SUBDOMAIN, portBindings: null, accessRestriction: null, domain: DOMAIN_0.domain })
.end(function (err, res) {
expect(res.statusCode).to.equal(403);
expect(res.status).to.equal(403);
done();
});
});
@@ -390,7 +390,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ appStoreId: APP_STORE_ID, subdomain: APP_SUBDOMAIN, portBindings: null, domain: DOMAIN_0.domain, accessRestriction: { users: [ 'someuser' ], groups: [] } })
.end(function (err, res) {
expect(res.statusCode).to.equal(404);
expect(res.status).to.equal(404);
expect(fake.isDone()).to.be.ok();
done();
});
@@ -403,7 +403,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ appStoreId: APP_STORE_ID, subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, portBindings: null, accessRestriction: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(402);
expect(res.status).to.equal(402);
expect(fake1.isDone()).to.be.ok();
done();
});
@@ -419,7 +419,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ appStoreId: APP_STORE_ID, subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, portBindings: { ECHO_SERVER_PORT: 7171 }, accessRestriction: { users: [ 'someuser' ], groups: [] } })
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
expect(res.body.id).to.be.a('string');
APP_ID = res.body.id;
expect(fake1.isDone()).to.be.ok();
@@ -432,7 +432,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ manifest: APP_MANIFEST, subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, portBindings: null, accessRestriction: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(409);
expect(res.status).to.equal(409);
done();
});
});
@@ -443,7 +443,7 @@ xdescribe('App API', function () {
superagent.get(SERVER_URL + '/api/v1/apps/' + APP_ID)
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
expect(res.body.id).to.eql(APP_ID);
expect(res.body.installationState).to.be.ok();
expect(res.body.mailboxName).to.be(APP_SUBDOMAIN + '.app');
@@ -456,7 +456,7 @@ xdescribe('App API', function () {
superagent.get(SERVER_URL + '/api/v1/apps/kubachi')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(404);
expect(res.status).to.equal(404);
done();
});
});
@@ -465,7 +465,7 @@ xdescribe('App API', function () {
superagent.get(SERVER_URL + '/api/v1/apps')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
expect(res.body.apps).to.be.an('array');
expect(res.body.apps[0].id).to.eql(APP_ID);
expect(res.body.apps[0].installationState).to.be.ok();
@@ -477,7 +477,7 @@ xdescribe('App API', function () {
superagent.get(SERVER_URL + '/api/v1/apps')
.query({ access_token: token_1 })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
expect(res.body.apps).to.be.an('array');
expect(res.body.apps.length).to.equal(0);
done();
@@ -496,7 +496,7 @@ xdescribe('App API', function () {
superagent.get(SERVER_URL + '/api/v1/apps/' + APP_ID)
.query({ access_token: token })
.end(function (err, res) {
if (res.statusCode !== 200) return callback(new Error('Response error'));
if (res.status !== 200) return callback(new Error('Response error'));
if (res.body.installationState === apps.ISTATE_INSTALLED) { appResult = res.body; return callback(); }
if (res.body.installationState === apps.ISTATE_ERROR) return callback(new Error('Install error'));
@@ -570,7 +570,7 @@ xdescribe('App API', function () {
console.log(`talking to http://${appEntry.containerIp}:7777`);
superagent.get(`http://${appEntry.containerIp}:7777`).end(function (error, result) {
console.dir(error);
expect(result.statusCode).to.equal(200);
expect(result.status).to.equal(200);
done();
});
});
@@ -600,7 +600,7 @@ xdescribe('App API', function () {
superagent.get(SERVER_URL + '/api/v1/apps/' + APP_ID + '/logstream')
.query({ access_token: token, fromLine: 0 })
.end(function (err, res) {
expect(res.statusCode).to.be(400);
expect(res.status).to.be(400);
done();
});
});
@@ -637,7 +637,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/label')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -647,7 +647,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ label: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -657,7 +657,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ label: 'LABEL'})
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -666,7 +666,7 @@ xdescribe('App API', function () {
superagent.get(SERVER_URL + '/api/v1/apps/' + APP_ID)
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
expect(res.body.label).to.be('LABEL');
done();
});
@@ -677,7 +677,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/tags')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -687,7 +687,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ tags: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -697,7 +697,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ tags: ['tag1', '', 'tag2'] })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -707,7 +707,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ tags: ['tag1', 123, 'tag2'] })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -717,7 +717,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ tags: [ 'tag1', 'tag2' ] })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -726,7 +726,7 @@ xdescribe('App API', function () {
superagent.get(SERVER_URL + '/api/v1/apps/' + APP_ID)
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
expect(res.body.tags).to.eql([ 'tag1', 'tag2' ]);
done();
});
@@ -736,7 +736,7 @@ xdescribe('App API', function () {
it('fails for no icon', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/icon')
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -745,7 +745,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/icon')
.send({ icon: 'something non base64' })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -755,7 +755,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ icon: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX/TQBcNTh/AAAAAXRSTlPM0jRW/QAAAApJREFUeJxjYgAAAAYAAzY3fKgAAAAASUVORK5CYII=' })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -763,7 +763,7 @@ xdescribe('App API', function () {
it('did set the icon', function (done) {
superagent.get(SERVER_URL + '/api/v1/apps/' + APP_ID + '/icon')
.end(function (err, res) {
expect(res.statusCode).to.equal(200); // response is some PNG
expect(res.status).to.equal(200); // response is some PNG
done();
});
});
@@ -773,7 +773,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ icon: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -784,7 +784,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ enable: false })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -793,7 +793,7 @@ xdescribe('App API', function () {
superagent.get(SERVER_URL + '/api/v1/apps/' + APP_ID)
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
expect(res.body.enableAutomaticUpdate).to.be(false);
done();
});
@@ -804,7 +804,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ enable: false })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -813,7 +813,7 @@ xdescribe('App API', function () {
superagent.get(SERVER_URL + '/api/v1/apps/' + APP_ID)
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
expect(res.body.enableBackup).to.be(false);
done();
});
@@ -825,7 +825,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ accessRestriction: false })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -835,7 +835,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ accessRestriction: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -845,7 +845,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ accessRestriction: { users: [ 'someuserid' ], groups: [ 'somegroupid' ] } })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -856,7 +856,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ upstreamUri: '' })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -866,7 +866,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ upstreamUri: 'foobar:com' })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -876,7 +876,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ upstreamUri: 'https://1.2.3.4:443' })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -887,7 +887,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, cert: CERT })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -897,7 +897,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, key: KEY })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -907,7 +907,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, cert: 'x' + CERT, key: KEY })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -917,7 +917,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, cert: CERT, key: KEY })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -927,7 +927,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, cert: null, key: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -938,7 +938,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/memory_limit')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -948,7 +948,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ memoryLimit: -34 })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -958,7 +958,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ memoryLimit: 512 * 1024 * 1024 })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
done();
});
@@ -987,7 +987,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ robotsTxt: 34 })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -997,7 +997,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ robotsTxt: 'any string is good', csp: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -1007,7 +1007,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ robotsTxt: null, csp: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -1017,7 +1017,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ robotsTxt: null, csp: 34 })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -1027,7 +1027,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ robotsTxt: null, csp: 'frame-ancestors \'self\'' })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -1037,7 +1037,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ robotsTxt: null, csp: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
expect(res.status).to.equal(200);
done();
});
});
@@ -1049,7 +1049,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ subdomain: 'hellothre' })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -1059,7 +1059,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ subdomain: 1234, domain: DOMAIN_0.domain })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -1069,7 +1069,7 @@ xdescribe('App API', function () {
.query({ access_token: token_1 })
.send({ subdomain: APP_SUBDOMAIN_NEW, domain: DOMAIN_0.domain, portBindings: { ECHO_SERVER_PORT: 7172 }, accessRestriction: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(403);
expect(res.status).to.equal(403);
done();
});
});
@@ -1079,7 +1079,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ subdomain: APP_SUBDOMAIN_NEW, domain: DOMAIN_0.domain, portBindings: { ECHO_SERVER_PORT: 7172 } })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
done();
});
@@ -1125,7 +1125,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/debug_mode')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -1135,7 +1135,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ debugMode: 'sleep' })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -1145,7 +1145,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ debugMode: { readonlyRootfs: false } })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
done();
});
@@ -1173,7 +1173,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ debugMode: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
done();
});
@@ -1202,7 +1202,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/env')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -1212,7 +1212,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ env: 'ok' })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -1222,7 +1222,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ env: { 'OPM': 'SAITAMA' } })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
done();
});
@@ -1250,7 +1250,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ env: {} })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
done();
});
@@ -1278,7 +1278,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/mailbox')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -1288,7 +1288,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ mailbox: 'genos@cloudron.io' })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -1298,7 +1298,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ mailboxName: 'genos', mailboxDomain: DOMAIN_0.domain })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
done();
});
@@ -1326,7 +1326,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ mailboxName: null, mailboxDomain: DOMAIN_0.domain })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
done();
});
@@ -1354,7 +1354,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/data_dir')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -1364,7 +1364,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ dataDir: 'what' })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
expect(res.status).to.equal(400);
done();
});
});
@@ -1377,7 +1377,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ dataDir: dataDir })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
done();
});
@@ -1392,7 +1392,7 @@ xdescribe('App API', function () {
.query({ access_token: token })
.send({ dataDir: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
done();
});
@@ -1409,7 +1409,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/stop')
.query({ access_token: token_1 })
.end(function (err, res) {
expect(res.statusCode).to.equal(403);
expect(res.status).to.equal(403);
done();
});
});
@@ -1418,7 +1418,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/stop')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
done();
});
@@ -1437,7 +1437,7 @@ xdescribe('App API', function () {
// wait for app status to be updated
superagent.get(SERVER_URL + '/api/v1/apps/' + APP_ID).query({ access_token: token }).end(function (error, result) {
if (error || result.statusCode !== 200 || result.body.runState !== 'stopped') return done(new Error('App is not in stopped state'));
if (error || result.status !== 200 || result.body.runState !== 'stopped') return done(new Error('App is not in stopped state'));
done();
});
@@ -1449,7 +1449,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/start')
.query({ access_token: token_1 })
.end(function (err, res) {
expect(res.statusCode).to.equal(403);
expect(res.status).to.equal(403);
done();
});
});
@@ -1458,7 +1458,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/start')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
done();
});
@@ -1474,7 +1474,7 @@ xdescribe('App API', function () {
superagent.get('http://localhost:' + app.httpPort + APP_MANIFEST.healthCheckPath)
.end(function (err, res) {
if (res && res.statusCode === 200) return done();
if (res && res.status === 200) return done();
done(new Error('app is not running'));
});
});
@@ -1484,7 +1484,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/restart')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
done();
});
@@ -1500,7 +1500,7 @@ xdescribe('App API', function () {
superagent.get('http://localhost:' + app.httpPort + APP_MANIFEST.healthCheckPath)
.end(function (err, res) {
if (res && res.statusCode === 200) return done();
if (res && res.status === 200) return done();
done(new Error('app is not running'));
});
});
@@ -1512,7 +1512,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/whatever/uninstall')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(404);
expect(res.status).to.equal(404);
done();
});
});
@@ -1521,7 +1521,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/uninstall')
.query({ access_token: token_1 })
.end(function (err, res) {
expect(res.statusCode).to.equal(403);
expect(res.status).to.equal(403);
done();
});
});
@@ -1533,7 +1533,7 @@ xdescribe('App API', function () {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/uninstall')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
expect(res.status).to.equal(202);
taskId = res.body.taskId;
expect(fake1.isDone()).to.be.ok();
expect(fake2.isDone()).to.be.ok();
@@ -1562,7 +1562,7 @@ xdescribe('App API', function () {
superagent.get(SERVER_URL + '/api/v1/apps/' + APP_ID)
.query({ access_token: token })
.end(function (err, res) {
if (res.statusCode === 404) return done(null);
if (res.status === 404) return done(null);
done(new Error('App is still there'));
});
});
+10 -10
View File
@@ -11,7 +11,7 @@ const appstore = require('../../appstore.js'),
expect = require('expect.js'),
nock = require('nock'),
settings = require('../../settings.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
const { setup, cleanup, serverUrl, owner, appstoreToken } = common;
@@ -24,7 +24,7 @@ describe('Appstore Apps API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/appstore/apps`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.be(424);
expect(response.status).to.be(424);
});
it('cannot get app with bad token', async function () {
@@ -36,7 +36,7 @@ describe('Appstore Apps API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.be(412);
expect(response.status).to.be(412);
expect(scope1.isDone()).to.be.ok();
});
@@ -48,7 +48,7 @@ describe('Appstore Apps API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/appstore/apps`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(scope1.isDone()).to.be.ok();
});
@@ -60,7 +60,7 @@ describe('Appstore Apps API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/appstore/apps/org.wordpress.cloudronapp`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(scope1.isDone()).to.be.ok();
});
@@ -72,7 +72,7 @@ describe('Appstore Apps API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/appstore/apps/org.wordpress.cloudronapp/versions/3.4.2`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(scope1.isDone()).to.be.ok();
});
});
@@ -102,7 +102,7 @@ describe('Appstore Cloudron Registration API - existing user', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
expect(scope1.isDone()).to.not.be.ok(); // should not have called register_user since signup is false
expect(scope2.isDone()).to.be.ok();
expect(scope3.isDone()).to.be.ok();
@@ -118,7 +118,7 @@ describe('Appstore Cloudron Registration API - existing user', function () {
const response = await superagent.get(`${serverUrl}/api/v1/appstore/subscription`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.email).to.be('test@cloudron.io');
expect(response.body.subscription).to.be.an('object');
expect(scope1.isDone()).to.be.ok();
@@ -149,7 +149,7 @@ describe('Appstore Cloudron Registration API - new user signup', function () {
.send({ email: 'test@cloudron.io', password: 'secret', signup: true })
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
expect(scope1.isDone()).to.be.ok();
expect(scope2.isDone()).to.be.ok();
expect(scope3.isDone()).to.be.ok();
@@ -164,7 +164,7 @@ describe('Appstore Cloudron Registration API - new user signup', function () {
const response = await superagent.get(`${serverUrl}/api/v1/appstore/subscription`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.email).to.be('test@cloudron.io');
expect(response.body.subscription).to.be.an('object');
expect(scope1.isDone()).to.be.ok();
+7 -7
View File
@@ -9,7 +9,7 @@ const archives = require('../../archives.js'),
backups = require('../../backups.js'),
common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('Archives API', function () {
const { setup, cleanup, serverUrl, owner, auditSource } = common;
@@ -42,7 +42,7 @@ describe('Archives API', function () {
it('list succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/archives`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.archives.length).to.be(1);
expect(response.body.archives[0].id).to.be(archiveId);
expect(response.body.archives[0].appConfig).to.eql(appBackup.appConfig);
@@ -52,7 +52,7 @@ describe('Archives API', function () {
it('get valid archive', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/archives/${archiveId}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.appConfig).to.eql(appBackup.appConfig);
expect(response.body.manifest).to.eql(appBackup.manifest);
});
@@ -61,24 +61,24 @@ describe('Archives API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/archives/random`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('cannot del invalid archive', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/archives/random`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('del valid archive', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/archives/${archiveId}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
const response2 = await superagent.get(`${serverUrl}/api/v1/archives`)
.query({ access_token: owner.token });
expect(response2.statusCode).to.equal(200);
expect(response2.status).to.equal(200);
expect(response2.body.archives.length).to.be(0);
});
});
+27 -27
View File
@@ -8,7 +8,7 @@
const backups = require('../../backups.js'),
common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
const BACKUP_FOLDER = '/tmp/backup_test';
@@ -33,7 +33,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set backup_policy with invalid schedule', async function () {
@@ -45,7 +45,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set backup_policy without retention', async function () {
@@ -57,7 +57,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set backup_policy with invalid retention', async function () {
@@ -69,7 +69,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set backup_policy with empty retention', async function () {
@@ -81,7 +81,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set backup_policy with retention missing properties', async function () {
@@ -93,7 +93,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set backup_policy with retention with invalid keepWithinSecs', async function () {
@@ -105,7 +105,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
});
@@ -122,7 +122,7 @@ describe('Backups API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/backups/config`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body).to.eql(defaultConfig);
});
@@ -135,7 +135,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set backup_config with invalid provider', async function () {
@@ -147,7 +147,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set backup_config without format', async function () {
@@ -159,7 +159,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set backup_config with invalid format', async function () {
@@ -171,7 +171,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set backup_config with invalid password', async function () {
@@ -183,7 +183,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set backup_config with invalid syncConcurrency', async function () {
@@ -195,7 +195,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set backup_config with invalid syncConcurrency', async function () {
@@ -207,7 +207,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set backup_config with invalid acceptSelfSignedCerts', async function () {
@@ -219,7 +219,7 @@ describe('Backups API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('can set backup_config', async function () {
@@ -232,14 +232,14 @@ describe('Backups API', function () {
.query({ access_token: owner.token })
.send(tmp);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
it('can get backup_config', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/backups/config`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.format).to.equal('rsync');
expect(response.body.backupFolder).to.equal(BACKUP_FOLDER);
});
@@ -258,20 +258,20 @@ describe('Backups API', function () {
it('fails due to mising token', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/backups/create`)
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('fails due to wrong token', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/backups/create`)
.query({ access_token: 'randomtoken' })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('succeeds', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/backups/create`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(202);
expect(response.status).to.equal(202);
expect(response.body.taskId).to.be.a('string');
await waitForTask(response.body.taskId);
});
@@ -281,7 +281,7 @@ describe('Backups API', function () {
it('succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/backups`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.backups.length).to.be(1);
});
});
@@ -292,7 +292,7 @@ describe('Backups API', function () {
before(async function () {
const response = await superagent.get(`${serverUrl}/api/v1/backups`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.backups.length).to.be(1);
someBackup = response.body.backups[0];
});
@@ -302,7 +302,7 @@ describe('Backups API', function () {
.query({ access_token: owner.token })
.send({ preserveSecs: 'not-a-number', label: 'some string' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails for unknown backup', async function () {
@@ -311,14 +311,14 @@ describe('Backups API', function () {
.send({ preserveSecs: 30, label: 'NewOrleans' })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('succeeds', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/backups/${someBackup.id}`)
.query({ access_token: owner.token })
.send({ preserveSecs: 30, label: 'NewOrleans' });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
});
});
+14 -14
View File
@@ -10,7 +10,7 @@ const common = require('./common.js'),
expect = require('expect.js'),
fs = require('fs'),
paths = require('../../paths.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('Branding API', function () {
const { setup, cleanup, serverUrl, owner } = common;
@@ -25,7 +25,7 @@ describe('Branding API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/branding/cloudron_name`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.name).to.be('Cloudron');
});
@@ -34,7 +34,7 @@ describe('Branding API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set empty name', async function () {
@@ -43,7 +43,7 @@ describe('Branding API', function () {
.send({ name: '' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('set succeeds', async function () {
@@ -51,14 +51,14 @@ describe('Branding API', function () {
.query({ access_token: owner.token })
.send({ name });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
it('get succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/branding/cloudron_name`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.name).to.eql(name);
});
});
@@ -68,7 +68,7 @@ describe('Branding API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/branding/cloudron_avatar`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body).to.be.a(Buffer);
});
@@ -77,7 +77,7 @@ describe('Branding API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('set succeeds', async function () {
@@ -85,14 +85,14 @@ describe('Branding API', function () {
.query({ access_token: owner.token })
.attach('avatar', paths.CLOUDRON_DEFAULT_AVATAR_FILE);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
it('get succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/branding/cloudron_avatar`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.toString()).to.eql(fs.readFileSync(paths.CLOUDRON_DEFAULT_AVATAR_FILE, 'utf-8'));
});
});
@@ -102,7 +102,7 @@ describe('Branding API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/branding/footer`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.footer).to.eql(constants.FOOTER);
});
@@ -111,7 +111,7 @@ describe('Branding API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('set succeeds', async function () {
@@ -119,14 +119,14 @@ describe('Branding API', function () {
.query({ access_token: owner.token })
.send({ footer: 'BigFoot Inc' });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
it('get succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/branding/footer`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.footer).to.eql('BigFoot Inc');
});
});
+34 -34
View File
@@ -8,7 +8,7 @@
const constants = require('../../constants.js'),
common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('Cloudron', function () {
const { setup, cleanup, serverUrl, owner, user, dashboardFqdn } = common;
@@ -21,14 +21,14 @@ describe('Cloudron', function () {
const response = await superagent.get(`${serverUrl}/api/v1/dashboard/config`)
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('can get config (admin)', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/dashboard/config`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.apiServerOrigin).to.eql('http://localhost:6060');
expect(response.body.webServerOrigin).to.eql('https://cloudron.io');
expect(response.body.adminFqdn).to.eql(dashboardFqdn);
@@ -40,7 +40,7 @@ describe('Cloudron', function () {
const response = await superagent.get(`${serverUrl}/api/v1/dashboard/config`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.apiServerOrigin).to.eql('http://localhost:6060');
expect(response.body.webServerOrigin).to.eql('https://cloudron.io');
expect(response.body.adminFqdn).to.eql(dashboardFqdn);
@@ -61,13 +61,13 @@ describe('Cloudron', function () {
const response = await superagent.post(`${serverUrl}/api/v1/users`)
.query({ access_token: owner.token })
.send({ email: USER.email });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
USER.id = response.body.id;
const response2 = await superagent.get(`${serverUrl}/api/v1/users/${USER.id}/invite_link`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response2.statusCode).to.equal(200);
expect(response2.status).to.equal(200);
const response3 = await superagent.post(`${serverUrl}/api/v1/auth/setup_account`)
.send({
@@ -77,20 +77,20 @@ describe('Cloudron', function () {
displayName: USER.displayName
})
.ok(() => true);
expect(response3.statusCode).to.equal(201);
expect(response3.status).to.equal(201);
expect(response3.body.accessToken).to.be.a('string');
const response4 = await superagent.get(`${serverUrl}/api/v1/users/${USER.id}`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response4.statusCode).to.equal(200);
expect(response4.status).to.equal(200);
expect(response4.body.username).to.equal(USER.username);
expect(response4.body.displayName).to.equal(USER.displayName);
const response5 = await superagent.post(`${serverUrl}/api/v1/auth/login`)
.send({ username: USER.username, password: USER.password });
expect(response5.statusCode).to.equal(200);
expect(response5.status).to.equal(200);
});
it('succeeds and overwrites with pre-set username and display name', async function () {
@@ -104,13 +104,13 @@ describe('Cloudron', function () {
const response = await superagent.post(`${serverUrl}/api/v1/users`)
.query({ access_token: owner.token })
.send({ email: USER.email, username: 'presetup2', displayName: 'pre setup' });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
USER.id = response.body.id;
const response2 = await superagent.get(`${serverUrl}/api/v1/users/${USER.id}/invite_link`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response2.statusCode).to.equal(200);
expect(response2.status).to.equal(200);
const response3 = await superagent.post(`${serverUrl}/api/v1/auth/setup_account`)
.send({
@@ -120,7 +120,7 @@ describe('Cloudron', function () {
displayName: USER.displayName
})
.ok(() => true);
expect(response3.statusCode).to.equal(409);
expect(response3.status).to.equal(409);
const response4 = await superagent.post(`${serverUrl}/api/v1/auth/setup_account`)
.send({
@@ -129,20 +129,20 @@ describe('Cloudron', function () {
displayName: USER.displayName
})
.ok(() => true);
expect(response4.statusCode).to.equal(201);
expect(response4.status).to.equal(201);
expect(response4.body.accessToken).to.be.a('string');
const response5 = await superagent.get(`${serverUrl}/api/v1/users/${USER.id}`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response5.statusCode).to.equal(200);
expect(response5.status).to.equal(200);
expect(response5.body.username).to.equal(USER.username);
expect(response5.body.displayName).to.equal(USER.displayName);
const response6 = await superagent.post(`${serverUrl}/api/v1/auth/login`)
.send({ username: USER.username, password: USER.password });
expect(response6.statusCode).to.equal(200);
expect(response6.status).to.equal(200);
});
it('succeeds and does not overwrite pre-set username and display name if profiles are locked', async function () {
@@ -156,18 +156,18 @@ describe('Cloudron', function () {
const response0 = await superagent.post(`${serverUrl}/api/v1/user_directory/profile_config`)
.query({ access_token: owner.token })
.send({ lockUserProfiles: true, mandatory2FA: false });
expect(response0.statusCode).to.equal(200);
expect(response0.status).to.equal(200);
const response = await superagent.post(`${serverUrl}/api/v1/users`)
.query({ access_token: owner.token })
.send({ email: USER.email, username: 'presetup3', displayName: 'pre setup3' });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
USER.id = response.body.id;
const response2 = await superagent.get(`${serverUrl}/api/v1/users/${USER.id}/invite_link`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response2.statusCode).to.equal(200);
expect(response2.status).to.equal(200);
const response3 = await superagent.post(`${serverUrl}/api/v1/auth/setup_account`)
.send({
@@ -177,20 +177,20 @@ describe('Cloudron', function () {
displayName: USER.displayName // ignored
})
.ok(() => true);
expect(response3.statusCode).to.equal(201);
expect(response3.status).to.equal(201);
expect(response3.body.accessToken).to.be.a('string');
const response4 = await superagent.get(`${serverUrl}/api/v1/users/${USER.id}`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response4.statusCode).to.equal(200);
expect(response4.status).to.equal(200);
expect(response4.body.username).to.equal('presetup3'); // what the admin provided
expect(response4.body.displayName).to.equal('pre setup3'); // what the admin provided
const response5 = await superagent.post(`${serverUrl}/api/v1/auth/login`)
.send({ username: 'presetup3', password: USER.password });
expect(response5.statusCode).to.equal(200);
expect(response5.status).to.equal(200);
});
});
@@ -198,7 +198,7 @@ describe('Cloudron', function () {
it('cannot login without body', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/auth/login`)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot login without username', async function () {
@@ -206,7 +206,7 @@ describe('Cloudron', function () {
.send({ password: owner.password })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot login without password', async function () {
@@ -214,7 +214,7 @@ describe('Cloudron', function () {
.send({ username: owner.username })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot login with empty username', async function () {
@@ -222,7 +222,7 @@ describe('Cloudron', function () {
.send({ username: '', password: owner.password })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot login with empty password', async function () {
@@ -230,7 +230,7 @@ describe('Cloudron', function () {
.send({ username: owner.username, password: '' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot login with unknown username', async function () {
@@ -238,7 +238,7 @@ describe('Cloudron', function () {
.send({ username: 'somethingrandom', password: owner.password })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('cannot login with unknown email', async function () {
@@ -246,7 +246,7 @@ describe('Cloudron', function () {
.send({ username: 'randomgemail', password: owner.password })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('cannot login with wrong password', async function () {
@@ -254,14 +254,14 @@ describe('Cloudron', function () {
.send({ username: owner.username, password: owner.password.toUpperCase() })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('can login with username', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/auth/login`)
.send({ username: owner.username, password: owner.password });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(new Date(response.body.expires).toString()).to.not.be('Invalid Date');
expect(response.body.accessToken).to.be.a('string');
});
@@ -270,7 +270,7 @@ describe('Cloudron', function () {
const response = await superagent.post(`${serverUrl}/api/v1/auth/login`)
.send({ username: owner.username.toUpperCase(), password: owner.password });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(new Date(response.body.expires).toString()).to.not.be('Invalid Date');
expect(response.body.accessToken).to.be.a('string');
});
@@ -279,7 +279,7 @@ describe('Cloudron', function () {
const response = await superagent.post(`${serverUrl}/api/v1/auth/login`)
.send({ username: owner.email, password: owner.password });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(new Date(response.body.expires).toString()).to.not.be('Invalid Date');
expect(response.body.accessToken).to.be.a('string');
});
@@ -288,7 +288,7 @@ describe('Cloudron', function () {
const response = await superagent.post(`${serverUrl}/api/v1/auth/login`)
.send({ username: owner.email.toUpperCase(), password: owner.password });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(new Date(response.body.expires).toString()).to.not.be('Invalid Date');
expect(response.body.accessToken).to.be.a('string');
});
@@ -298,7 +298,7 @@ describe('Cloudron', function () {
it('succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/cloudron/languages`);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.languages).to.be.an('array');
expect(response.body.languages.indexOf('en')).to.not.equal(-1);
});
+1 -1
View File
@@ -13,7 +13,7 @@ const apps = require('../../apps.js'),
server = require('../../server.js'),
settings = require('../../settings.js'),
support = require('../../support.js'),
superagent = require('superagent'),
superagent = require('../../superagent.js'),
tasks = require('../../tasks.js'),
timers = require('timers/promises'),
tokens = require('../../tokens.js');
+9 -9
View File
@@ -7,7 +7,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('Directory Server API', function () {
const { setup, cleanup, serverUrl, owner } = common;
@@ -27,7 +27,7 @@ describe('Directory Server API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/directory_server/config`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body).to.eql(defaultConfig);
});
@@ -40,7 +40,7 @@ describe('Directory Server API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set directory_server config without secret', async function () {
@@ -53,7 +53,7 @@ describe('Directory Server API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot enable directory_server config with empty secret', async function () {
@@ -65,7 +65,7 @@ describe('Directory Server API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot enable directory_server config with empty allowlist', async function () {
@@ -78,7 +78,7 @@ describe('Directory Server API', function () {
.send(tmp)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('can enable directory_server config', async function () {
@@ -91,7 +91,7 @@ describe('Directory Server API', function () {
.query({ access_token: owner.token })
.send(tmp);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
it('can get directory_server config', async function () {
@@ -101,7 +101,7 @@ describe('Directory Server API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/directory_server/config`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body).to.eql({ enabled: true, secret: 'ldapsecret', allowlist: '1.2.3.4' });
});
@@ -115,7 +115,7 @@ describe('Directory Server API', function () {
.query({ access_token: owner.token })
.send(tmp);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
});
});
+31 -31
View File
@@ -11,7 +11,7 @@ const child_process = require('child_process'),
fs = require('fs'),
path = require('path'),
paths = require('../../paths.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
const DOMAIN_0 = {
domain: 'domain0.com',
@@ -45,7 +45,7 @@ describe('Domains API', function () {
.send({})
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails with invalid domain', async function () {
@@ -54,7 +54,7 @@ describe('Domains API', function () {
.send({ domain: 'abc' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails with unknown provider', async function () {
@@ -63,7 +63,7 @@ describe('Domains API', function () {
.send({ domain: 'cloudron.com', provider: 'doesnotexist', config: { }})
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails with invalid tlsConfig', async function () {
@@ -72,7 +72,7 @@ describe('Domains API', function () {
.send({ domain: 'cloudron.com', provider: 'noop', config: { }, tlsConfig: 'foobar' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails with unknown tls provider', async function () {
@@ -81,7 +81,7 @@ describe('Domains API', function () {
.send({ domain: 'cloudron.com', provider: 'noop', config: { }, tlsConfig: { provider: 'hello' }})
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails without token', async function () {
@@ -90,7 +90,7 @@ describe('Domains API', function () {
.send(DOMAIN_0)
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('fails for normal user', async function () {
@@ -99,7 +99,7 @@ describe('Domains API', function () {
.send(DOMAIN_0)
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('succeeds', async function () {
@@ -107,7 +107,7 @@ describe('Domains API', function () {
.query({ access_token: owner.token })
.send(DOMAIN_0);
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
});
it('succeeds for second domain without zoneName', async function () {
@@ -115,7 +115,7 @@ describe('Domains API', function () {
.query({ access_token: owner.token })
.send(DOMAIN_1);
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
});
it('fails for already added domain', async function () {
@@ -124,7 +124,7 @@ describe('Domains API', function () {
.send(DOMAIN_0)
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
});
@@ -133,7 +133,7 @@ describe('Domains API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/domains`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.domains).to.be.an(Array);
expect(response.body.domains.length).to.equal(3);
@@ -154,7 +154,7 @@ describe('Domains API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/domains`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.domains).to.be.an(Array);
expect(response.body.domains.length).to.equal(3);
@@ -179,14 +179,14 @@ describe('Domains API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/domains/${DOMAIN_0.domain}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
const d = response.body;
expect(d.domain).to.equal(DOMAIN_0.domain);
expect(d.tlsConfig).to.be.an('object');
@@ -201,7 +201,7 @@ describe('Domains API', function () {
.query({ access_token: user.token })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
});
@@ -211,7 +211,7 @@ describe('Domains API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('config fails as normal user', async function () {
@@ -220,7 +220,7 @@ describe('Domains API', function () {
.send(DOMAIN_0)
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('config succeeds as admin', async function () {
@@ -228,7 +228,7 @@ describe('Domains API', function () {
.query({ access_token: owner.token })
.send(DOMAIN_0);
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('wellknown succeeds', async function () {
@@ -236,7 +236,7 @@ describe('Domains API', function () {
.query({ access_token: owner.token })
.send({ wellKnown: null });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('wellknown succeeds', async function () {
@@ -244,7 +244,7 @@ describe('Domains API', function () {
.query({ access_token: owner.token })
.send({ wellKnown: { service: 'some.service' } });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
});
@@ -271,7 +271,7 @@ describe('Domains API', function () {
.send(d)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set certificate without key', async function () {
@@ -283,7 +283,7 @@ describe('Domains API', function () {
.send(d)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set certificate with cert not being a string', async function () {
@@ -295,7 +295,7 @@ describe('Domains API', function () {
.send(d)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set certificate with key not being a string', async function () {
@@ -307,7 +307,7 @@ describe('Domains API', function () {
.send(d)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set non-fallback certificate', async function () {
@@ -319,7 +319,7 @@ describe('Domains API', function () {
.send(d)
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('can set fallback certificate', async function () {
@@ -330,7 +330,7 @@ describe('Domains API', function () {
.query({ access_token: owner.token })
.send(d);
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('did set the certificate', async function () {
@@ -348,7 +348,7 @@ describe('Domains API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('fails for normal user', async function () {
@@ -356,20 +356,20 @@ describe('Domains API', function () {
.query({ access_token: user.token })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('succeeds as admin', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/domains/${DOMAIN_0.domain}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
const response2 = await superagent.get(`${serverUrl}/api/v1/domains/${DOMAIN_0.domain}`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response2.statusCode).to.equal(404);
expect(response2.status).to.equal(404);
});
});
});
+12 -12
View File
@@ -10,7 +10,7 @@ const async = require('async'),
common = require('./common.js'),
eventlog = require('../../eventlog.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('Eventlog API', function () {
const { setup, cleanup, serverUrl, owner, user } = common;
@@ -35,14 +35,14 @@ describe('Eventlog API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/eventlog/someid`)
.query({ access_token: 'badtoken' })
.ok(() => true);
expect(response.statusCode).to.be(401);
expect(response.status).to.be(401);
});
it('fails for non-admin', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/eventlog/someid`)
.query({ access_token: user.token })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('fails if not exists', async function () {
@@ -50,7 +50,7 @@ describe('Eventlog API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('succeeds for admin', async function () {
@@ -58,7 +58,7 @@ describe('Eventlog API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
delete response.body.event.creationTime;
expect(response.body.event).to.eql(EVENT_0);
});
@@ -69,7 +69,7 @@ describe('Eventlog API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/eventlog`)
.query({ access_token: 'badtoken' })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('fails for non-admin', async function () {
@@ -77,14 +77,14 @@ describe('Eventlog API', function () {
.query({ access_token: user.token, page: 1, per_page: 10 })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('succeeds for admin', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/eventlog`)
.query({ access_token: owner.token, page: 1, per_page: 10 });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.eventlogs.length >= 2).to.be.ok(); // activate, user.add
});
@@ -92,7 +92,7 @@ describe('Eventlog API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/eventlog`)
.query({ access_token: owner.token, page: 1, per_page: 10, action: 'cloudron.activate' });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.eventlogs.length).to.equal(1);
});
@@ -100,7 +100,7 @@ describe('Eventlog API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/eventlog`)
.query({ access_token: owner.token, page: 1, per_page: 10, actions: 'cloudron.activate, user.add' });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.eventlogs.length).to.equal(4);
});
@@ -108,7 +108,7 @@ describe('Eventlog API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/eventlog`)
.query({ access_token: owner.token, page: 1, per_page: 10, search: owner.email });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.eventlogs.length).to.equal(1);
});
@@ -116,7 +116,7 @@ describe('Eventlog API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/eventlog`)
.query({ access_token: owner.token, page: 1, per_page: 10, search: owner.email, actions: 'cloudron.activate' });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.eventlogs.length).to.equal(0);
});
});
+3 -3
View File
@@ -7,7 +7,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('External LDAP API', function () {
const { setup, cleanup, serverUrl, owner } = common;
@@ -23,7 +23,7 @@ describe('External LDAP API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/external_ldap/config`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body).to.eql(defaultConfig);
});
@@ -35,7 +35,7 @@ describe('External LDAP API', function () {
.query({ access_token: owner.token })
.send(config);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
});
});
+26 -26
View File
@@ -8,7 +8,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
const GROUP_NAME = 'externals';
let group0Object, group1Object;
@@ -24,7 +24,7 @@ describe('Groups API', function () {
.send({ name: GROUP_NAME })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('create succeeds', async function () {
@@ -32,7 +32,7 @@ describe('Groups API', function () {
.query({ access_token: owner.token })
.send({ name: GROUP_NAME });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
group0Object = response.body;
});
@@ -42,7 +42,7 @@ describe('Groups API', function () {
.send({ name: GROUP_NAME})
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
it('can create another group', async function () {
@@ -50,7 +50,7 @@ describe('Groups API', function () {
.query({ access_token: owner.token })
.send({ name: 'group1'});
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
group1Object = response.body;
});
@@ -60,7 +60,7 @@ describe('Groups API', function () {
.send({ groupIds: [ group0Object.id, 'something' ]})
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('can set groups of a user', async function () {
@@ -68,7 +68,7 @@ describe('Groups API', function () {
.query({ access_token: owner.token })
.send({ groupIds: [ group0Object.id, group1Object.id ]});
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('cannot set duplicate groups for a user', async function () {
@@ -77,7 +77,7 @@ describe('Groups API', function () {
.send({ groupIds: [ group0Object.id, group1Object.id, group0Object.id ]})
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
it('can set users of a group', async function () {
@@ -85,7 +85,7 @@ describe('Groups API', function () {
.query({ access_token: owner.token })
.send({ userIds: [ owner.id, user.id ]});
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
it('cannot set duplicate users of a group', async function () {
@@ -94,7 +94,7 @@ describe('Groups API', function () {
.send({ userIds: [ owner.id, user.id, owner.id ]})
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
it('cannot get non-existing group', async function () {
@@ -102,7 +102,7 @@ describe('Groups API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('cannot get existing group with normal user', async function () {
@@ -110,14 +110,14 @@ describe('Groups API', function () {
.query({ access_token: user.token })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('can get existing group', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/groups/${group0Object.id}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.name).to.be(group0Object.name);
expect(response.body.userIds.length).to.be(2);
expect(response.body.userIds).to.contain(owner.id);
@@ -128,7 +128,7 @@ describe('Groups API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/groups`)
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('cannot list groups as normal user', async function () {
@@ -136,14 +136,14 @@ describe('Groups API', function () {
.query({ access_token: user.token })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('can list groups', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/groups`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.groups).to.be.an(Array);
expect(response.body.groups.length).to.be(2);
expect(response.body.groups[0].name).to.eql(group0Object.name);
@@ -156,7 +156,7 @@ describe('Groups API', function () {
.send({ })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('can set invalid group name', async function () {
@@ -165,7 +165,7 @@ describe('Groups API', function () {
.send({ name: '!group1-newname'})
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('can set group name', async function () {
@@ -173,7 +173,7 @@ describe('Groups API', function () {
.query({ access_token: owner.token })
.send({ name: 'group1-newname'});
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
it('cannot set unknown app access', async function () {
@@ -182,7 +182,7 @@ describe('Groups API', function () {
.send({ appIds: ['app-id' ] })
.ok(() => true);
expect(response.statusCode).to.equal(200); // bad appId is just ignored
expect(response.status).to.equal(200); // bad appId is just ignored
});
it('can set app access', async function () {
@@ -190,7 +190,7 @@ describe('Groups API', function () {
.query({ access_token: owner.token })
.send({ appIds: [app.id] });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
it('did set app access', async function () {
@@ -206,14 +206,14 @@ describe('Groups API', function () {
.query({ access_token: owner.token })
.send({ groupIds: [ group0Object.id ]});
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('cannot remove without token', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/groups/externals`)
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('can clear users of a group', async function () {
@@ -221,20 +221,20 @@ describe('Groups API', function () {
.query({ access_token: owner.token })
.send({ userIds: [ ]});
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
it('can remove empty group', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/groups/${group1Object.id}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('can remove non-empty group', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/groups/${group0Object.id}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
});
+54 -57
View File
@@ -8,7 +8,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
mail = require('../../mail.js'),
superagent = require('superagent'),
superagent = require('../../superagent.js'),
_ = require('../../underscore.js');
describe('Mail API', function () {
@@ -29,14 +29,14 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('can get domain', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.domain).to.equal(dashboardDomain);
expect(response.body.enabled).to.equal(false);
expect(response.body.mailFromValidation).to.equal(true);
@@ -52,7 +52,7 @@ describe('Mail API', function () {
let dnsAnswerQueue = [];
let dkimDomain, spfDomain, mxDomain, dmarcDomain;
before(function (done) {
before(async function () {
const dig = require('../../dig.js');
// replace dns resolveTxt()
@@ -72,14 +72,11 @@ describe('Mail API', function () {
mxDomain = dashboardDomain;
dmarcDomain = '_dmarc.' + dashboardDomain;
superagent.post(`${serverUrl}/api/v1/mail/${dashboardDomain}/enable`)
const response = await superagent.post(`${serverUrl}/api/v1/mail/${dashboardDomain}/enable`)
.query({ access_token: owner.token })
.send({ enabled: true })
.end(function (err, response) {
expect(response.statusCode).to.equal(202);
.send({ enabled: true });
done();
});
expect(response.status).to.be(202);
});
after(function (done) {
@@ -94,7 +91,7 @@ describe('Mail API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}/status`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
function clearDnsAnswerQueue() {
@@ -110,7 +107,7 @@ describe('Mail API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}` + '/status')
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.dns.dkim).to.be.an('object');
expect(response.body.dns.dkim.domain).to.eql(dkimDomain);
@@ -156,7 +153,7 @@ describe('Mail API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}` + '/status')
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.dns.spf).to.be.an('object');
expect(response.body.dns.spf.expected).to.eql(`v=spf1 a:${dashboardFqdn} ~all`);
@@ -195,7 +192,7 @@ describe('Mail API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}` + '/status')
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.dns.spf).to.be.an('object');
expect(response.body.dns.spf.expected).to.eql(`v=spf1 a:${dashboardFqdn} a:random.com ~all`);
@@ -233,7 +230,7 @@ describe('Mail API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}/status`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.dns.spf).to.be.an('object');
expect(response.body.dns.spf.domain).to.eql(spfDomain);
@@ -251,7 +248,7 @@ describe('Mail API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}/status`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.dns.dmarc).to.be.an('object');
expect(response.body.dns.dmarc.expected).to.eql('v=DMARC1; p=reject; pct=100');
@@ -270,7 +267,7 @@ describe('Mail API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}` + '/status')
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.dns.dkim).to.be.an('object');
expect(response.body.dns.dkim.domain).to.eql(dkimDomain);
@@ -303,7 +300,7 @@ describe('Mail API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.mailFromValidation).to.eql(true);
});
@@ -313,7 +310,7 @@ describe('Mail API', function () {
.send({ })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('can set with enabled field', async function () {
@@ -321,7 +318,7 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.send({ enabled: false });
expect(response.statusCode).to.equal(202);
expect(response.status).to.equal(202);
});
});
@@ -329,7 +326,7 @@ describe('Mail API', function () {
it('get catch_all succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.catchAll).to.eql([]);
});
@@ -339,7 +336,7 @@ describe('Mail API', function () {
.send({ })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set with bad addresses field', async function () {
@@ -348,7 +345,7 @@ describe('Mail API', function () {
.send({ addresses: [ 'user1', 123 ] })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set with bad addresses field', async function () {
@@ -357,7 +354,7 @@ describe('Mail API', function () {
.send({ addresses: [ 'user1' ] })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('set succeeds', async function () {
@@ -365,14 +362,14 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.send({ addresses: [ `user1@${dashboardDomain}` ] });
expect(response.statusCode).to.equal(202);
expect(response.status).to.equal(202);
});
it('get succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.catchAll).to.eql([ `user1@${dashboardDomain}` ]);
});
});
@@ -381,7 +378,7 @@ describe('Mail API', function () {
it('get mail relay succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.relay).to.eql({ provider: 'cloudron-smtp' });
});
@@ -391,7 +388,7 @@ describe('Mail API', function () {
.send({ })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set with bad host', async function () {
@@ -400,7 +397,7 @@ describe('Mail API', function () {
.send({ provider: 'external-smtp', host: true })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('set fails because mail server is unreachable', async function () {
@@ -409,7 +406,7 @@ describe('Mail API', function () {
.send({ provider: 'external-smtp', host: 'host', port: 25, username: 'u', password: 'p', tls: true })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('get succeeds', async function () {
@@ -420,7 +417,7 @@ describe('Mail API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(_.omit(response.body.relay, ['password'])).to.eql(_.omit(relay, ['password']));
});
});
@@ -433,7 +430,7 @@ describe('Mail API', function () {
.send({ name: MAILBOX_NAME, ownerId: owner.id, ownerType: 'user', active: true, storageQuota: 10, messagesQuota: 20 })
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
});
it('cannot add again', async function () {
@@ -442,7 +439,7 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
it('get fails if not exist', async function () {
@@ -450,14 +447,14 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('get succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}/mailboxes/${MAILBOX_NAME}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.mailbox).to.be.an('object');
expect(response.body.mailbox.name).to.equal(MAILBOX_NAME);
expect(response.body.mailbox.ownerId).to.equal(owner.id);
@@ -473,7 +470,7 @@ describe('Mail API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}/mailboxes`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.mailboxes.length).to.eql(1);
expect(response.body.mailboxes[0]).to.be.an('object');
expect(response.body.mailboxes[0].name).to.equal(MAILBOX_NAME);
@@ -491,7 +488,7 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('disable succeeds', async function () {
@@ -499,12 +496,12 @@ describe('Mail API', function () {
.send({ deleteMails: false })
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
const response2 = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}` + '/mailboxes/' + MAILBOX_NAME)
.query({ access_token: owner.token })
.ok(() => true);
expect(response2.statusCode).to.equal(404);
expect(response2.status).to.equal(404);
});
});
@@ -520,7 +517,7 @@ describe('Mail API', function () {
.send({ name: MAILBOX_NAME, ownerId: owner.id, ownerType: 'user', active: true, storageQuota: 10, messagesQuota: 20 })
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
});
it('set fails if aliases is missing', async function () {
@@ -528,7 +525,7 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('set fails if user does not exist', async function () {
@@ -537,7 +534,7 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('set fails if aliases is the wrong type', async function () {
@@ -546,7 +543,7 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('set succeeds', async function () {
@@ -554,14 +551,14 @@ describe('Mail API', function () {
.send({ aliases: [{ name: 'hello*', domain: dashboardDomain}, {name: 'there', domain: dashboardDomain}] })
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(202);
expect(response.status).to.equal(202);
});
it('get succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}` + '/mailboxes/' + MAILBOX_NAME + '/aliases')
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.aliases).to.eql([{ name: 'hello*', domain: dashboardDomain}, {name: 'there', domain: dashboardDomain}]);
});
@@ -570,7 +567,7 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
});
@@ -586,7 +583,7 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('add fails with invalid groupId', async function () {
@@ -595,7 +592,7 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('add fails without members array', async function () {
@@ -604,7 +601,7 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('add succeeds', async function () {
@@ -612,7 +609,7 @@ describe('Mail API', function () {
.send({ name: LIST_NAME, members: [ `admin2@${dashboardDomain}`, `${owner.username}@${dashboardDomain}`], membersOnly: false, active: true })
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
});
it('add twice fails', async function () {
@@ -621,7 +618,7 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
it('get fails if not exist', async function (){
@@ -629,14 +626,14 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('get succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}/lists/${LIST_NAME}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.list).to.be.an('object');
expect(response.body.list.name).to.equal(LIST_NAME);
expect(response.body.list.ownerId).to.equal('admin');
@@ -650,7 +647,7 @@ describe('Mail API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}/lists`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.lists).to.be.an(Array);
expect(response.body.lists.length).to.equal(1);
expect(response.body.lists[0].name).to.equal(LIST_NAME);
@@ -666,20 +663,20 @@ describe('Mail API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('del succeeds', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/mail/${dashboardDomain}/lists/${LIST_NAME}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
const response2 = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}/lists/${LIST_NAME}`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response2.statusCode).to.equal(404);
expect(response2.status).to.equal(404);
});
});
});
+5 -5
View File
@@ -7,7 +7,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('Network API', function () {
const { setup, cleanup, serverUrl, owner } = common;
@@ -20,7 +20,7 @@ describe('Network API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/network/dynamic_dns`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.enabled).to.be(false);
});
@@ -29,7 +29,7 @@ describe('Network API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set', async function () {
@@ -38,14 +38,14 @@ describe('Network API', function () {
.send({ enabled: true })
.ok(() => true);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
it('get succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/network/dynamic_dns`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.enabled).to.be(true);
});
});
+7 -7
View File
@@ -8,7 +8,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
notifications = require('../../notifications.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('Notifications API', function () {
const { setup, cleanup, serverUrl, owner } = common;
@@ -28,13 +28,13 @@ describe('Notifications API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/notifications/random`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('can get notification by id', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/notifications/${notificationIds[0]}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.id).to.be(notificationIds[0]);
expect(response.body.title).to.be('title 0');
expect(response.body.message).to.be('message 0');
@@ -46,7 +46,7 @@ describe('Notifications API', function () {
.query({ access_token: owner.token })
.send({ acknowledged: true })
.ok(() => true);
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
const result = await notifications.get(notificationIds[0]);
expect(result.acknowledged).to.be(true);
@@ -57,20 +57,20 @@ describe('Notifications API', function () {
.query({ access_token: owner.token })
.send({ acknowledged: true })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('can list unread notifications', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/notifications`) // ?acknowledged=false is default
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.notifications.length).to.be.greaterThan(2);
});
it('can list read notifications', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/notifications?acknowledged=true`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.notifications.length).to.be(1);
expect(response.body.notifications[0].id).to.be(notificationIds[0]);
expect(response.body.notifications[0].title).to.be('title 0');
+15 -15
View File
@@ -8,7 +8,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
const CLIENT_0 = {
id: 'client0',
@@ -37,7 +37,7 @@ describe('OpenID connect clients API', function () {
.send(CLIENT_0)
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('create succeeds', async function () {
@@ -45,7 +45,7 @@ describe('OpenID connect clients API', function () {
.query({ access_token: owner.token })
.send(CLIENT_0);
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
CLIENT_0.id = response.body.id;
CLIENT_0.secret = response.body.secret;
});
@@ -55,7 +55,7 @@ describe('OpenID connect clients API', function () {
.query({ access_token: owner.token })
.send(CLIENT_1);
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
CLIENT_1.id = response.body.id;
CLIENT_1.secret = response.body.secret;
});
@@ -65,7 +65,7 @@ describe('OpenID connect clients API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('cannot get existing client with normal user', async function () {
@@ -73,14 +73,14 @@ describe('OpenID connect clients API', function () {
.query({ access_token: user.token })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('can get existing client', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/oidc/clients/${CLIENT_1.id}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.id).to.equal(CLIENT_1.id);
expect(response.body.secret).to.equal(CLIENT_1.secret);
expect(response.body.loginRedirectUri).to.equal(CLIENT_1.loginRedirectUri);
@@ -93,14 +93,14 @@ describe('OpenID connect clients API', function () {
.send(CLIENT_0)
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('cannot list clients without token', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/oidc/clients`)
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('cannot list clients as normal user', async function () {
@@ -108,14 +108,14 @@ describe('OpenID connect clients API', function () {
.query({ access_token: user.token })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('can list clients', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/oidc/clients`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.clients).to.be.an(Array);
expect(response.body.clients.length).to.be(2);
expect(response.body.clients[0].id).to.eql(CLIENT_0.id);
@@ -128,7 +128,7 @@ describe('OpenID connect clients API', function () {
.send({ loginRedirectUri: CLIENT_0.loginRedirectUri })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot update client without loginRedirectUri', async function () {
@@ -137,20 +137,20 @@ describe('OpenID connect clients API', function () {
.send({})
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot remove without token', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/oidc/clients/${CLIENT_0.id}`)
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('can remove empty group', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/oidc/clients/${CLIENT_0.id}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
});
+38 -38
View File
@@ -9,7 +9,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
speakeasy = require('speakeasy'),
superagent = require('superagent'),
superagent = require('../../superagent.js'),
fs = require('fs'),
path = require('path'),
paths = require('../../paths.js'),
@@ -26,7 +26,7 @@ describe('Profile API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/profile`)
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('fails with empty token', async function () {
@@ -34,7 +34,7 @@ describe('Profile API', function () {
.query({ access_token: '' })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('fails with invalid token', async function () {
@@ -42,14 +42,14 @@ describe('Profile API', function () {
.query({ access_token: 'some token' })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('succeeds', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/profile`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.username).to.equal(owner.username.toLowerCase());
expect(response.body.email).to.equal(owner.email.toLowerCase());
expect(response.body.fallbackEmail).to.equal('');
@@ -67,7 +67,7 @@ describe('Profile API', function () {
.query({ access_token: token.accessToken })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('fails with invalid token in auth header', async function () {
@@ -75,13 +75,13 @@ describe('Profile API', function () {
.set('Authorization', 'Bearer ' + 'x' + owner.token)
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('succeeds with token in auth header', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/profile`).set('Authorization', 'Bearer ' + owner.token);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.username).to.equal(owner.username.toLowerCase());
expect(response.body.email).to.equal(owner.email.toLowerCase());
expect(response.body.displayName).to.be.a('string');
@@ -96,7 +96,7 @@ describe('Profile API', function () {
.send({ email: 'newemail@example.com' })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('change email fails due to missing password', async function () {
@@ -105,7 +105,7 @@ describe('Profile API', function () {
.send({ email: 'newemail@example.com' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('change email fails due to invalid password', async function () {
@@ -114,7 +114,7 @@ describe('Profile API', function () {
.send({ email: 'foo@bar.com', password: 'this is wrong' })
.ok(() => true);
expect(response.statusCode).to.equal(412);
expect(response.status).to.equal(412);
});
it('change email fails due to invalid email', async function () {
@@ -123,7 +123,7 @@ describe('Profile API', function () {
.send({ email: 'foo@bar' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('change email succeeds', async function () {
@@ -131,12 +131,12 @@ describe('Profile API', function () {
.query({ access_token: owner.token })
.send({ email: 'newemail@example.Com', password: owner.password });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
const response2 = await superagent.get(`${serverUrl}/api/v1/profile`)
.query({ access_token: owner.token });
expect(response2.statusCode).to.equal(200);
expect(response2.status).to.equal(200);
expect(response2.body.username).to.equal(owner.username);
expect(response2.body.email).to.equal('newemail@example.com'); // lower cased
expect(response2.body.displayName).to.equal('');
@@ -150,7 +150,7 @@ describe('Profile API', function () {
.send({ fallbackEmail: 'newemail@example.com' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('change fallback email fails due to invalid password', async function () {
@@ -159,7 +159,7 @@ describe('Profile API', function () {
.send({ fallbackEmail: 'foo@bar.com', password: 'this is wrong' })
.ok(() => true);
expect(response.statusCode).to.equal(412);
expect(response.status).to.equal(412);
});
it('change fallback email succeeds', async function () {
@@ -167,12 +167,12 @@ describe('Profile API', function () {
.query({ access_token: owner.token })
.send({ fallbackEmail: 'NewFallbackemail@example.com', password: owner.password });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
const response2 = await superagent.get(`${serverUrl}/api/v1/profile`)
.query({ access_token: owner.token });
expect(response2.statusCode).to.equal(200);
expect(response2.status).to.equal(200);
expect(response2.body.username).to.equal(owner.username);
expect(response2.body.fallbackEmail).to.equal('newfallbackemail@example.com'); // lowercase
});
@@ -184,11 +184,11 @@ describe('Profile API', function () {
.query({ access_token: owner.token })
.send({ displayName: 'Agent Smith' });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
const response2 = await superagent.get(`${serverUrl}/api/v1/profile`)
.query({ access_token: owner.token });
expect(response2.statusCode).to.equal(200);
expect(response2.status).to.equal(200);
expect(response2.body.username).to.equal(owner.username);
expect(response2.body.email).to.equal('newemail@example.com'); // lower cased
expect(response2.body.displayName).to.equal('Agent Smith');
@@ -202,7 +202,7 @@ describe('Profile API', function () {
.send({ newPassword: 'some wrong password' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails due to missing new password', async function () {
@@ -211,7 +211,7 @@ describe('Profile API', function () {
.send({ password: owner.password })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails due to wrong password', async function () {
@@ -220,7 +220,7 @@ describe('Profile API', function () {
.send({ password: 'some wrong password', newPassword: 'MOre#$%34' })
.ok(() => true);
expect(response.statusCode).to.equal(412);
expect(response.status).to.equal(412);
});
it('fails due to invalid password', async function () {
@@ -229,7 +229,7 @@ describe('Profile API', function () {
.send({ password: owner.password, newPassword: 'five' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('succeeds', async function () {
@@ -237,7 +237,7 @@ describe('Profile API', function () {
.query({ access_token: owner.token })
.send({ password: owner.password, newPassword: 'MOre#$%34' });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
});
@@ -264,7 +264,7 @@ describe('Profile API', function () {
.send({ username: user.username, password: user.password })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('fails due to wrong token', async function () {
@@ -272,7 +272,7 @@ describe('Profile API', function () {
.send({ username: user.username, password: user.password, totpToken: '12345' })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('succeeds', async function () {
@@ -284,7 +284,7 @@ describe('Profile API', function () {
const response = await superagent.post(`${serverUrl}/api/v1/auth/login`)
.send({ username: user.username, password: user.password, totpToken: totpToken });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body).to.be.an(Object);
expect(response.body.accessToken).to.be.a('string');
});
@@ -299,7 +299,7 @@ describe('Profile API', function () {
const response = await superagent.post(`${serverUrl}/api/v1/auth/login`)
.send({ username: user.username, password: user.password });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body).to.be.an(Object);
expect(response.body.accessToken).to.be.a('string');
});
@@ -324,7 +324,7 @@ describe('Profile API', function () {
customAvatarSize = require('fs').readFileSync('./logo.png').length;
expect(response.statusCode).to.be(202);
expect(response.status).to.be(202);
});
it('did set custom avatar', async function () {
@@ -336,7 +336,7 @@ describe('Profile API', function () {
.ok(() => true);
expect(parseInt(response2.headers['content-length'])).to.equal(customAvatarSize);
expect(response2.statusCode).to.equal(200);
expect(response2.status).to.equal(200);
});
it('can set gravatar', async function () {
@@ -344,7 +344,7 @@ describe('Profile API', function () {
.query({ access_token: user.token })
.send({ avatar: 'gravatar' });
expect(response.statusCode).to.be(202);
expect(response.status).to.be(202);
});
it('did set gravatar', async function () {
@@ -359,7 +359,7 @@ describe('Profile API', function () {
.query({ access_token: user.token })
.send({ avatar: '' });
expect(response.statusCode).to.be(202);
expect(response.status).to.be(202);
});
it('did unset avatar', async function () {
@@ -378,7 +378,7 @@ describe('Profile API', function () {
.query({ access_token: user.token })
.send({ language: 'ta' })
.ok(() => true);
expect(response.statusCode).to.be(400);
expect(response.status).to.be(400);
});
it('fails to set bad language', async function () {
@@ -386,7 +386,7 @@ describe('Profile API', function () {
.query({ access_token: user.token })
.send({ language: 123 })
.ok(() => true);
expect(response.statusCode).to.be(400);
expect(response.status).to.be(400);
});
it('fails to set unknown language', async function () {
@@ -394,14 +394,14 @@ describe('Profile API', function () {
.query({ access_token: user.token })
.send({ language: 'ta' })
.ok(() => true);
expect(response.statusCode).to.be(400);
expect(response.status).to.be(400);
});
it('set valid language', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/profile/language`)
.query({ access_token: user.token })
.send({ language: 'en' });
expect(response.statusCode).to.be(204);
expect(response.status).to.be(204);
});
it('did set language', async function () {
@@ -413,7 +413,7 @@ describe('Profile API', function () {
const response = await superagent.post(`${serverUrl}/api/v1/profile/language`)
.query({ access_token: user.token })
.send({ language: '' });
expect(response.statusCode).to.be(204);
expect(response.status).to.be(204);
});
it('did reset language', async function () {
+26 -26
View File
@@ -8,7 +8,7 @@
const common = require('./common.js');
const expect = require('expect.js'),
superagent = require('superagent'),
superagent = require('../../superagent.js'),
timers = require('timers/promises');
const DOMAIN = 'example-server-test.com';
@@ -39,7 +39,7 @@ describe('Provision', function () {
.send({ domainConfig: { domain: DOMAIN, config: {} } })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails with invalid provider', async function () {
@@ -47,7 +47,7 @@ describe('Provision', function () {
.send({ domainConfig: { provider: 'foobar', domain: DOMAIN, config: {} } })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails with missing domain', async function () {
@@ -55,7 +55,7 @@ describe('Provision', function () {
.send({ domainConfig: { provider: 'noop', config: {} } })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails with invalid domain', async function () {
@@ -63,7 +63,7 @@ describe('Provision', function () {
.send({ domainConfig: { provider: 'noop', domain: '.foo', config: {} } })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails with invalid config', async function () {
@@ -71,7 +71,7 @@ describe('Provision', function () {
.send({ domainConfig: { provider: 'noop', domain: DOMAIN, config: 'not an object' } })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails with invalid zoneName', async function () {
@@ -79,7 +79,7 @@ describe('Provision', function () {
.send({ domainConfig: { provider: 'noop', domain: DOMAIN, config: {}, zoneName: 1337 } })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails with invalid tlsConfig', async function () {
@@ -87,7 +87,7 @@ describe('Provision', function () {
.send({ domainConfig: { provider: 'noop', domain: DOMAIN, config: {}, tlsConfig: 'foobar' } })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails with invalid tlsConfig provider', async function () {
@@ -95,7 +95,7 @@ describe('Provision', function () {
.send({ domainConfig: { provider: 'noop', domain: DOMAIN, config: {}, tlsConfig: { provider: 1337 } } })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('succeeds', async function () {
@@ -103,7 +103,7 @@ describe('Provision', function () {
.send({ domainConfig: { provider: 'noop', domain: DOMAIN, adminFqdn: 'my.' + DOMAIN, config: {}, tlsConfig: { provider: 'fallback' } } })
.ok(() => true);
expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
await waitForSetup();
});
@@ -113,7 +113,7 @@ describe('Provision', function () {
.send({ domainConfig: { provider: 'noop', domain: DOMAIN, adminFqdn: 'my.' + DOMAIN, config: {}, tlsConfig: { provider: 'fallback' } } })
.ok(() => true);
expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
await waitForSetup();
});
@@ -122,7 +122,7 @@ describe('Provision', function () {
describe('Activation', function () {
it('device is in first time mode', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/provision/status`);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.activated).to.not.be.ok();
expect(response.body.version).to.be.ok();
expect(response.body.adminFqdn).to.be.ok(); // dashboard is setup at this point
@@ -133,7 +133,7 @@ describe('Provision', function () {
.send({ password: owner.password, email: owner.email })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails with invalid username', async function () {
@@ -141,7 +141,7 @@ describe('Provision', function () {
.send({ username: '?this.is-not!valid', password: owner.password, email: owner.email })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails due to empty username', async function () {
@@ -149,7 +149,7 @@ describe('Provision', function () {
.send({ username: '', password: owner.password, email: owner.email })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails without email', async function () {
@@ -157,7 +157,7 @@ describe('Provision', function () {
.send({ username: owner.username, password: owner.password })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails due to empty email', async function () {
@@ -165,7 +165,7 @@ describe('Provision', function () {
.send({ username: owner.username, password: owner.password, email: '' })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails due to invalid email', async function () {
@@ -173,7 +173,7 @@ describe('Provision', function () {
.send({ username: owner.username, password: owner.password, email: 'invalidemail' })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails without password', async function () {
@@ -181,7 +181,7 @@ describe('Provision', function () {
.send({ username: owner.password.username, email: owner.email })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails due to empty password', async function () {
@@ -189,7 +189,7 @@ describe('Provision', function () {
.send({ username: owner.username, password: '', email: owner.email })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails with invalid password', async function () {
@@ -197,7 +197,7 @@ describe('Provision', function () {
.send({ username: owner.username, password: 'short', email: owner.email })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('fails due to wrong displayName type', async function () {
@@ -205,14 +205,14 @@ describe('Provision', function () {
.send({ username: owner.username, password: owner.password, email: owner.email, displayName: 1234 })
.ok(() => true);
expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
});
it('succeeds', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/provision/activate`)
.send({ username: owner.username, password: owner.password, email: owner.email, displayName: owner.displayName });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
expect(response.body.token).to.be.a('string');
});
@@ -221,7 +221,7 @@ describe('Provision', function () {
.send({ username: owner.username, password: owner.password, email: owner.email, displayName: owner.displayName })
.ok(() => true);
expect(response.statusCode).to.eql(405); // route unavailable post activation
expect(response.status).to.eql(405); // route unavailable post activation
});
it('seutp fails after activation', async function () {
@@ -229,12 +229,12 @@ describe('Provision', function () {
.send({ domainConfig: { provider: 'noop', domain: DOMAIN, adminFqdn: 'my.' + DOMAIN, config: {}, tlsConfig: { provider: 'fallback' } } })
.ok(() => true);
expect(response.statusCode).to.eql(405);
expect(response.status).to.eql(405);
});
it('device left first time mode', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/provision/status`);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.activated).to.be.ok();
});
});
+19 -19
View File
@@ -10,7 +10,7 @@ const common = require('./common.js'),
fs = require('fs'),
nock = require('nock'),
support = require('../../support.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('Support API', function () {
const { setup, cleanup, serverUrl, owner, mockApiServerOrigin, appstoreToken, user, admin } = common;
@@ -25,7 +25,7 @@ describe('Support API', function () {
it('get remote support', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/support/remote_support`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.enabled).to.be(false);
});
@@ -34,7 +34,7 @@ describe('Support API', function () {
.query({ access_token: owner.token })
.send({ enabled: true });
expect(response.statusCode).to.equal(202);
expect(response.status).to.equal(202);
let data = await fs.promises.readFile(authorizedKeysFile, 'utf8');
let count = (data.match(/support@cloudron.io/g) || []).length;
@@ -44,7 +44,7 @@ describe('Support API', function () {
it('returns true when remote support enabled', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/support/remote_support`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.enabled).to.be(true);
});
@@ -52,7 +52,7 @@ describe('Support API', function () {
const response = await superagent.post(`${serverUrl}/api/v1/support/remote_support`)
.query({ access_token: owner.token })
.send({ enabled: true });
expect(response.statusCode).to.equal(202);
expect(response.status).to.equal(202);
let data = await fs.promises.readFile(authorizedKeysFile, 'utf8');
let count = (data.match(/support@cloudron.io/g) || []).length;
@@ -64,7 +64,7 @@ describe('Support API', function () {
.query({ access_token: owner.token })
.send({ enabled: false });
expect(response.statusCode).to.equal(202);
expect(response.status).to.equal(202);
let data = await fs.promises.readFile(authorizedKeysFile, 'utf8');
let count = (data.match(/support@cloudron.io/g) || []).length;
@@ -76,7 +76,7 @@ describe('Support API', function () {
.query({ access_token: owner.token })
.send({ enabled: false });
expect(response.statusCode).to.equal(202);
expect(response.status).to.equal(202);
const data = await fs.promises.readFile(authorizedKeysFile, 'utf8');
const count = (data.match(/support@cloudron.io/g) || []).length;
@@ -90,7 +90,7 @@ describe('Support API', function () {
.send({ type: 'ticket', subject: 'some subject', description: 'some description' })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('fails without type', async function () {
@@ -99,7 +99,7 @@ describe('Support API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails with empty type', async function () {
@@ -108,7 +108,7 @@ describe('Support API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails with unknown type', async function () {
@@ -117,7 +117,7 @@ describe('Support API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails without description', async function () {
@@ -126,7 +126,7 @@ describe('Support API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails with empty subject', async function () {
@@ -135,7 +135,7 @@ describe('Support API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails with empty description', async function () {
@@ -144,7 +144,7 @@ describe('Support API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('fails without subject', async function () {
@@ -153,7 +153,7 @@ describe('Support API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('succeeds with ticket type', async function () {
@@ -166,7 +166,7 @@ describe('Support API', function () {
.send({ type: 'ticket', subject: 'some subject', description: 'some description' })
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
expect(scope2.isDone()).to.be.ok();
});
@@ -176,7 +176,7 @@ describe('Support API', function () {
.query({ access_token: user.token })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('admin also cannot open tickets', async function () {
@@ -185,7 +185,7 @@ describe('Support API', function () {
.query({ access_token: admin.token })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('owner can open tickets', async function () {
@@ -198,7 +198,7 @@ describe('Support API', function () {
.send({ type: 'app_missing', subject: 'some subject', description: 'some description' })
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
expect(scope2.isDone()).to.be.ok();
});
});
+11 -11
View File
@@ -13,7 +13,7 @@ const constants = require('../../constants.js'),
os = require('os'),
paths = require('../../paths.js'),
safe = require('safetydance'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('System', function () {
const { setup, cleanup, serverUrl, owner, user, waitForTask } = common;
@@ -26,7 +26,7 @@ describe('System', function () {
const response = await superagent.get(`${serverUrl}/api/v1/system/cpus`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.cpus).to.be.ok();
expect(response.body.cpus.every(c => typeof c.model === 'string')).to.be(true);
@@ -38,7 +38,7 @@ describe('System', function () {
const response = await superagent.get(`${serverUrl}/api/v1/system/info`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.info).to.be.ok();
expect(response.body.info.sysVendor).to.be.a('string');
@@ -60,7 +60,7 @@ describe('System', function () {
.query({ access_token: owner.token, fromLine: 0 })
.ok(() => true);
expect(response.statusCode).to.be(400);
expect(response.status).to.be(400);
});
it('logStream - stream logs', function (done) {
@@ -106,14 +106,14 @@ describe('System', function () {
const response = await superagent.get(`${serverUrl}/api/v1/system/memory`)
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('succeeds (admin)', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/system/memory`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.memory).to.eql(os.totalmem());
expect(response.body.swap).to.be.a('number');
});
@@ -122,7 +122,7 @@ describe('System', function () {
const response = await superagent.get(`${serverUrl}/api/v1/system/memory`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.memory).to.eql(os.totalmem());
expect(response.body.swap).to.be.a('number');
});
@@ -135,7 +135,7 @@ describe('System', function () {
const response = await superagent.get(`${serverUrl}/api/v1/system/disk_usage`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body).to.eql({ usage: null });
});
@@ -144,7 +144,7 @@ describe('System', function () {
.query({ access_token: owner.token })
.send({});
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
expect(response.body.taskId).to.be.ok();
await waitForTask(response.body.taskId);
});
@@ -153,7 +153,7 @@ describe('System', function () {
const response = await superagent.get(`${serverUrl}/api/v1/system/disk_usage`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.usage.ts).to.be.a('number');
const filesystems = Object.keys(response.body.usage.filesystems);
@@ -173,7 +173,7 @@ describe('System', function () {
const response = await superagent.get(`${serverUrl}/api/v1/system/block_devices`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.devices).to.be.ok();
expect(response.body.devices.some(d => d.mountpoint === '/')).to.be(true);
+7 -7
View File
@@ -7,7 +7,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent'),
superagent = require('../../superagent.js'),
tasks = require('../../tasks.js');
describe('Tasks API', function () {
@@ -24,7 +24,7 @@ describe('Tasks API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/tasks/${taskId}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.percent).to.be(100);
expect(response.body.args).to.be(undefined);
expect(response.body.active).to.be(false); // finished
@@ -44,7 +44,7 @@ describe('Tasks API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/tasks/${taskId}/logs`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
resolve();
});
});
@@ -59,7 +59,7 @@ describe('Tasks API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
resolve();
});
});
@@ -74,7 +74,7 @@ describe('Tasks API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/tasks/${taskId}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.percent).to.be(100);
expect(response.body.active).to.be(false); // finished
expect(response.body.success).to.be(false);
@@ -87,7 +87,7 @@ describe('Tasks API', function () {
const response = await superagent.post(`${serverUrl}/api/v1/tasks/${taskId}/stop`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
}, 100);
});
});
@@ -100,7 +100,7 @@ describe('Tasks API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/tasks?type=${tasks._TASK_IDENTITY}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.tasks.length >= 1).to.be(true);
expect(response.body.tasks[0].id).to.be(taskId);
expect(response.body.tasks[0].percent).to.be(100);
+7 -7
View File
@@ -7,7 +7,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('Tokens API', function () {
const { setup, cleanup, serverUrl, owner } = common;
@@ -23,7 +23,7 @@ describe('Tokens API', function () {
.query({ access_token: owner.token })
.send({ name: new Array(128).fill('s').join('') })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('can create token', async function () {
@@ -58,7 +58,7 @@ describe('Tokens API', function () {
it('can list tokens', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/tokens`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.tokens.length).to.be(3); // one is owner token on activation
const tokenIds = response.body.tokens.map(t => t.id);
expect(tokenIds).to.contain(token.id);
@@ -68,14 +68,14 @@ describe('Tokens API', function () {
it('can get token', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/tokens/${token.id}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.id).to.be(token.id);
});
it('can delete token', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/tokens/${token.id}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
});
@@ -114,14 +114,14 @@ describe('Tokens API', function () {
.send(DOMAIN_0)
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('cannot get non-existent token', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/tokens/foobar`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
});
});
+8 -8
View File
@@ -8,7 +8,7 @@
const common = require('./common.js'),
constants = require('../../constants.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('Updater API', function () {
const { setup, cleanup, serverUrl, owner } = common;
@@ -20,7 +20,7 @@ describe('Updater API', function () {
it('can get app auto update pattern (default)', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/updater/autoupdate_pattern`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.pattern).to.be.ok();
});
@@ -28,20 +28,20 @@ describe('Updater API', function () {
const response = await superagent.post(`${serverUrl}/api/v1/updater/autoupdate_pattern`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('can set autoupdate_pattern', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/updater/autoupdate_pattern`)
.query({ access_token: owner.token })
.send({ pattern: '00 30 11 * * 1-5' });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
it('can get auto update pattern', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/updater/autoupdate_pattern`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.pattern).to.be('00 30 11 * * 1-5');
});
@@ -49,13 +49,13 @@ describe('Updater API', function () {
const response = await superagent.post(`${serverUrl}/api/v1/updater/autoupdate_pattern`)
.query({ access_token: owner.token })
.send({ pattern: constants.AUTOUPDATE_PATTERN_NEVER });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
});
it('can get auto update pattern', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/updater/autoupdate_pattern`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.pattern).to.be(constants.AUTOUPDATE_PATTERN_NEVER);
});
@@ -64,7 +64,7 @@ describe('Updater API', function () {
.query({ access_token: owner.token })
.send({ pattern: '1 3 x 5 6' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
});
});
+9 -9
View File
@@ -8,7 +8,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('User Directory API', function () {
const { setup, cleanup, serverUrl, owner, user } = common;
@@ -22,7 +22,7 @@ describe('User Directory API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.lockUserProfiles).to.be(false);
expect(response.body.mandatory2FA).to.be(false);
});
@@ -33,7 +33,7 @@ describe('User Directory API', function () {
.send({ lockUserProfiles: true })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot set as normal user', async function() {
@@ -42,7 +42,7 @@ describe('User Directory API', function () {
.send({ lockUserProfiles: true, mandatory2FA: true })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('can lock user profile', async function() {
@@ -51,14 +51,14 @@ describe('User Directory API', function () {
.send({ lockUserProfiles: true, mandatory2FA: false })
.ok(() => true);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
const response2 = await superagent.post(`${serverUrl}/api/v1/profile/email`)
.query({ access_token: owner.token })
.send({ email: 'newemail@example.Com', password: owner.password })
.ok(() => true);
expect(response2.statusCode).to.equal(403); // profile is locked
expect(response2.status).to.equal(403); // profile is locked
});
it('can set mandatory 2fa', async function() {
@@ -67,20 +67,20 @@ describe('User Directory API', function () {
.send({ lockUserProfiles: true, mandatory2FA: true })
.ok(() => true);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
// token gets revoked!
const response2 = await superagent.get(`${serverUrl}/api/v1/profile`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response2.statusCode).to.equal(200); // token is not gone, since it is persisted
expect(response2.status).to.equal(200); // token is not gone, since it is persisted
const response3 = await superagent.get(`${serverUrl}/api/v1/profile`)
.query({ access_token: user.token })
.ok(() => true);
expect(response3.statusCode).to.equal(401); // token is gone
expect(response3.status).to.equal(401); // token is gone
});
});
});
+65 -65
View File
@@ -7,7 +7,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
superagent = require('superagent'),
superagent = require('../../superagent.js'),
users = require('../../users.js');
describe('Users API', function () {
@@ -50,14 +50,14 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('can get userInfo with token', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/users/${user.id}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.username).to.equal(user.username.toLowerCase());
expect(response.body.email).to.equal(user.email.toLowerCase());
expect(response.body.groupIds).to.eql([]);
@@ -69,7 +69,7 @@ describe('Users API', function () {
.query({ access_token: user.token })
.ok(() => true);
expect(reponse.statusCode).to.equal(403);
expect(reponse.status).to.equal(403);
});
});
@@ -80,7 +80,7 @@ describe('Users API', function () {
.send({ username: user2.username })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot create user with non email fallbackEmail', async function () {
@@ -89,7 +89,7 @@ describe('Users API', function () {
.send({ username: user2.username, email: user2.email, fallbackEmail: 'notanemail' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('create second user succeeds', async function () {
@@ -97,7 +97,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ username: user2.username, email: user2.email });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
user2.id = response.body.id;
});
@@ -106,7 +106,7 @@ describe('Users API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/users/${user2.id}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.username).to.equal(user2.username.toLowerCase());
expect(response.body.email).to.equal(user2.email.toLowerCase());
expect(response.body.groupIds).to.eql([]);
@@ -117,7 +117,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ email: unnamedUser.email });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
unnamedUser.id = response.body.id;
});
@@ -127,7 +127,7 @@ describe('Users API', function () {
.send({ username: 'someusername' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('create user reserved name fails', async function () {
@@ -136,7 +136,7 @@ describe('Users API', function () {
.send({ username: 'no-reply', email: 'reserved@cloudron.local' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('create user with short name succeeds', async function () {
@@ -144,7 +144,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ username: 'n', email: 'singleletter@cloudron.local' });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
});
it('create user with same username should fail', async function () {
@@ -153,7 +153,7 @@ describe('Users API', function () {
.send({ username: user2.username, email: user2.email })
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
it('cannot create user with bad password', async function () {
@@ -162,7 +162,7 @@ describe('Users API', function () {
.send({ username: 'badpassworduser', email: 'badpass@cloudron.local', password:'tooweak' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('can create user with a password', async function () {
@@ -170,7 +170,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ username: userWithPassword.username, email: userWithPassword.email, password: userWithPassword.password });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
userWithPassword.id = response.body.id;
});
@@ -185,7 +185,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('creation succeeds', async function () {
@@ -193,7 +193,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.inviteLink).to.be.a('string');
});
@@ -204,7 +204,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ email: user.email });
expect(response.statusCode).to.equal(202);
expect(response.status).to.equal(202);
await common.checkMails(1);
});
});
@@ -215,14 +215,14 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ role: users.ROLE_ADMIN });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('did set second user as admin', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/users/${user.id}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.role).to.be(users.ROLE_ADMIN);
});
@@ -232,7 +232,7 @@ describe('Users API', function () {
.send({ role: users.ROLE_ADMIN })
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
it('make self as normal user fails', async function () {
@@ -241,7 +241,7 @@ describe('Users API', function () {
.send({ role: users.ROLE_USER })
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
it('remove second user as admin succeeds', async function () {
@@ -249,7 +249,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ role: users.ROLE_USER });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('normal user cannot change role of admin', async function () {
@@ -258,7 +258,7 @@ describe('Users API', function () {
.send({ role: users.ROLE_USER })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
});
@@ -267,7 +267,7 @@ describe('Users API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/users`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.users).to.be.an('array');
response.body.users.forEach(function (user) {
@@ -282,14 +282,14 @@ describe('Users API', function () {
.query({ access_token: user.token })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('list users succeeds for admin', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/users`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.users).to.be.an('array');
expect(response.body.users.length).to.be.greaterThan(3);
@@ -311,7 +311,7 @@ describe('Users API', function () {
.send({ email: 'newemail@cloudron.local' })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('change email fails due to invalid email', async function () {
@@ -320,7 +320,7 @@ describe('Users API', function () {
.send({ email: 'newemail@cloudron' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('change fallbackEmail fails due to invalid email', async function () {
@@ -329,7 +329,7 @@ describe('Users API', function () {
.send({ fallbackEmail: 'newemail@cloudron' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('change user succeeds without email nor displayName', async function () {
@@ -337,7 +337,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({});
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('change email succeeds', async function () {
@@ -346,12 +346,12 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ email: user2.email });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
const response2 = await superagent.get(`${serverUrl}/api/v1/users/${user2.id}`)
.query({ access_token: owner.token });
expect(response2.statusCode).to.equal(200);
expect(response2.status).to.equal(200);
expect(response2.body.username).to.equal(user2.username.toLowerCase());
expect(response2.body.email).to.equal(user2.email.toLowerCase());
expect(response2.body.displayName).to.equal('');
@@ -363,7 +363,7 @@ describe('Users API', function () {
.send({ email: owner.email })
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
it('can change display name', async function () {
@@ -373,12 +373,12 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ displayName: displayName });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
const response2 = await superagent.get(`${serverUrl}/api/v1/users/${user2.id}`)
.query({ access_token: owner.token });
expect(response2.statusCode).to.equal(200);
expect(response2.status).to.equal(200);
expect(response2.body.displayName).to.equal(displayName);
});
});
@@ -389,7 +389,7 @@ describe('Users API', function () {
.send({ password: 'youdontsay' })
.ok(() => true);
expect(response.statusCode).to.equal(401);
expect(response.status).to.equal(401);
});
it('change password fails due to small password', async function () {
@@ -398,7 +398,7 @@ describe('Users API', function () {
.send({ password: 'small' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('change password succeeds', async function () {
@@ -406,7 +406,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ password: 'bigenough' });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('did change the user password', async function () {
@@ -420,12 +420,12 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ active: false });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
const response2 = await superagent.get(`${serverUrl}/api/v1/users/${user.id}`)
.query({ access_token: owner.token });
expect(response2.statusCode).to.equal(200);
expect(response2.status).to.equal(200);
expect(response2.body.active).to.equal(false);
});
@@ -434,12 +434,12 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ active: true });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
const response2 = await superagent.get(`${serverUrl}/api/v1/users/${user.id}`)
.query({ access_token: owner.token });
expect(response2.statusCode).to.equal(200);
expect(response2.status).to.equal(200);
expect(response2.body.active).to.equal(true);
});
});
@@ -450,14 +450,14 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ role: users.ROLE_USER_MANAGER });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('can list users as usermanager', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/users`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.users).to.be.an(Array);
expect(response.body.users.length).to.be.greaterThan(3);
});
@@ -468,7 +468,7 @@ describe('Users API', function () {
.send({ password: 'bigenough' })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('can set password of another', async function () {
@@ -476,7 +476,7 @@ describe('Users API', function () {
.query({ access_token: user.token })
.send({ password: 'bigenough' });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('cannot change admin bit of another', async function () {
@@ -485,7 +485,7 @@ describe('Users API', function () {
.send({ role: users.ROLE_ADMIN })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('cannot change admin bit of self', async function () {
@@ -494,7 +494,7 @@ describe('Users API', function () {
.send({ role: users.ROLE_ADMIN })
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
it('cannot remove admin', async function () {
@@ -502,7 +502,7 @@ describe('Users API', function () {
.query({ access_token: user.token })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('can create user as user manager', async function () {
@@ -510,7 +510,7 @@ describe('Users API', function () {
.query({ access_token: user.token })
.send({ username: user3.username, email: user3.email });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
user3.id = response.body.id;
});
@@ -519,7 +519,7 @@ describe('Users API', function () {
const response = await superagent.del(`${serverUrl}/api/v1/users/${user3.id}`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('add mailbox fails', async function () {
@@ -528,7 +528,7 @@ describe('Users API', function () {
.query({ access_token: user.token })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
});
@@ -538,14 +538,14 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.send({ role: users.ROLE_MAIL_MANAGER });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('can list users as mail manager', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/users`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.users).to.be.an(Array);
expect(response.body.users.length).to.be.greaterThan(3);
});
@@ -556,7 +556,7 @@ describe('Users API', function () {
.send({ role: users.ROLE_ADMIN })
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
it('cannot remove admin', async function () {
@@ -564,7 +564,7 @@ describe('Users API', function () {
.query({ access_token: user.token })
.ok(() => true);
expect(response.statusCode).to.equal(403);
expect(response.status).to.equal(403);
});
it('can create user as mail manager', async function () {
@@ -572,7 +572,7 @@ describe('Users API', function () {
.query({ access_token: user.token })
.send({ username: user3.username, email: user3.email });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
user3.id = response.body.id;
});
@@ -581,7 +581,7 @@ describe('Users API', function () {
const response = await superagent.del(`${serverUrl}/api/v1/users/${user3.id}`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('add mailbox succeeds as mail manager', async function () {
@@ -589,14 +589,14 @@ describe('Users API', function () {
.send({ name: 'support', ownerId: owner.id, ownerType: 'user', active: true, storageQuota: 0, messagesQuota: 0 })
.query({ access_token: user.token });
expect(response.statusCode).to.equal(201);
expect(response.status).to.equal(201);
});
it('list mailbox succeeds as mail manager', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}/mailboxes`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.mailboxes.length).to.be(1);
expect(response.body.mailboxes[0].name).to.be('support');
});
@@ -608,7 +608,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('user cannot removes himself', async function () {
@@ -616,7 +616,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
it('admin removes normal user', async function () {
@@ -624,7 +624,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
it('admin removes himself should not be allowed', async function () {
@@ -632,7 +632,7 @@ describe('Users API', function () {
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(409);
expect(response.status).to.equal(409);
});
});
});
+8 -8
View File
@@ -8,7 +8,7 @@
const common = require('./common.js'),
expect = require('expect.js'),
safe = require('safetydance'),
superagent = require('superagent');
superagent = require('../../superagent.js');
describe('Volumes API', function () {
const { setup, cleanup, serverUrl, owner } = common;
@@ -22,7 +22,7 @@ describe('Volumes API', function () {
.query({ access_token: owner.token })
.send({ name: 'music#/ ', mountType: 'filesystem', mountOptions: { hostPath: '/media/cloudron-test-music' } })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('cannot create volume with bad path', async function () {
@@ -30,7 +30,7 @@ describe('Volumes API', function () {
.query({ access_token: owner.token })
.send({ name: 'music', mountType: 'filesystem', mountOptions: { hostPath: '/tmp/music' } })
.ok(() => true);
expect(response.statusCode).to.equal(400);
expect(response.status).to.equal(400);
});
it('can create volume', async function () {
@@ -47,7 +47,7 @@ describe('Volumes API', function () {
it('can list volumes', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/volumes`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.volumes.length).to.be(1);
expect(response.body.volumes[0].id).to.be(volumeId);
expect(response.body.volumes[0].hostPath).to.be('/media/cloudron-test-music');
@@ -57,13 +57,13 @@ describe('Volumes API', function () {
const response = await superagent.get(`${serverUrl}/api/v1/volumes/foobar`)
.query({ access_token: owner.token })
.ok(() => true);
expect(response.statusCode).to.equal(404);
expect(response.status).to.equal(404);
});
it('can get volume', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/volumes/${volumeId}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(200);
expect(response.status).to.equal(200);
expect(response.body.id).to.be(volumeId);
expect(response.body.hostPath).to.be('/media/cloudron-test-music');
});
@@ -74,12 +74,12 @@ describe('Volumes API', function () {
.send({ mountOptions: { hostPath: '/media/cloudron-test-music-2' }})
.ok(() => true));
expect(response.statusCode).to.equal(400); // cannot update filesytem
expect(response.status).to.equal(400); // cannot update filesytem
});
it('can delete volume', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/volumes/${volumeId}`)
.query({ access_token: owner.token });
expect(response.statusCode).to.equal(204);
expect(response.status).to.equal(204);
});
});