mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 06:45:08 +00:00
fix(test): Update moto to 4.1.15 and update tests (#2769)
This commit is contained in:
11
poetry.lock
generated
11
poetry.lock
generated
@@ -1,4 +1,4 @@
|
||||
# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand.
|
||||
# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "about-time"
|
||||
@@ -1572,13 +1572,13 @@ test = ["pytest", "pytest-cov"]
|
||||
|
||||
[[package]]
|
||||
name = "moto"
|
||||
version = "4.1.14"
|
||||
version = "4.1.15"
|
||||
description = ""
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "moto-4.1.14-py2.py3-none-any.whl", hash = "sha256:7d3bd748a34641715ba469c761f72fb8ec18f349987c98f5a0f9be85a07a9911"},
|
||||
{file = "moto-4.1.14.tar.gz", hash = "sha256:545afeb4df94dfa730e2d7e87366dc26b4a33c2891f462cbb049f040c80ed1ec"},
|
||||
{file = "moto-4.1.15-py2.py3-none-any.whl", hash = "sha256:3fbcf91090692c30117d275fb34b48a075a6f65d4712ba6c4d004ffab976db46"},
|
||||
{file = "moto-4.1.15.tar.gz", hash = "sha256:272236d312457b324c645741ee589924fd61a96b84680dc2e607f8663c563551"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@@ -1610,6 +1610,7 @@ efs = ["sshpubkeys (>=3.1.0)"]
|
||||
eks = ["sshpubkeys (>=3.1.0)"]
|
||||
glue = ["pyparsing (>=3.0.7)"]
|
||||
iotdata = ["jsondiff (>=1.1.2)"]
|
||||
resourcegroupstaggingapi = ["PyYAML (>=5.1)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "ecdsa (!=0.15)", "graphql-core", "jsondiff (>=1.1.2)", "openapi-spec-validator (>=0.2.8)", "py-partiql-parser (==0.3.6)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "sshpubkeys (>=3.1.0)"]
|
||||
route53resolver = ["sshpubkeys (>=3.1.0)"]
|
||||
s3 = ["PyYAML (>=5.1)", "py-partiql-parser (==0.3.6)"]
|
||||
s3crc32c = ["PyYAML (>=5.1)", "crc32c", "py-partiql-parser (==0.3.6)"]
|
||||
@@ -3162,4 +3163,4 @@ docs = ["mkdocs", "mkdocs-material"]
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.9"
|
||||
content-hash = "97d9ac4036f3d11b8315bebaa047a90b74c00acf8a5827e39a8e7fbe99ce4fbd"
|
||||
content-hash = "a3cc3cb89965a792f4ec253c97e35689d599acd4e05d49cc719bdd4ef627aac0"
|
||||
|
||||
@@ -61,7 +61,7 @@ docker = "6.1.3"
|
||||
flake8 = "6.1.0"
|
||||
freezegun = "1.2.2"
|
||||
mock = "5.1.0"
|
||||
moto = "4.1.14"
|
||||
moto = "4.1.15"
|
||||
openapi-spec-validator = "0.6.0"
|
||||
pylint = "2.17.5"
|
||||
pytest = "7.4.0"
|
||||
|
||||
@@ -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