def test_ignore_last_found_preserve_previous_config(client): """ GIVEN a cache containing new secrets AND a config not empty WHEN I run ignore command THEN existing config option are not wiped out """ config = Config() previous_secrets = [ { "name": "", "match": "previous_secret" }, { "name": "", "match": "other_previous_secret" }, ] previous_paths = {"some_path", "some_other_path"} config.matches_ignore = previous_secrets.copy() config.paths_ignore = previous_paths config.exit_zero = True cache = Cache() cache.last_found_secrets = FOUND_SECRETS ignore_last_found(config, cache) matches_ignore = sorted(config.matches_ignore, key=compare_matches_ignore) found_secrets = sorted(FOUND_SECRETS + previous_secrets, key=compare_matches_ignore) assert matches_ignore == found_secrets assert config.paths_ignore == previous_paths assert config.exit_zero is True
def test_ignore_last_found_preserve_previous_config(client): """ GIVEN a cache containing new secrets AND a config not empty WHEN I run ignore command THEN existing config option are not wiped out """ config = Config() previous_secrets = {"previous_secret", "other_previous_secret"} previous_paths = {"some_path", "some_other_path"} config.matches_ignore = previous_secrets config.paths_ignore = previous_paths config.exit_zero = True cache = Cache() cache.last_found_secrets = FOUND_SECRETS ignore_last_found(config, cache) assert config.matches_ignore == FOUND_SECRETS.union(previous_secrets) assert config.paths_ignore == previous_paths assert config.exit_zero is True