Skip to content

feat(tests): MockAzureClient rule regression test harness — 7 rules offline#124

Merged
Vishnu2707 merged 14 commits into
devfrom
feat/mock-test-harness
Jun 5, 2026
Merged

feat(tests): MockAzureClient rule regression test harness — 7 rules offline#124
Vishnu2707 merged 14 commits into
devfrom
feat/mock-test-harness

Conversation

@TFT444
Copy link
Copy Markdown
Collaborator

@TFT444 TFT444 commented Jun 4, 2026

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

  • New scan rule
  • Documentation

Files added

  • tests/helpers/__init__.py — package marker
  • tests/helpers/mock_azure.pyMockAzureClient drop-in for the real
    AzureClient. Configure fake resources via set_*() helpers.
    make_resource(**kwargs) builds SimpleNamespace objects for any
    resource attribute structure the rules need.
  • tests/conftest.py — added mock_azure and subscription_id fixtures
    alongside the existing Flask fixtures (no existing tests broken)
  • tests/test_rules_storage.py — AZ-STOR-001, AZ-STOR-002
  • tests/test_rules_network.py — AZ-NET-001, AZ-NET-002
  • tests/test_rules_identity.py — AZ-IDN-001
  • tests/test_rules_keyvault.py — AZ-KV-002
  • tests/test_rules_database.py — AZ-DB-004

Testing

  • 17 tests across 7 rules, 5 categories
  • Every rule has a compliant case (0 findings) and a non-compliant
    case (exactly 1 finding with correct rule_id, severity, category,
    resource fields, and metadata)
  • No hardcoded credentials or secrets
  • All seven CI checks pass

Related issue

Closes #114

TFT444 added 8 commits June 4, 2026 15:50
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.
@TFT444 TFT444 self-assigned this Jun 4, 2026
@TFT444
Copy link
Copy Markdown
Collaborator Author

TFT444 commented Jun 5, 2026

@Vishnu2707 When ever you get time to check. I believe all good

Thank You

@TFT444 TFT444 requested a review from Vishnu2707 June 5, 2026 00:02
Copy link
Copy Markdown
Member

@Vishnu2707 Vishnu2707 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

@Vishnu2707 Vishnu2707 merged commit c938551 into dev Jun 5, 2026
1 check passed
@Vishnu2707 Vishnu2707 deleted the feat/mock-test-harness branch June 5, 2026 19:52
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

Successfully merging this pull request may close these issues.

2 participants