groups: add app access tests

This commit is contained in:
Girish Ramakrishnan
2025-02-12 14:09:09 +01:00
parent fda0a918f0
commit bd44bb4534
5 changed files with 153 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
'use strict';
const appstore = require('../../appstore.js'),
const apps = require('../../apps.js'),
appstore = require('../../appstore.js'),
debug = require('debug')('box:test/common'),
constants = require('../../constants.js'),
database = require('../../database.js'),
@@ -17,6 +18,34 @@ const appstore = require('../../appstore.js'),
timers = require('timers/promises'),
tokens = require('../../tokens.js');
const manifest = {
'id': 'io.cloudron.test',
'author': 'The Presidents Of the United States Of America',
'title': 'test title',
'description': 'test description',
'tagline': 'test rocks',
'website': 'http://test.cloudron.io',
'contactEmail': 'test@cloudron.io',
'version': '0.1.0',
'manifestVersion': 2,
'dockerImage': 'cloudron/test:25.2.0',
'healthCheckPath': '/',
'httpPort': 7777,
'tcpPorts': {
'ECHO_SERVER_PORT': {
'title': 'Echo Server Port',
'description': 'Echo server',
'containerPort': 7778
}
},
'addons': {
'oauth': { },
'redis': { },
'mysql': { },
'postgresql': { }
}
};
exports = module.exports = {
setup,
setupServer,
@@ -50,6 +79,25 @@ exports = module.exports = {
token: null
},
app: {
id: 'appid',
appStoreId: 'appStoreId',
installationState: apps.ISTATE_PENDING_INSTALL,
runState: 'running',
subdomain: 'app',
domain: 'test.example.com',
fqdn: 'app.test.example.com',
manifest,
containerId: 'someid',
portBindings: {},
accessRestriction: null,
memoryLimit: 0,
mailboxDomain: 'test.example.com',
secondaryDomains: [],
redirectDomains: [],
aliasDomains: []
},
mockApiServerOrigin: 'http://localhost:6060',
dashboardDomain: 'test.example.com',
dashboardFqdn: 'my.test.example.com',
@@ -114,6 +162,9 @@ async function setup() {
const token2 = await tokens.add({ identifier: user.id, clientId: tokens.ID_WEBADMIN, expires: Date.now() + (60 * 60 * 1000), name: 'fromtest' });
user.token = token2.accessToken;
// create app object
await apps.add(exports.app.id, exports.app.appStoreId, exports.app.manifest, exports.app.subdomain, exports.app.domain, exports.app.portBindings, exports.app);
await settings._set(settings.APPSTORE_API_TOKEN_KEY, exports.appstoreToken); // appstore token
debug('Setup complete');