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

fix(test): mock VPC client #2640

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,24 @@ def test_vpc_only_default_vpcs(self):
with mock.patch(
"prowler.providers.aws.lib.audit_info.audit_info.current_audit_info",
new=current_audit_info,
), mock.patch(
"prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled.vpc_client",
new=VPC(current_audit_info),
):
with mock.patch(
"prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled.vpc_client",
new=VPC(current_audit_info),
):
# Test Check
from prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled import (
vpc_flow_logs_enabled,
)

check = vpc_flow_logs_enabled()
result = check.execute()

assert (
len(result) == 2
) # Number of AWS regions, one default VPC per region
# Test Check
from prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled import (
vpc_flow_logs_enabled,
)

check = vpc_flow_logs_enabled()
result = check.execute()

assert len(result) == 2 # Number of AWS regions, one default VPC per region

@mock_ec2
def test_vpc_with_flow_logs(self):
from prowler.providers.aws.services.vpc.vpc_service import VPC

# Create VPC Mocked Resources
ec2_client = client("ec2", region_name=AWS_REGION)

Expand All @@ -83,6 +82,9 @@ def test_vpc_with_flow_logs(self):
with mock.patch(
"prowler.providers.aws.lib.audit_info.audit_info.current_audit_info",
new=current_audit_info,
), mock.patch(
"prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled.vpc_client",
new=VPC(current_audit_info),
):
# Test Check
from prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled import (
Expand All @@ -104,6 +106,8 @@ def test_vpc_with_flow_logs(self):

@mock_ec2
def test_vpc_without_flow_logs(self):
from prowler.providers.aws.services.vpc.vpc_service import VPC

# Create VPC Mocked Resources
ec2_client = client("ec2", region_name=AWS_REGION)

Expand All @@ -114,6 +118,9 @@ def test_vpc_without_flow_logs(self):
with mock.patch(
"prowler.providers.aws.lib.audit_info.audit_info.current_audit_info",
new=current_audit_info,
), mock.patch(
"prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled.vpc_client",
new=VPC(current_audit_info),
):
# Test Check
from prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled import (
Expand Down