prettify code
This commit is contained in:
parent
c3ca3aa7fc
commit
69aaaefce3
@ -116,8 +116,10 @@ interface WaitResult {
|
|||||||
* Returns a new object being the current environment
|
* Returns a new object being the current environment
|
||||||
* plus the values given in the parameter.
|
* plus the values given in the parameter.
|
||||||
*/
|
*/
|
||||||
export function extendEnv(extension: {[index: string]: string}): {[index: string]: string | undefined} {
|
export function extendEnv(extension: {
|
||||||
let ret: {[index: string]: string | undefined} = {};
|
[index: string]: string;
|
||||||
|
}): { [index: string]: string | undefined } {
|
||||||
|
let ret: { [index: string]: string | undefined } = {};
|
||||||
for (let v in process.env) {
|
for (let v in process.env) {
|
||||||
ret[v] = process.env[v];
|
ret[v] = process.env[v];
|
||||||
}
|
}
|
||||||
@ -190,7 +192,7 @@ export async function runCommand(
|
|||||||
logName: string,
|
logName: string,
|
||||||
command: string,
|
command: string,
|
||||||
args: string[],
|
args: string[],
|
||||||
env: {[index: string]: string | undefined} = process.env
|
env: { [index: string]: string | undefined } = process.env,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
console.log("runing command", shellescape([command, ...args]));
|
console.log("runing command", shellescape([command, ...args]));
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -198,7 +200,7 @@ export async function runCommand(
|
|||||||
const proc = spawn(command, args, {
|
const proc = spawn(command, args, {
|
||||||
stdio: ["inherit", "pipe", "pipe"],
|
stdio: ["inherit", "pipe", "pipe"],
|
||||||
shell: false,
|
shell: false,
|
||||||
env: env
|
env: env,
|
||||||
});
|
});
|
||||||
proc.stdout.on("data", (x) => {
|
proc.stdout.on("data", (x) => {
|
||||||
if (x instanceof Buffer) {
|
if (x instanceof Buffer) {
|
||||||
@ -340,14 +342,14 @@ export class GlobalTestState {
|
|||||||
command: string,
|
command: string,
|
||||||
args: string[],
|
args: string[],
|
||||||
logName: string,
|
logName: string,
|
||||||
env: {[index: string] : string | undefined} = process.env
|
env: { [index: string]: string | undefined } = process.env,
|
||||||
): ProcessWrapper {
|
): ProcessWrapper {
|
||||||
console.log(
|
console.log(
|
||||||
`spawning process (${logName}): ${shellescape([command, ...args])}`,
|
`spawning process (${logName}): ${shellescape([command, ...args])}`,
|
||||||
);
|
);
|
||||||
const proc = spawn(command, args, {
|
const proc = spawn(command, args, {
|
||||||
stdio: ["inherit", "pipe", "pipe"],
|
stdio: ["inherit", "pipe", "pipe"],
|
||||||
env: env
|
env: env,
|
||||||
});
|
});
|
||||||
console.log(`spawned process (${logName}) with pid ${proc.pid}`);
|
console.log(`spawned process (${logName}) with pid ${proc.pid}`);
|
||||||
proc.on("error", (err) => {
|
proc.on("error", (err) => {
|
||||||
|
@ -24,7 +24,7 @@ import {
|
|||||||
pingProc,
|
pingProc,
|
||||||
ProcessWrapper,
|
ProcessWrapper,
|
||||||
runCommand,
|
runCommand,
|
||||||
extendEnv
|
extendEnv,
|
||||||
} from "./harness";
|
} from "./harness";
|
||||||
|
|
||||||
export interface LibeufinSandboxServiceInterface {
|
export interface LibeufinSandboxServiceInterface {
|
||||||
@ -70,13 +70,11 @@ export class LibeufinSandboxService implements LibeufinSandboxServiceInterface {
|
|||||||
async start(): Promise<void> {
|
async start(): Promise<void> {
|
||||||
this.sandboxProc = this.globalTestState.spawnService(
|
this.sandboxProc = this.globalTestState.spawnService(
|
||||||
"libeufin-sandbox",
|
"libeufin-sandbox",
|
||||||
[
|
["serve", "--port", `${this.sandboxConfig.httpPort}`],
|
||||||
"serve",
|
|
||||||
"--port",
|
|
||||||
`${this.sandboxConfig.httpPort}`
|
|
||||||
],
|
|
||||||
"libeufin-sandbox",
|
"libeufin-sandbox",
|
||||||
extendEnv({LIBEUFIN_SANDBOX_DB_CONNECTION: this.sandboxConfig.databaseJdbcUri})
|
extendEnv({
|
||||||
|
LIBEUFIN_SANDBOX_DB_CONNECTION: this.sandboxConfig.databaseJdbcUri,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,24 +108,19 @@ export class LibeufinNexusService {
|
|||||||
this.globalTestState,
|
this.globalTestState,
|
||||||
"libeufin-nexus-superuser",
|
"libeufin-nexus-superuser",
|
||||||
"libeufin-nexus",
|
"libeufin-nexus",
|
||||||
[
|
["superuser", "admin", "--password", "test"],
|
||||||
"superuser",
|
extendEnv({
|
||||||
"admin",
|
LIBEUFIN_NEXUS_DB_CONNECTION: this.nexusConfig.databaseJdbcUri,
|
||||||
"--password",
|
}),
|
||||||
"test"
|
|
||||||
],
|
|
||||||
extendEnv({LIBEUFIN_NEXUS_DB_CONNECTION: this.nexusConfig.databaseJdbcUri})
|
|
||||||
);
|
);
|
||||||
|
|
||||||
this.nexusProc = this.globalTestState.spawnService(
|
this.nexusProc = this.globalTestState.spawnService(
|
||||||
"libeufin-nexus",
|
"libeufin-nexus",
|
||||||
[
|
["serve", "--port", `${this.nexusConfig.httpPort}`],
|
||||||
"serve",
|
|
||||||
"--port",
|
|
||||||
`${this.nexusConfig.httpPort}`,
|
|
||||||
],
|
|
||||||
"libeufin-nexus",
|
"libeufin-nexus",
|
||||||
extendEnv({LIBEUFIN_NEXUS_DB_CONNECTION: this.nexusConfig.databaseJdbcUri})
|
extendEnv({
|
||||||
|
LIBEUFIN_NEXUS_DB_CONNECTION: this.nexusConfig.databaseJdbcUri,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +277,7 @@ export interface PostNexusPermissionRequest {
|
|||||||
resourceType: string;
|
resourceType: string;
|
||||||
resourceId: string;
|
resourceId: string;
|
||||||
permissionName: string;
|
permissionName: string;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace LibeufinNexusApi {
|
export namespace LibeufinNexusApi {
|
||||||
@ -411,20 +404,13 @@ export namespace LibeufinNexusApi {
|
|||||||
req: CreateNexusUserRequest,
|
req: CreateNexusUserRequest,
|
||||||
) {
|
) {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL(
|
let url = new URL(`/users`, baseUrl);
|
||||||
`/users`,
|
await axios.post(url.href, req, {
|
||||||
baseUrl,
|
auth: {
|
||||||
);
|
username: "admin",
|
||||||
await axios.post(
|
password: "test",
|
||||||
url.href,
|
|
||||||
req,
|
|
||||||
{
|
|
||||||
auth: {
|
|
||||||
username: "admin",
|
|
||||||
password: "test",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function postPermission(
|
export async function postPermission(
|
||||||
@ -432,20 +418,13 @@ export namespace LibeufinNexusApi {
|
|||||||
req: PostNexusPermissionRequest,
|
req: PostNexusPermissionRequest,
|
||||||
) {
|
) {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL(
|
let url = new URL(`/permissions`, baseUrl);
|
||||||
`/permissions`,
|
await axios.post(url.href, req, {
|
||||||
baseUrl,
|
auth: {
|
||||||
);
|
username: "admin",
|
||||||
await axios.post(
|
password: "test",
|
||||||
url.href,
|
|
||||||
req,
|
|
||||||
{
|
|
||||||
auth: {
|
|
||||||
username: "admin",
|
|
||||||
password: "test",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createTwgFacade(
|
export async function createTwgFacade(
|
||||||
|
Loading…
Reference in New Issue
Block a user