Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beforeAll(function(done){
config = Container.get(Configuration);
if (config.loaded) {
startGateway()
.then(done)
.catch(err => {
console.error(err);
fail(err);
});
} else {
config.on("load", () => {
startGateway()
.then(done)
.catch(err => {
console.error(err);
fail(err);
});
});
before(() => {
config = Container.get(Configuration);
gatewayRequest = request.defaults({ baseUrl: `http://localhost:${config.gateway.protocol.http.listenPort}` });
});
before(() => {
config = Container.get(Configuration);
gatewayRequest = request.defaults({baseUrl: `http://localhost:${config.gateway.protocol.http.listenPort}`});
});
before(() => {
config = Container.get(Configuration);
gatewayRequest = request.defaults({baseUrl: `http://localhost:${config.gateway.protocol.http.listenPort}`});
});
before(() => {
config = Container.get(Configuration);
gatewayRequest = request.defaults({ baseUrl: `http://localhost:${config.gateway.protocol.http.listenPort}` });
});
before(() => {
config = Container.get(Configuration);
gatewayRequest = request.defaults({baseUrl: `http://localhost:${config.gateway.protocol.http.listenPort}`});
});
async function startGateway() {
database = Container.get(Database);
gateway = Container.get(Gateway);
await database.redisClient.flushdb();
await gateway.start();
await gateway.startAdmin();
gateway.server.set('env', 'test');
sdk = await SDK.initialize({
defaultHost: getSwaggerHost(config.gateway),
swaggerUrl: getSwaggerUrl(config.gateway),
token: generateSecurityToken(config.gateway)
});
}
before(async () => {
config = Container.get(Configuration);
database = Container.get(Database);
gateway = Container.get(Gateway);
sdk = await SDK.initialize({
defaultHost: getSwaggerHost(config.gateway),
swaggerUrl: getSwaggerUrl(config.gateway),
token: generateSecurityToken(config.gateway)
});
});
return new Promise((resolve, reject) => {
const swaggerUrl = `http://localhost:${config.gateway.admin.protocol.http.listenPort}/${config.gateway.admin.apiDocs.path}/json`;
database = Container.get(Database);
gateway = Container.get(Gateway);
gateway.start()
.then(() => gateway.startAdmin())
.then(() => {
gateway.server.set('env', 'test');
gatewayRequest = request.defaults({baseUrl: `http://localhost:${config.gateway.protocol.http.listenPort}`});
return database.redisClient.flushdb();
})
.then(() => createUser())
.then((user) => SDK.initialize(swaggerUrl, 'config', '123test'))
.then((s) => {
sdk = s;
return installMiddlewares();
})
.then(() => installApis())
.then(resolve)
before(function(){
config = Container.get(Configuration);
if (config.loaded) {
return startGateway();
} else {
return new Promise((resolve, reject) => {
config.on('load', () => {
startGateway()
.then(resolve)
.catch(reject);
});
});
}
});