diff --git a/test-runner/.actions.json b/test-runner/.actions.json index 3b459a412..cbc2e7618 100644 --- a/test-runner/.actions.json +++ b/test-runner/.actions.json @@ -1,5 +1,4 @@ { "TEST": ["3", "4", "5"], - "mask": [true], "experimental": [true] } diff --git a/test-runner/test_runner.py b/test-runner/test_runner.py index a023b99eb..fd4e14743 100644 --- a/test-runner/test_runner.py +++ b/test-runner/test_runner.py @@ -64,13 +64,6 @@ def parse_args(args: list): parser.add_argument( "-l", "--logs", dest="logs_path", default="output", help="-l /path/to/logs" ) - parser.add_argument( - "-m", - "--mask", - dest="mask", - action="store_true", - help="Enable mask parameter for sensitive information in logs", - ) return parser.parse_args(args) @@ -112,13 +105,14 @@ def get_test_list(args: dict, tests_yaml: List[dict]): List[dict]: list of expanded tests """ tests_list = {} + disable_masking = False for test in tests_yaml: if re.search(r"\$\{([A-Za-z0-9_]*)\:\-(.*?)\}", test): if args.actions_path: with open(args.actions_path, "r", encoding="utf-8") as actions_file: for key, dval in json.load(actions_file).items(): - if key == "mask": - [args.mask] = dval + if key == "mask" and dval == [False]: + disable_masking = True if isinstance(dval, list) and key != "experimental": for _, val in enumerate(dval): os.environ[key] = str(val) @@ -141,7 +135,7 @@ def get_test_list(args: dict, tests_yaml: List[dict]): logging.error("Command not found for %s", test) sys.exit(1) - return tests_list + return tests_list, disable_masking if __name__ == "__main__": @@ -173,7 +167,7 @@ def get_test_list(args: dict, tests_yaml: List[dict]): except YAMLError as yaml_exc: logging.error(yaml_exc) sys.exit(1) - tests_list = get_test_list(args, tests_json) + tests_list, disable_masking = get_test_list(args, tests_json) logging.debug("Creating Test Objects from: %s", tests_list) # For each test, create a Test Object with the test name is the key of the test in yaml tests = [Test(name=test, **tests_list[test]) for test in tests_list] @@ -181,7 +175,7 @@ def get_test_list(args: dict, tests_yaml: List[dict]): summary = [] ERROR = False for idx, test in enumerate(tests): - if not args.mask: + if disable_masking: test.mask = [] # Set Context to test-runner.log set_log_filename(logging.getLogger(), "test-runner", args.logs_path) diff --git a/test-runner/tests/utest.py b/test-runner/tests/utest.py index cf1a6e916..5b02911a5 100644 --- a/test-runner/tests/utest.py +++ b/test-runner/tests/utest.py @@ -145,8 +145,9 @@ def test_get_test_list(test_args_input, test_json_input): "test7": {"cmd": "echo 'world: hello'", "mask": ["world"]}, } - test_fn = get_test_list(test_args_input, test_json_input) + test_fn, disable_masking = get_test_list(test_args_input, test_json_input) assert test_fn == test_val + assert disable_masking is False def test_masking(test_class_input):