mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 14:55:00 +00:00
fix(test): Update moto to 4.1.15 and update tests (#2769)
This commit is contained in:
@@ -5,7 +5,6 @@ from boto3 import client, session
|
||||
from moto import mock_cloudtrail, mock_s3
|
||||
|
||||
from prowler.providers.aws.lib.audit_info.models import AWS_Audit_Info
|
||||
from prowler.providers.aws.services.cloudtrail.cloudtrail_service import Trail
|
||||
from prowler.providers.common.models import Audit_Metadata
|
||||
|
||||
AWS_ACCOUNT_NUMBER = "123456789012"
|
||||
@@ -96,7 +95,7 @@ class Test_cloudtrail_multi_region_enabled:
|
||||
|
||||
@mock_cloudtrail
|
||||
@mock_s3
|
||||
def test_various_trails_no_login(self):
|
||||
def test_various_trails_no_logging(self):
|
||||
cloudtrail_client_us_east_1 = client(
|
||||
"cloudtrail", region_name=AWS_REGION_US_EAST_1
|
||||
)
|
||||
@@ -171,7 +170,7 @@ class Test_cloudtrail_multi_region_enabled:
|
||||
|
||||
@mock_cloudtrail
|
||||
@mock_s3
|
||||
def test_various_trails_with_and_without_login(self):
|
||||
def test_various_trails_with_and_without_logging(self):
|
||||
cloudtrail_client_us_east_1 = client(
|
||||
"cloudtrail", region_name=AWS_REGION_US_EAST_1
|
||||
)
|
||||
@@ -247,7 +246,7 @@ class Test_cloudtrail_multi_region_enabled:
|
||||
|
||||
@mock_cloudtrail
|
||||
@mock_s3
|
||||
def test_trail_multiregion_logging_and_single_region_not_login(self):
|
||||
def test_trail_multiregion_logging_and_single_region_not_logging(self):
|
||||
cloudtrail_client_us_east_1 = client(
|
||||
"cloudtrail", region_name=AWS_REGION_US_EAST_1
|
||||
)
|
||||
@@ -287,42 +286,12 @@ class Test_cloudtrail_multi_region_enabled:
|
||||
with mock.patch(
|
||||
"prowler.providers.aws.services.cloudtrail.cloudtrail_multi_region_enabled.cloudtrail_multi_region_enabled.cloudtrail_client",
|
||||
new=Cloudtrail(current_audit_info),
|
||||
) as cloudtrail_client:
|
||||
):
|
||||
# Test Check
|
||||
from prowler.providers.aws.services.cloudtrail.cloudtrail_multi_region_enabled.cloudtrail_multi_region_enabled import (
|
||||
cloudtrail_multi_region_enabled,
|
||||
)
|
||||
|
||||
##############################################################################################################
|
||||
# Only until moto issue is solved (Right now is not getting shadow us-east-1 trail status in eu-west-1 region)
|
||||
cloudtrail_client.trails = [
|
||||
Trail(
|
||||
name=trail_name_us,
|
||||
is_multiregion=True,
|
||||
home_region=AWS_REGION_US_EAST_1,
|
||||
arn=trail_us["TrailARN"],
|
||||
region=AWS_REGION_US_EAST_1,
|
||||
is_logging=True,
|
||||
),
|
||||
Trail(
|
||||
name=trail_name_eu,
|
||||
is_multiregion=False,
|
||||
home_region=AWS_REGION_EU_WEST_1,
|
||||
arn="",
|
||||
region=AWS_REGION_EU_WEST_1,
|
||||
is_logging=False,
|
||||
),
|
||||
Trail(
|
||||
name=trail_name_us,
|
||||
is_multiregion=True,
|
||||
home_region=AWS_REGION_US_EAST_1,
|
||||
arn=trail_us["TrailARN"],
|
||||
region=AWS_REGION_EU_WEST_1,
|
||||
is_logging=True,
|
||||
),
|
||||
]
|
||||
##############################################################################################################
|
||||
|
||||
check = cloudtrail_multi_region_enabled()
|
||||
result = check.execute()
|
||||
assert len(result) == len(current_audit_info.audited_regions)
|
||||
|
||||
@@ -126,10 +126,7 @@ class Test_ec2_instance_detailed_monitoring_enabled:
|
||||
), mock.patch(
|
||||
"prowler.providers.aws.services.ec2.ec2_instance_detailed_monitoring_enabled.ec2_instance_detailed_monitoring_enabled.ec2_client",
|
||||
new=EC2(current_audit_info),
|
||||
) as ec2_client:
|
||||
# Moto does not handle the Monitoring key in the instances, so we have to update it manually
|
||||
ec2_client.instances[0].monitoring_state = "enabled"
|
||||
|
||||
):
|
||||
from prowler.providers.aws.services.ec2.ec2_instance_detailed_monitoring_enabled.ec2_instance_detailed_monitoring_enabled import (
|
||||
ec2_instance_detailed_monitoring_enabled,
|
||||
)
|
||||
|
||||
@@ -274,7 +274,7 @@ class Test_VPC_Service:
|
||||
Type="network",
|
||||
)["LoadBalancers"][0]["LoadBalancerArn"]
|
||||
|
||||
_ = ec2_client.create_vpc_endpoint_service_configuration(
|
||||
endpoint = ec2_client.create_vpc_endpoint_service_configuration(
|
||||
NetworkLoadBalancerArns=[lb_arn],
|
||||
TagSpecifications=[
|
||||
{
|
||||
@@ -285,12 +285,22 @@ class Test_VPC_Service:
|
||||
},
|
||||
],
|
||||
)
|
||||
endpoint_id = endpoint["ServiceConfiguration"]["ServiceId"]
|
||||
endpoint_arn = f"arn:aws:ec2:{AWS_REGION}:{AWS_ACCOUNT_NUMBER}:vpc-endpoint-service/{endpoint_id}"
|
||||
endpoint_service = endpoint["ServiceConfiguration"]["ServiceName"]
|
||||
|
||||
# VPC client for this test class
|
||||
audit_info = self.set_mocked_audit_info()
|
||||
vpc = VPC(audit_info)
|
||||
assert (
|
||||
len(vpc.vpc_endpoint_services) == 0
|
||||
) # Wait until this issue is fixed https://github.com/spulec/moto/issues/5605
|
||||
|
||||
for vpce in vpc.vpc_endpoint_services:
|
||||
assert vpce.arn == endpoint_arn
|
||||
assert vpce.id == endpoint_id
|
||||
assert vpce.service == endpoint_service
|
||||
assert vpce.owner_id == AWS_ACCOUNT_NUMBER
|
||||
assert vpce.allowed_principals == []
|
||||
assert vpce.region == AWS_REGION
|
||||
assert vpce.tags == []
|
||||
|
||||
# Test VPC Describe VPC Subnets
|
||||
@mock_ec2
|
||||
|
||||
Reference in New Issue
Block a user