def test_inspect_image_file(capsys): test_filepath = os.path.join(RESOURCE_DIRECTORY, 'test.png') inspect_content.inspect_file( GCLOUD_PROJECT, test_filepath, ['FIRST_NAME', 'EMAIL_ADDRESS', 'PHONE_NUMBER'], include_quote=True) out, _ = capsys.readouterr() assert 'Info type: PHONE_NUMBER' in out
def test_inspect_file_no_results(capsys): test_filepath = os.path.join(RESOURCE_DIRECTORY, 'harmless.txt') inspect_content.inspect_file( GCLOUD_PROJECT, test_filepath, ['FIRST_NAME', 'EMAIL_ADDRESS'], include_quote=True) out, _ = capsys.readouterr() assert 'No findings' in out
def test_inspect_file(capsys): test_filepath = os.path.join(RESOURCE_DIRECTORY, "test.txt") inspect_content.inspect_file( GCLOUD_PROJECT, test_filepath, ["FIRST_NAME", "EMAIL_ADDRESS"], include_quote=True, ) out, _ = capsys.readouterr() assert "Info type: EMAIL_ADDRESS" in out
def test_inspect_file_no_results(capsys): test_filepath = os.path.join(RESOURCE_DIRECTORY, "harmless.txt") inspect_content.inspect_file( GCLOUD_PROJECT, test_filepath, ["FIRST_NAME", "EMAIL_ADDRESS"], include_quote=True, ) out, _ = capsys.readouterr() assert "No findings" in out
def test_inspect_file_with_custom_info_types(capsys): test_filepath = os.path.join(RESOURCE_DIRECTORY, 'test.txt') dictionaries = ['*****@*****.**'] regexes = ['\\(\\d{3}\\) \\d{3}-\\d{4}'] inspect_content.inspect_file(GCLOUD_PROJECT, test_filepath, [], custom_dictionaries=dictionaries, custom_regexes=regexes, include_quote=True) out, _ = capsys.readouterr() assert 'Info type: CUSTOM_DICTIONARY_0' in out assert 'Info type: CUSTOM_REGEX_0' in out
def test_inspect_file_with_custom_info_types(capsys): test_filepath = os.path.join(RESOURCE_DIRECTORY, 'test.txt') dictionaries = ['*****@*****.**'] regexes = ['\\(\\d{3}\\) \\d{3}-\\d{4}'] inspect_content.inspect_file( GCLOUD_PROJECT, test_filepath, [], custom_dictionaries=dictionaries, custom_regexes=regexes, include_quote=True) out, _ = capsys.readouterr() assert 'Info type: CUSTOM_DICTIONARY_0' in out assert 'Info type: CUSTOM_REGEX_0' in out