Add test_apigateway_rest_api_waf_acl_attached.py to validate WAF ACL logic#304
Open
prajwal-choudhari-comprinno wants to merge 4 commits intocomprinnotech:testcases_devfrom
Conversation
|
|
||
| assert report.status == CheckStatus.UNKNOWN | ||
| assert report.resource_ids_status[0].status == CheckStatus.UNKNOWN | ||
| assert "API Gateway listing error occurred." in report.resource_ids_status[0].summary |
Contributor
There was a problem hiding this comment.
- No partial WAF coverage test Add test with one stage with webAclArn, one without
- No multiple API coverage Add test with two APIs (one passes, one fails)
- Exception field untested Assert presence of exception in the result for exceptions
- All APIs missing WAF Add test for multiple APIs, all stages missing WAF
There was a problem hiding this comment.
Partial WAF coverage (some stages with WAF, some without)
Multiple APIs with mixed WAF coverage
Exception field coverage for get_stages and get_rest_apis
All APIs missing WAF scenario
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.
Context
This change introduces unit tests for the
apigateway_rest_api_waf_acl_attachedcheck. The purpose is to validate the logic that determines whether API Gateway REST APIs have WAF ACLs attached. This ensures the check's accuracy under various conditions and increases confidence during refactoring or enhancement.Description
This PR includes a comprehensive test suite for the check
apigateway_rest_api_waf_acl_attached, covering the following scenarios:No REST APIs exist: The check should return
PASSEDwith no resources.WAF ACL is attached to REST API: The test simulates a REST API with the expected WAF tag. (Note: currently returns
FAILEDwith empty results due to current implementation, as documented.)WAF ACL not attached to REST API: Simulates APIs without the tag, expecting a
FAILEDresult.ClientError from AWS API: Simulates an AWS permission issue or internal error. The check should return
UNKNOWN.All tests mock the
boto3API calls usingunittest.mock, avoiding live AWS interaction. No additional dependencies or infrastructure are required.Checklist
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.