More test cleanups to support domains api
This commit is contained in:
@@ -10,7 +10,6 @@ var async = require('async'),
|
|||||||
config = require('../../config.js'),
|
config = require('../../config.js'),
|
||||||
database = require('../../database.js'),
|
database = require('../../database.js'),
|
||||||
expect = require('expect.js'),
|
expect = require('expect.js'),
|
||||||
nock = require('nock'),
|
|
||||||
superagent = require('superagent'),
|
superagent = require('superagent'),
|
||||||
server = require('../../server.js'),
|
server = require('../../server.js'),
|
||||||
tokendb = require('../../tokendb.js');
|
tokendb = require('../../tokendb.js');
|
||||||
@@ -23,25 +22,18 @@ var token = null;
|
|||||||
var USER_1_ID = null, token_1;
|
var USER_1_ID = null, token_1;
|
||||||
|
|
||||||
function setup(done) {
|
function setup(done) {
|
||||||
config.setVersion('1.2.3');
|
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
server.start.bind(server),
|
server.start.bind(server),
|
||||||
|
|
||||||
database._clear,
|
database._clear,
|
||||||
|
|
||||||
function createAdmin(callback) {
|
function createAdmin(callback) {
|
||||||
var scope1 = nock(config.apiServerOrigin()).get('/api/v1/boxes/' + config.fqdn() + '/setup/verify?setupToken=somesetuptoken').reply(200, {});
|
|
||||||
var scope2 = nock(config.apiServerOrigin()).post('/api/v1/boxes/' + config.fqdn() + '/setup/done?setupToken=somesetuptoken').reply(201, {});
|
|
||||||
|
|
||||||
superagent.post(SERVER_URL + '/api/v1/cloudron/activate')
|
superagent.post(SERVER_URL + '/api/v1/cloudron/activate')
|
||||||
.query({ setupToken: 'somesetuptoken' })
|
.query({ setupToken: 'somesetuptoken' })
|
||||||
.send({ username: USERNAME, password: PASSWORD, email: EMAIL })
|
.send({ username: USERNAME, password: PASSWORD, email: EMAIL })
|
||||||
.end(function (error, result) {
|
.end(function (error, result) {
|
||||||
expect(result).to.be.ok();
|
expect(result).to.be.ok();
|
||||||
expect(result.statusCode).to.eql(201);
|
expect(result.statusCode).to.eql(201);
|
||||||
expect(scope1.isDone()).to.be.ok();
|
|
||||||
expect(scope2.isDone()).to.be.ok();
|
|
||||||
|
|
||||||
// stash token for further use
|
// stash token for further use
|
||||||
token = result.body.token;
|
token = result.body.token;
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ var groupObject;
|
|||||||
|
|
||||||
var server;
|
var server;
|
||||||
function setup(done) {
|
function setup(done) {
|
||||||
|
config.set('provider', 'caas');
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
server.start.bind(server),
|
server.start.bind(server),
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ describe('OAuth2', function () {
|
|||||||
appStoreId: '',
|
appStoreId: '',
|
||||||
manifest: { version: '0.1.0', addons: { } },
|
manifest: { version: '0.1.0', addons: { } },
|
||||||
location: 'test',
|
location: 'test',
|
||||||
|
domain: 'example.com',
|
||||||
portBindings: {},
|
portBindings: {},
|
||||||
accessRestriction: null,
|
accessRestriction: null,
|
||||||
memoryLimit: 0,
|
memoryLimit: 0,
|
||||||
@@ -165,6 +166,7 @@ describe('OAuth2', function () {
|
|||||||
appStoreId: '',
|
appStoreId: '',
|
||||||
manifest: { version: '0.1.0', addons: { } },
|
manifest: { version: '0.1.0', addons: { } },
|
||||||
location: 'test1',
|
location: 'test1',
|
||||||
|
domain: 'example.com',
|
||||||
portBindings: {},
|
portBindings: {},
|
||||||
accessRestriction: { users: [ 'foobar' ] },
|
accessRestriction: { users: [ 'foobar' ] },
|
||||||
memoryLimit: 0,
|
memoryLimit: 0,
|
||||||
@@ -176,6 +178,7 @@ describe('OAuth2', function () {
|
|||||||
appStoreId: '',
|
appStoreId: '',
|
||||||
manifest: { version: '0.1.0', addons: { } },
|
manifest: { version: '0.1.0', addons: { } },
|
||||||
location: 'test2',
|
location: 'test2',
|
||||||
|
domain: 'example.com',
|
||||||
portBindings: {},
|
portBindings: {},
|
||||||
accessRestriction: { users: [ USER_0.id ] },
|
accessRestriction: { users: [ USER_0.id ] },
|
||||||
memoryLimit: 0,
|
memoryLimit: 0,
|
||||||
@@ -187,6 +190,7 @@ describe('OAuth2', function () {
|
|||||||
appStoreId: '',
|
appStoreId: '',
|
||||||
manifest: { version: '0.1.0', addons: { } },
|
manifest: { version: '0.1.0', addons: { } },
|
||||||
location: 'test3',
|
location: 'test3',
|
||||||
|
domain: 'example.com',
|
||||||
portBindings: {},
|
portBindings: {},
|
||||||
accessRestriction: { groups: [ 'someothergroup', 'admin', 'anothergroup' ] },
|
accessRestriction: { groups: [ 'someothergroup', 'admin', 'anothergroup' ] },
|
||||||
memoryLimit: 0,
|
memoryLimit: 0,
|
||||||
@@ -302,10 +306,10 @@ describe('OAuth2', function () {
|
|||||||
clientdb.add.bind(null, CLIENT_6.id, CLIENT_6.appId, CLIENT_6.type, CLIENT_6.clientSecret, CLIENT_6.redirectURI, CLIENT_6.scope),
|
clientdb.add.bind(null, CLIENT_6.id, CLIENT_6.appId, CLIENT_6.type, CLIENT_6.clientSecret, CLIENT_6.redirectURI, CLIENT_6.scope),
|
||||||
clientdb.add.bind(null, CLIENT_7.id, CLIENT_7.appId, CLIENT_7.type, CLIENT_7.clientSecret, CLIENT_7.redirectURI, CLIENT_7.scope),
|
clientdb.add.bind(null, CLIENT_7.id, CLIENT_7.appId, CLIENT_7.type, CLIENT_7.clientSecret, CLIENT_7.redirectURI, CLIENT_7.scope),
|
||||||
clientdb.add.bind(null, CLIENT_9.id, CLIENT_9.appId, CLIENT_9.type, CLIENT_9.clientSecret, CLIENT_9.redirectURI, CLIENT_9.scope),
|
clientdb.add.bind(null, CLIENT_9.id, CLIENT_9.appId, CLIENT_9.type, CLIENT_9.clientSecret, CLIENT_9.redirectURI, CLIENT_9.scope),
|
||||||
appdb.add.bind(null, APP_0.id, APP_0.appStoreId, APP_0.manifest, APP_0.location, APP_0.portBindings, APP_0),
|
appdb.add.bind(null, APP_0.id, APP_0.appStoreId, APP_0.manifest, APP_0.location, APP_0.domain, APP_0.portBindings, APP_0),
|
||||||
appdb.add.bind(null, APP_1.id, APP_1.appStoreId, APP_1.manifest, APP_1.location, APP_1.portBindings, APP_1),
|
appdb.add.bind(null, APP_1.id, APP_1.appStoreId, APP_1.manifest, APP_1.location, APP_1.domain, APP_1.portBindings, APP_1),
|
||||||
appdb.add.bind(null, APP_2.id, APP_2.appStoreId, APP_2.manifest, APP_2.location, APP_2.portBindings, APP_2),
|
appdb.add.bind(null, APP_2.id, APP_2.appStoreId, APP_2.manifest, APP_2.location, APP_2.domain, APP_2.portBindings, APP_2),
|
||||||
appdb.add.bind(null, APP_3.id, APP_3.appStoreId, APP_3.manifest, APP_3.location, APP_3.portBindings, APP_3),
|
appdb.add.bind(null, APP_3.id, APP_3.appStoreId, APP_3.manifest, APP_3.location, APP_3.domain, APP_3.portBindings, APP_3),
|
||||||
function (callback) {
|
function (callback) {
|
||||||
user.create(USER_0.username, USER_0.password, USER_0.email, USER_0.displayName, null /* source */, function (error, userObject) {
|
user.create(USER_0.username, USER_0.password, USER_0.email, USER_0.displayName, null /* source */, function (error, userObject) {
|
||||||
expect(error).to.not.be.ok();
|
expect(error).to.not.be.ok();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ var token = null;
|
|||||||
|
|
||||||
var server;
|
var server;
|
||||||
function setup(done) {
|
function setup(done) {
|
||||||
|
config.set('provider', 'caas');
|
||||||
config.setVersion('1.2.3');
|
config.setVersion('1.2.3');
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
@@ -67,10 +68,11 @@ describe('REST API', function () {
|
|||||||
superagent.post(SERVER_URL + '/api/v1/users')
|
superagent.post(SERVER_URL + '/api/v1/users')
|
||||||
.query({ access_token: token })
|
.query({ access_token: token })
|
||||||
.set('content-type', 'application/json')
|
.set('content-type', 'application/json')
|
||||||
.send("some invalid non-strict json")
|
.send('some invalid non-strict json')
|
||||||
.end(function (error, result) {
|
.end(function (error, result) {
|
||||||
expect(result.statusCode).to.equal(400);
|
expect(result.statusCode).to.equal(400);
|
||||||
expect(result.body.message).to.be('Failed to parse body');
|
expect(result.body.message).to.be('Bad JSON');
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -79,9 +81,10 @@ describe('REST API', function () {
|
|||||||
superagent.post(SERVER_URL + '/api/v1/users')
|
superagent.post(SERVER_URL + '/api/v1/users')
|
||||||
.query({ access_token: token })
|
.query({ access_token: token })
|
||||||
.set('content-type', 'application/x-www-form-urlencoded')
|
.set('content-type', 'application/x-www-form-urlencoded')
|
||||||
.send("some string")
|
.send('some string')
|
||||||
.end(function (error, result) {
|
.end(function (error, result) {
|
||||||
expect(result.statusCode).to.equal(400);
|
expect(result.statusCode).to.equal(400);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ function setup(done) {
|
|||||||
|
|
||||||
function addApp(callback) {
|
function addApp(callback) {
|
||||||
var manifest = { version: '0.0.1', manifestVersion: 1, dockerImage: 'foo', healthCheckPath: '/', httpPort: 3, title: 'ok', addons: { } };
|
var manifest = { version: '0.0.1', manifestVersion: 1, dockerImage: 'foo', healthCheckPath: '/', httpPort: 3, title: 'ok', addons: { } };
|
||||||
appdb.add('appid', 'appStoreId', manifest, 'location', [ ] /* portBindings */, { }, callback);
|
appdb.add('appid', 'appStoreId', manifest, 'location', 'example.com', [ ] /* portBindings */, { }, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
function createSettings(callback) {
|
function createSettings(callback) {
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ describe('dns provider', function () {
|
|||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
database.initialize,
|
database.initialize,
|
||||||
settings.initialize
|
settings.initialize,
|
||||||
|
database._clear
|
||||||
], done);
|
], done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user