Skip to content

Commit f75ce45

Browse files
committed
support for setup of sys env on machine
1 parent a370667 commit f75ce45

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

commands/utils/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
DEFAULT_TEST_PATH: ".",
1010
LAMBDA_CONFIG: "./lambdatest-config.json",
1111
SUPPORTED_CYPRESS_VERSIONS: ["5", "6"],
12+
WHITELISTED_ENV_VARS: ["CI_BUILD_ID"],
1213
BUILD_END_STATES:
1314
"&status=running,queued,created,initiated,pqueued,error,lambda error,failed",
1415
BUILD_ERROR_STATES: "&status=error,lambda error,failed",

commands/utils/set_args.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,16 +325,37 @@ function sync_args_from_cmd(args) {
325325

326326
//Set the env variables
327327
let sys_env_vars = undefined;
328+
let sys_env = undefined;
328329
if ("sys-envs" in args) {
329-
sys_env_vars = args["sys-envs"].split(",");
330+
sys_env_vars = args["sys-envs"];
331+
sys_env_vars = sys_env_vars.trim();
332+
sys_env_vars = sys_env_vars.split(",");
330333
} else if (lt_config["run_settings"]["sys-envs"]) {
331-
sys_env_vars = lt_config["run_settings"]["sys-envs"].split(",");
334+
335+
sys_env_vars = lt_config["run_settings"]["sys-envs"];
336+
sys_env_vars = sys_env_vars.trim();
337+
sys_env_vars = sys_env_vars.split(";");
332338
}
333339

340+
341+
334342
if (sys_env_vars) {
335343
let envs = {};
336-
for (env in sys_env_vars) {
337-
envs[sys_env_vars[env].split("=")[0]] = sys_env_vars[env].split("=")[1];
344+
console.log(sys_env_vars);
345+
let envItem;
346+
let envKey;
347+
348+
for (index in sys_env_vars) {
349+
envItem = sys_env_vars[index];
350+
if (envItem){
351+
// TODO: trim spaces from the key and value
352+
envKey = envItem.split("=")[0];
353+
if (envKey && ! constants.WHITELISTED_ENV_VARS.includes(envKey)){
354+
reject(`usage of unwanted environment variable detected. Allowed variables are - ${constants.WHITELISTED_ENV_VARS}`);
355+
}
356+
envs[envKey] = envItem.split("=")[1];
357+
}
358+
338359
}
339360
lt_config["run_settings"]["sys-envs"] = envs;
340361
}

0 commit comments

Comments
 (0)