def test_scan_patch(client, name, input_patch, expected): c = Commit() c._patch = input_patch with my_vcr.use_cassette(name): results = c.scan(client=client, matches_ignore={}, all_policies=True, verbose=False) assert (process_results(results, verbose=True, show_secrets=True) == expected.exit_code) for result in results: if result.scan.policy_breaks: assert len( result.scan.policy_breaks[0].matches) == expected.matches if expected.first_match: assert (result.scan.policy_breaks[0].matches[0].match == expected.first_match) else: assert result.scan.policy_breaks == [] if expected.want: assert result.content == expected.want["content"] assert result.filename == expected.want["filename"] assert result.filemode == expected.want["filemode"]
def test_patch_separation_ignore(): c = Commit() c._patch = PATCH_SEPARATION file_to_ignore = ".env" c.filter_set = [os.path.join(os.getcwd(), file_to_ignore)] files = list(c.get_files()) assert len(files) == 3 assert not (any(entry.filename == file_to_ignore for entry in files))
def test_patch_separation(): c = Commit() c._patch = PATCH_SEPARATION files = list(c.get_files()) assert len(files) == 4 assert c.info.author == "Testificate Jose" assert c.info.email == "*****@*****.**" assert c.info.date == "Fri Oct 18 13:20:00 2012 +0100"
def test_patch_max_size(): c = Commit() c._patch = """ diff --git a/tests/test_scannable.py b/.env new file mode 100644 index 0000000..0000000 --- /dev/null +++ b/.env @@ -0,0 +1,112 @@ CHECK_ENVIRONMENT=true """ c._patch += "a" * MAX_FILE_SIZE files = list(c.get_files()) assert len(files) == 0
def test_patch_separation(): c = Commit() c._patch = PATCH_SEPARATION files = list(c.get_files()) assert len(files) == 4