feat(tests): MockAzureClient rule regression test harness — 7 rules offline#124
Merged
Conversation
Introduced MockAzureClient for offline testing of Azure-related functionality.
Add fixtures for mock Azure client and subscription ID
This file contains regression tests for storage rules AZ-STOR-001 and AZ-STOR-002, ensuring compliance checks for public access and HTTPS-only settings.
Add regression tests for AZ-NET-001 and AZ-NET-002 rules to validate compliance and non-compliance scenarios for NSGs.
Added regression tests for AZ-IDN-001 rule to validate compliance and non-compliance scenarios.
Added regression tests for AZ-KV-002 rule to validate Key Vault compliance based on public access and private endpoint configurations.
Add regression tests for AZ-DB-004 rule compliance.
Added comments to clarify credential scanning patterns.
Collaborator
Author
|
@Vishnu2707 When ever you get time to check. I believe all good Thank You |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a fully offline rule regression test harness so scanner rules can be
tested without any live Azure credentials or network calls.
Type of change
Files added
tests/helpers/__init__.py— package markertests/helpers/mock_azure.py—MockAzureClientdrop-in for the realAzureClient. Configure fake resources viaset_*()helpers.make_resource(**kwargs)buildsSimpleNamespaceobjects for anyresource attribute structure the rules need.
tests/conftest.py— addedmock_azureandsubscription_idfixturesalongside the existing Flask fixtures (no existing tests broken)
tests/test_rules_storage.py— AZ-STOR-001, AZ-STOR-002tests/test_rules_network.py— AZ-NET-001, AZ-NET-002tests/test_rules_identity.py— AZ-IDN-001tests/test_rules_keyvault.py— AZ-KV-002tests/test_rules_database.py— AZ-DB-004Testing
case (exactly 1 finding with correct rule_id, severity, category,
resource fields, and metadata)
Related issue
Closes #114