fix(cloudformation): fix flaky tests (#6398)

This commit is contained in:
Daniel Barranquero
2025-01-09 10:45:11 +01:00
committed by GitHub
parent 80311d3837
commit 9d48f7286a
3 changed files with 42 additions and 0 deletions
@@ -12,6 +12,9 @@ class Test_cloudformation_stack_cdktoolkit_bootstrap_version:
cloudformation_client.stacks = []
cloudformation_client.audit_config = {"recommended_cdk_bootstrap_version": 21}
with mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_service.CloudFormation",
new=cloudformation_client,
), mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_client.cloudformation_client",
new=cloudformation_client,
):
@@ -37,6 +40,9 @@ class Test_cloudformation_stack_cdktoolkit_bootstrap_version:
cloudformation_client.audit_config = {"recommended_cdk_bootstrap_version": 21}
with mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_service.CloudFormation",
new=cloudformation_client,
), mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_client.cloudformation_client",
new=cloudformation_client,
):
@@ -73,6 +79,9 @@ class Test_cloudformation_stack_cdktoolkit_bootstrap_version:
cloudformation_client.audit_config = {"recommended_cdk_bootstrap_version": 21}
with mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_service.CloudFormation",
new=cloudformation_client,
), mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_client.cloudformation_client",
new=cloudformation_client,
):
@@ -10,9 +10,13 @@ class Test_cloudformation_stack_outputs_find_secrets:
def test_no_stacks(self):
cloudformation_client = mock.MagicMock
cloudformation_client.stacks = []
cloudformation_client.audit_config = {"secrets_ignore_patterns": []}
with mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_service.CloudFormation",
new=cloudformation_client,
), mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_client.cloudformation_client",
new=cloudformation_client,
):
# Test Check
from prowler.providers.aws.services.cloudformation.cloudformation_stack_outputs_find_secrets.cloudformation_stack_outputs_find_secrets import (
@@ -36,9 +40,14 @@ class Test_cloudformation_stack_outputs_find_secrets:
)
]
cloudformation_client.audit_config = {"secrets_ignore_patterns": []}
with mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_service.CloudFormation",
cloudformation_client,
), mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_client.cloudformation_client",
new=cloudformation_client,
):
from prowler.providers.aws.services.cloudformation.cloudformation_stack_outputs_find_secrets.cloudformation_stack_outputs_find_secrets import (
cloudformation_stack_outputs_find_secrets,
@@ -75,9 +84,14 @@ class Test_cloudformation_stack_outputs_find_secrets:
)
]
cloudformation_client.audit_config = {"secrets_ignore_patterns": []}
with mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_service.CloudFormation",
cloudformation_client,
), mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_client.cloudformation_client",
new=cloudformation_client,
):
from prowler.providers.aws.services.cloudformation.cloudformation_stack_outputs_find_secrets.cloudformation_stack_outputs_find_secrets import (
cloudformation_stack_outputs_find_secrets,
@@ -112,9 +126,14 @@ class Test_cloudformation_stack_outputs_find_secrets:
)
]
cloudformation_client.audit_config = {"secrets_ignore_patterns": []}
with mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_service.CloudFormation",
cloudformation_client,
), mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_client.cloudformation_client",
new=cloudformation_client,
):
from prowler.providers.aws.services.cloudformation.cloudformation_stack_outputs_find_secrets.cloudformation_stack_outputs_find_secrets import (
cloudformation_stack_outputs_find_secrets,
@@ -149,9 +168,14 @@ class Test_cloudformation_stack_outputs_find_secrets:
)
]
cloudformation_client.audit_config = {"secrets_ignore_patterns": []}
with mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_service.CloudFormation",
cloudformation_client,
), mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_client.cloudformation_client",
new=cloudformation_client,
):
from prowler.providers.aws.services.cloudformation.cloudformation_stack_outputs_find_secrets.cloudformation_stack_outputs_find_secrets import (
cloudformation_stack_outputs_find_secrets,
@@ -13,6 +13,9 @@ class Test_cloudformation_stacks_termination_protection_enabled:
with mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_service.CloudFormation",
new=cloudformation_client,
), mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_client.cloudformation_client",
new=cloudformation_client,
):
# Test Check
from prowler.providers.aws.services.cloudformation.cloudformation_stacks_termination_protection_enabled.cloudformation_stacks_termination_protection_enabled import (
@@ -40,6 +43,9 @@ class Test_cloudformation_stacks_termination_protection_enabled:
with mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_service.CloudFormation",
cloudformation_client,
), mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_client.cloudformation_client",
new=cloudformation_client,
):
from prowler.providers.aws.services.cloudformation.cloudformation_stacks_termination_protection_enabled.cloudformation_stacks_termination_protection_enabled import (
cloudformation_stacks_termination_protection_enabled,
@@ -78,6 +84,9 @@ class Test_cloudformation_stacks_termination_protection_enabled:
with mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_service.CloudFormation",
cloudformation_client,
), mock.patch(
"prowler.providers.aws.services.cloudformation.cloudformation_client.cloudformation_client",
new=cloudformation_client,
):
from prowler.providers.aws.services.cloudformation.cloudformation_stacks_termination_protection_enabled.cloudformation_stacks_termination_protection_enabled import (
cloudformation_stacks_termination_protection_enabled,