Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests failing on openSUSE Tumbleweed #875

Open
1 of 2 tasks
kastl-ars opened this issue Aug 9, 2024 · 0 comments
Open
1 of 2 tasks

Tests failing on openSUSE Tumbleweed #875

kastl-ars opened this issue Aug 9, 2024 · 0 comments

Comments

@kastl-ars
Copy link

  • I'm submitting a ...

    • bug report
    • feature request
  • What is the current behavior?

There are several tests failing when packaging detect-secrets for openSUSE. This might be due to the build environment that does not have network connectivity. But before ignoring those tests, I would like to get your opinion.

[   38s] =================================== FAILURES ===================================
[   38s] ___________________ TestAWSKeyDetector.test_verify_no_secret ___________________
[   38s] 
[   38s] self = <aws_key_test.TestAWSKeyDetector object at 0x7f61b0ab8be0>
[   38s] 
[   38s]     def test_verify_no_secret(self):
[   38s]         logic = AWSKeyDetector()
[   38s]     
[   38s]         assert logic.verify(
[   38s]             self.example_key,
[   38s]             get_code_snippet([], 1),
[   38s] >       ) == VerifiedResult.UNVERIFIED
[   38s] E       AttributeError: 'TestAWSKeyDetector' object has no attribute 'example_key'
[   38s] 
[   38s] tests/plugins/aws_key_test.py:77: AttributeError
[   38s] _________________ TestAWSKeyDetector.test_verify_valid_secret __________________
[   38s] 
[   38s] self = <aws_key_test.TestAWSKeyDetector object at 0x7f61b0ab9330>
[   38s] 
[   38s]     def test_verify_valid_secret(self):
[   38s]         with mock.patch(
[   38s]             'detect_secrets.plugins.aws.verify_aws_secret_access_key',
[   38s]             return_value=True,
[   38s]         ):
[   38s]             assert AWSKeyDetector().verify(
[   38s]                 self.example_key,
[   38s]                 get_code_snippet(['={}'.format(EXAMPLE_SECRET)], 1),
[   38s] >           ) == VerifiedResult.VERIFIED_TRUE
[   38s] E           AttributeError: 'TestAWSKeyDetector' object has no attribute 'example_key'
[   38s] 
[   38s] tests/plugins/aws_key_test.py:92: AttributeError
[   38s] ________________ TestAWSKeyDetector.test_verify_invalid_secret _________________
[   38s] 
[   38s] self = <aws_key_test.TestAWSKeyDetector object at 0x7f61b0918cd0>
[   38s] 
[   38s]     def test_verify_invalid_secret(self):
[   38s]         with mock.patch(
[   38s]             'detect_secrets.plugins.aws.verify_aws_secret_access_key',
[   38s]             return_value=False,
[   38s]         ):
[   38s]             assert AWSKeyDetector().verify(
[   38s]                 self.example_key,
[   38s]                 get_code_snippet(['={}'.format(EXAMPLE_SECRET)], 1),
[   38s] >           ) == VerifiedResult.VERIFIED_FALSE
[   38s] E           AttributeError: 'TestAWSKeyDetector' object has no attribute 'example_key'
[   38s] 
[   38s] tests/plugins/aws_key_test.py:102: AttributeError
[   38s] _______ TestAWSKeyDetector.test_verify_keep_trying_until_found_something _______
[   38s] 
[   38s] self = <aws_key_test.TestAWSKeyDetector object at 0x7f61b091a260>
[   38s] 
[   38s]     def test_verify_keep_trying_until_found_something(self):
[   38s]         data = {'count': 0}
[   38s]     
[   38s]         def counter(*args, **kwargs):
[   38s]             output = data['count']
[   38s]             data['count'] += 1
[   38s]     
[   38s]             return bool(output)
[   38s]     
[   38s]         with mock.patch(
[   38s]             'detect_secrets.plugins.aws.verify_aws_secret_access_key',
[   38s]             counter,
[   38s]         ):
[   38s]             assert AWSKeyDetector().verify(
[   38s]                 self.example_key,
[   38s]                 get_code_snippet(
[   38s]                     [
[   38s]                         'false_secret = {0}'.format('TEST' * 10),
[   38s]                         'real_secret = {0}'.format(EXAMPLE_SECRET),
[   38s]                     ],
[   38s]                     1,
[   38s]                 ),
[   38s] >           ) == VerifiedResult.VERIFIED_TRUE
[   38s] E           AttributeError: 'TestAWSKeyDetector' object has no attribute 'example_key'
[   38s] 
[   38s] tests/plugins/aws_key_test.py:126: AttributeError
[   38s] _ TestAnalyzeLine.test_potential_secret_constructed_correctly[VerifiedResult.UNVERIFIED-False] _
[   38s] 
[   38s] self = <base_test.TestAnalyzeLine object at 0x7f61b09184c0>
[   38s] verified_result = <VerifiedResult.UNVERIFIED: 2>, is_verified = False
[   38s] 
[   38s]     @pytest.mark.parametrize(
[   38s]         'verified_result ,is_verified',
[   38s]         [
[   38s]             (VerifiedResult.UNVERIFIED, False),
[   38s]             (VerifiedResult.VERIFIED_FALSE, False),
[   38s]             (VerifiedResult.VERIFIED_TRUE, True),
[   38s]         ],
[   38s]     )
[   38s]     def test_potential_secret_constructed_correctly(self, verified_result, is_verified):
[   38s]         self._enable_filter()
[   38s]         plugin = MockPlugin(verified_result)
[   38s]         output = plugin.analyze_line(
[   38s] >           filename=self.filename,
[   38s]             line=self.line,
[   38s]             line_number=1,
[   38s]             context=self.context,
[   38s]         )
[   38s] E       AttributeError: 'TestAnalyzeLine' object has no attribute 'filename'
[   38s] 
[   38s] tests/plugins/base_test.py:65: AttributeError
[   38s] _ TestAnalyzeLine.test_potential_secret_constructed_correctly[VerifiedResult.VERIFIED_FALSE-False] _
[   38s] 
[   38s] self = <base_test.TestAnalyzeLine object at 0x7f61b09190f0>
[   38s] verified_result = <VerifiedResult.VERIFIED_FALSE: 1>, is_verified = False
[   38s] 
[   38s]     @pytest.mark.parametrize(
[   38s]         'verified_result ,is_verified',
[   38s]         [
[   38s]             (VerifiedResult.UNVERIFIED, False),
[   38s]             (VerifiedResult.VERIFIED_FALSE, False),
[   38s]             (VerifiedResult.VERIFIED_TRUE, True),
[   38s]         ],
[   38s]     )
[   38s]     def test_potential_secret_constructed_correctly(self, verified_result, is_verified):
[   38s]         self._enable_filter()
[   38s]         plugin = MockPlugin(verified_result)
[   38s]         output = plugin.analyze_line(
[   38s] >           filename=self.filename,
[   38s]             line=self.line,
[   38s]             line_number=1,
[   38s]             context=self.context,
[   38s]         )
[   38s] E       AttributeError: 'TestAnalyzeLine' object has no attribute 'filename'
[   38s] 
[   38s] tests/plugins/base_test.py:65: AttributeError
[   38s] _ TestAnalyzeLine.test_potential_secret_constructed_correctly[VerifiedResult.VERIFIED_TRUE-True] _
[   38s] 
[   38s] self = <base_test.TestAnalyzeLine object at 0x7f61b09199c0>
[   38s] verified_result = <VerifiedResult.VERIFIED_TRUE: 3>, is_verified = True
[   38s] 
[   38s]     @pytest.mark.parametrize(
[   38s]         'verified_result ,is_verified',
[   38s]         [
[   38s]             (VerifiedResult.UNVERIFIED, False),
[   38s]             (VerifiedResult.VERIFIED_FALSE, False),
[   38s]             (VerifiedResult.VERIFIED_TRUE, True),
[   38s]         ],
[   38s]     )
[   38s]     def test_potential_secret_constructed_correctly(self, verified_result, is_verified):
[   38s]         self._enable_filter()
[   38s]         plugin = MockPlugin(verified_result)
[   38s]         output = plugin.analyze_line(
[   38s] >           filename=self.filename,
[   38s]             line=self.line,
[   38s]             line_number=1,
[   38s]             context=self.context,
[   38s]         )
[   38s] E       AttributeError: 'TestAnalyzeLine' object has no attribute 'filename'
[   38s] 
[   38s] tests/plugins/base_test.py:65: AttributeError
[   38s] _ TestAnalyzeLine.test_no_verification_call_if_verification_filter_is_disabled _
[   38s] 
[   38s] self = <base_test.TestAnalyzeLine object at 0x7f61b091b790>
[   38s] 
[   38s]     def test_no_verification_call_if_verification_filter_is_disabled(self):
[   38s]         self._disable_filter()
[   38s]         plugin = MockPlugin(VerifiedResult.VERIFIED_TRUE)
[   38s]         output = plugin.analyze_line(
[   38s] >           filename=self.filename,
[   38s]             line=self.line,
[   38s]             line_number=1,
[   38s]             context=self.context,
[   38s]         )
[   38s] E       AttributeError: 'TestAnalyzeLine' object has no attribute 'filename'
[   38s] 
[   38s] tests/plugins/base_test.py:81: AttributeError
[   38s] ___________ TestAnalyzeLine.test_handle_verify_exception_gracefully ____________
[   38s] 
[   38s] self = <base_test.TestAnalyzeLine object at 0x7f61b0919c60>
[   38s] 
[   38s]     def test_handle_verify_exception_gracefully(self):
[   38s]         self._enable_filter()
[   38s]         plugin = MockExceptionRaisingPlugin()
[   38s]         output = plugin.analyze_line(
[   38s] >           filename=self.filename,
[   38s]             line=self.line,
[   38s]             line_number=1,
[   38s]             context=self.context,
[   38s]         )
[   38s] E       AttributeError: 'TestAnalyzeLine' object has no attribute 'filename'
[   38s] 
[   38s] tests/plugins/base_test.py:94: AttributeError
[   38s] =============================== warnings summary ===============================
[   38s] tests/core/baseline_test.py::TestCreate::test_error_when_getting_git_tracked_files
[   38s]   /home/abuild/rpmbuild/BUILD/detect-secrets-1.5.0/detect_secrets/core/scan.py:74: UserWarning: Did not detect git repository. Try scanning all files instead.
[   38s]     log.warning('Did not detect git repository. Try scanning all files instead.')
[   38s] 
[   38s] tests/core/usage/filters_usage_test.py::test_disable_filter
[   38s]   /home/abuild/rpmbuild/BUILD/detect-secrets-1.5.0/detect_secrets/core/usage/filters.py:192: UserWarning: Redundant --disable-filter "blah"
[   38s]     log.warning(f'Redundant --disable-filter "{name}"')
[   38s] 
[   38s] -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
[   38s] =========================== short test summary info ============================
[   38s] FAILED tests/plugins/aws_key_test.py::TestAWSKeyDetector::test_verify_no_secret
[   38s] FAILED tests/plugins/aws_key_test.py::TestAWSKeyDetector::test_verify_valid_secret
[   38s] FAILED tests/plugins/aws_key_test.py::TestAWSKeyDetector::test_verify_invalid_secret
[   38s] FAILED tests/plugins/aws_key_test.py::TestAWSKeyDetector::test_verify_keep_trying_until_found_something
[   38s] FAILED tests/plugins/base_test.py::TestAnalyzeLine::test_potential_secret_constructed_correctly[VerifiedResult.UNVERIFIED-False]
[   38s] FAILED tests/plugins/base_test.py::TestAnalyzeLine::test_potential_secret_constructed_correctly[VerifiedResult.VERIFIED_FALSE-False]
[   38s] FAILED tests/plugins/base_test.py::TestAnalyzeLine::test_potential_secret_constructed_correctly[VerifiedResult.VERIFIED_TRUE-True]
[   38s] FAILED tests/plugins/base_test.py::TestAnalyzeLine::test_no_verification_call_if_verification_filter_is_disabled
[   38s] FAILED tests/plugins/base_test.py::TestAnalyzeLine::test_handle_verify_exception_gracefully
[   38s] ============ 9 failed, 1022 passed, 6 xfailed, 2 warnings in 32.24s ============

I am a little confused why the Did not detect git repository warning pops up. The tarball contains the .git directory, i.e. the build directory should be a valid git repository.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

The package is built in an offline-environment after preparing the source tarball and installing dependencies from the OS.

The tests are being run using pytest 8.2.2.

  • What is the expected behavior?

Ideally the tests should pass.

  • Please tell us about your environment:
    • detect-secrets Version: 1.5.0
    • Python Version: 3.10 / 3.11 / 3.12
    • OS Version: openSUSE Tumbleweed
    • File type (if applicable):

Any hints are highly appreciated!

Kind Regards
Johannes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant