mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 23:05:05 +00:00
fix(test): mock VPC client (#2640)
This commit is contained in:
@@ -50,25 +50,24 @@ class Test_vpc_flow_logs_enabled:
|
|||||||
with mock.patch(
|
with mock.patch(
|
||||||
"prowler.providers.aws.lib.audit_info.audit_info.current_audit_info",
|
"prowler.providers.aws.lib.audit_info.audit_info.current_audit_info",
|
||||||
new=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(
|
# Test Check
|
||||||
"prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled.vpc_client",
|
from prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled import (
|
||||||
new=VPC(current_audit_info),
|
vpc_flow_logs_enabled,
|
||||||
):
|
)
|
||||||
# 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()
|
check = vpc_flow_logs_enabled()
|
||||||
result = check.execute()
|
result = check.execute()
|
||||||
|
|
||||||
assert (
|
assert len(result) == 2 # Number of AWS regions, one default VPC per region
|
||||||
len(result) == 2
|
|
||||||
) # Number of AWS regions, one default VPC per region
|
|
||||||
|
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_vpc_with_flow_logs(self):
|
def test_vpc_with_flow_logs(self):
|
||||||
|
from prowler.providers.aws.services.vpc.vpc_service import VPC
|
||||||
|
|
||||||
# Create VPC Mocked Resources
|
# Create VPC Mocked Resources
|
||||||
ec2_client = client("ec2", region_name=AWS_REGION)
|
ec2_client = client("ec2", region_name=AWS_REGION)
|
||||||
|
|
||||||
@@ -90,6 +89,9 @@ class Test_vpc_flow_logs_enabled:
|
|||||||
with mock.patch(
|
with mock.patch(
|
||||||
"prowler.providers.aws.lib.audit_info.audit_info.current_audit_info",
|
"prowler.providers.aws.lib.audit_info.audit_info.current_audit_info",
|
||||||
new=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
|
# Test Check
|
||||||
from prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled import (
|
from prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled import (
|
||||||
@@ -111,6 +113,8 @@ class Test_vpc_flow_logs_enabled:
|
|||||||
|
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_vpc_without_flow_logs(self):
|
def test_vpc_without_flow_logs(self):
|
||||||
|
from prowler.providers.aws.services.vpc.vpc_service import VPC
|
||||||
|
|
||||||
# Create VPC Mocked Resources
|
# Create VPC Mocked Resources
|
||||||
ec2_client = client("ec2", region_name=AWS_REGION)
|
ec2_client = client("ec2", region_name=AWS_REGION)
|
||||||
|
|
||||||
@@ -121,6 +125,9 @@ class Test_vpc_flow_logs_enabled:
|
|||||||
with mock.patch(
|
with mock.patch(
|
||||||
"prowler.providers.aws.lib.audit_info.audit_info.current_audit_info",
|
"prowler.providers.aws.lib.audit_info.audit_info.current_audit_info",
|
||||||
new=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
|
# Test Check
|
||||||
from prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled import (
|
from prowler.providers.aws.services.vpc.vpc_flow_logs_enabled.vpc_flow_logs_enabled import (
|
||||||
|
|||||||
Reference in New Issue
Block a user