def test_ignored_lines(self, content_to_format):
        file_content = content_to_format.format(secret=self.secret)
        f = create_file_object_from_string(file_content)

        results = self.logic.analyze(f, 'does_not_matter')

        assert len(results) == 0
Exemplo n.º 2
0
    def test_analyze(self, file_content):
        logic = PrivateKeyDetector()

        f = create_file_object_from_string(file_content)
        output = logic.analyze(f, 'mock_filename')
        assert len(output) == 1
        for potential_secret in output:
            assert 'mock_filename' == potential_secret.filename
Exemplo n.º 3
0
    def test_analyze(self):
        logic = PrivateKeyDetector()

        file_content = ('-----BEGIN RSA PRIVATE KEY-----'
                        'super secret private key here'
                        '-----END RSA PRIVATE KEY-----')

        f = create_file_object_from_string(file_content)
        assert 'mock_filename' in logic.analyze(f, 'mock_filename')
    def test_analyze_multiple_strings_same_line(self, content_to_format, expected_results):
        content = content_to_format.format(
            non_secret=self.non_secret,
            secret=self.secret,
        )
        f = create_file_object_from_string(content)

        results = self.logic.analyze(f, 'does_not_matter')

        assert len(results) == expected_results
    def test_pattern(self, content_to_format, should_be_caught):
        content = content_to_format.format(
            non_secret=self.non_secret,
            secret=self.secret,
        )

        f = create_file_object_from_string(content)

        results = self.logic.analyze(f, 'does_not_matter')

        assert len(results) == bool(should_be_caught)
Exemplo n.º 6
0
    def test_analyze(self):
        logic = PrivateKeyDetector()

        file_content = ('-----BEGIN RSA PRIVATE KEY-----'
                        'super secret private key here'
                        '-----END RSA PRIVATE KEY-----')

        f = create_file_object_from_string(file_content)
        output = logic.analyze(f, 'mock_filename')
        assert len(output) == 1
        for potential_secret in output:
            assert 'mock_filename' == potential_secret.filename