Skip to content

Commit c54227b

Browse files
fix(test): solve VPC import in tests (#4674)
Co-authored-by: Sergio <[email protected]>
1 parent cce564b commit c54227b

File tree

19 files changed

+149
-17
lines changed

19 files changed

+149
-17
lines changed

tests/providers/aws/services/ec2/ec2_securitygroup_allow_ingress_from_internet_to_any_port/ec2_securitygroup_allow_ingress_from_internet_to_any_port_test.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from boto3 import client, resource
44
from moto import mock_aws
55

6-
from prowler.providers.aws.services.vpc.vpc_service import VPC
76
from tests.providers.aws.audit_info_utils import (
87
AWS_REGION_EU_WEST_1,
98
AWS_REGION_US_EAST_1,
@@ -19,6 +18,7 @@ def test_ec2_default_sgs(self):
1918
ec2_client.create_vpc(CidrBlock="10.0.0.0/16")
2019

2120
from prowler.providers.aws.services.ec2.ec2_service import EC2
21+
from prowler.providers.aws.services.vpc.vpc_service import VPC
2222

2323
current_audit_info = set_mocked_aws_audit_info(
2424
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -70,6 +70,7 @@ def test_ec2_non_compliant_default_sg(self):
7070
)
7171

7272
from prowler.providers.aws.services.ec2.ec2_service import EC2
73+
from prowler.providers.aws.services.vpc.vpc_service import VPC
7374

7475
current_audit_info = set_mocked_aws_audit_info(
7576
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -132,6 +133,7 @@ def test_ec2_compliant_default_sg(self):
132133
)
133134

134135
from prowler.providers.aws.services.ec2.ec2_service import EC2
136+
from prowler.providers.aws.services.vpc.vpc_service import VPC
135137

136138
current_audit_info = set_mocked_aws_audit_info(
137139
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -199,6 +201,7 @@ def test_ec2_compliant_default_sg_only_open_to_one_port(self):
199201
)
200202

201203
from prowler.providers.aws.services.ec2.ec2_service import EC2
204+
from prowler.providers.aws.services.vpc.vpc_service import VPC
202205

203206
current_audit_info = set_mocked_aws_audit_info(
204207
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -247,6 +250,7 @@ def test_ec2_default_sgs_ignoring(self):
247250
ec2_client.create_vpc(CidrBlock="10.0.0.0/16")
248251

249252
from prowler.providers.aws.services.ec2.ec2_service import EC2
253+
from prowler.providers.aws.services.vpc.vpc_service import VPC
250254

251255
current_audit_info = set_mocked_aws_audit_info(
252256
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -287,6 +291,7 @@ def test_ec2_default_sgs_ignoring_vpc_in_use(self):
287291
default_sg["GroupId"]
288292
default_sg["GroupName"]
289293
from prowler.providers.aws.services.ec2.ec2_service import EC2
294+
from prowler.providers.aws.services.vpc.vpc_service import VPC
290295

291296
current_audit_info = set_mocked_aws_audit_info(
292297
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -329,6 +334,7 @@ def test_ec2_default_sgs_with_all_ports_check(self):
329334
default_sg["GroupId"]
330335
default_sg["GroupName"]
331336
from prowler.providers.aws.services.ec2.ec2_service import EC2
337+
from prowler.providers.aws.services.vpc.vpc_service import VPC
332338

333339
current_audit_info = set_mocked_aws_audit_info(
334340
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -389,6 +395,7 @@ def test_ec2_non_compliant_default_sg_pass_to_avoid_fail_twice(self):
389395
)
390396

391397
from prowler.providers.aws.services.ec2.ec2_service import EC2
398+
from prowler.providers.aws.services.vpc.vpc_service import VPC
392399

393400
current_audit_info = set_mocked_aws_audit_info(
394401
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]

tests/providers/aws/services/ec2/ec2_securitygroup_allow_ingress_from_internet_to_port_mongodb_27017_27018/ec2_securitygroup_allow_ingress_from_internet_to_port_mongodb_27017_27018_test.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from boto3 import client, resource
44
from moto import mock_aws
55

6-
from prowler.providers.aws.services.vpc.vpc_service import VPC
76
from tests.providers.aws.audit_info_utils import (
87
AWS_REGION_EU_WEST_1,
98
AWS_REGION_US_EAST_1,
@@ -19,6 +18,7 @@ def test_ec2_default_sgs(self):
1918
ec2_client.create_vpc(CidrBlock="10.0.0.0/16")
2019

2120
from prowler.providers.aws.services.ec2.ec2_service import EC2
21+
from prowler.providers.aws.services.vpc.vpc_service import VPC
2222

2323
current_audit_info = set_mocked_aws_audit_info(
2424
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -74,6 +74,7 @@ def test_ec2_non_compliant_default_sg(self):
7474
)
7575

7676
from prowler.providers.aws.services.ec2.ec2_service import EC2
77+
from prowler.providers.aws.services.vpc.vpc_service import VPC
7778

7879
current_audit_info = set_mocked_aws_audit_info(
7980
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -140,6 +141,7 @@ def test_ec2_compliant_default_sg(self):
140141
)
141142

142143
from prowler.providers.aws.services.ec2.ec2_service import EC2
144+
from prowler.providers.aws.services.vpc.vpc_service import VPC
143145

144146
current_audit_info = set_mocked_aws_audit_info(
145147
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -190,6 +192,7 @@ def test_ec2_default_sgs_ignoring(self):
190192
ec2_client.create_vpc(CidrBlock="10.0.0.0/16")
191193

192194
from prowler.providers.aws.services.ec2.ec2_service import EC2
195+
from prowler.providers.aws.services.vpc.vpc_service import VPC
193196

194197
current_audit_info = set_mocked_aws_audit_info(
195198
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -232,6 +235,7 @@ def test_ec2_default_sgs_ignoring_vpc_in_use(self):
232235
default_sg["GroupId"]
233236
default_sg["GroupName"]
234237
from prowler.providers.aws.services.ec2.ec2_service import EC2
238+
from prowler.providers.aws.services.vpc.vpc_service import VPC
235239

236240
current_audit_info = set_mocked_aws_audit_info(
237241
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -291,6 +295,7 @@ def test_ec2_non_compliant_default_sg_pass_to_avoid_fail_twice(self):
291295
)
292296

293297
from prowler.providers.aws.services.ec2.ec2_service import EC2
298+
from prowler.providers.aws.services.vpc.vpc_service import VPC
294299

295300
current_audit_info = set_mocked_aws_audit_info(
296301
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]

tests/providers/aws/services/ec2/ec2_securitygroup_allow_ingress_from_internet_to_tcp_ftp_port_20_21/ec2_securitygroup_allow_ingress_from_internet_to_tcp_ftp_port_20_21_test.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from boto3 import client, resource
44
from moto import mock_aws
55

6-
from prowler.providers.aws.services.vpc.vpc_service import VPC
76
from tests.providers.aws.audit_info_utils import (
87
AWS_REGION_EU_WEST_1,
98
AWS_REGION_US_EAST_1,
@@ -19,6 +18,7 @@ def test_ec2_default_sgs(self):
1918
ec2_client.create_vpc(CidrBlock="10.0.0.0/16")
2019

2120
from prowler.providers.aws.services.ec2.ec2_service import EC2
21+
from prowler.providers.aws.services.vpc.vpc_service import VPC
2222

2323
current_audit_info = set_mocked_aws_audit_info(
2424
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -74,6 +74,7 @@ def test_ec2_non_compliant_default_sg(self):
7474
)
7575

7676
from prowler.providers.aws.services.ec2.ec2_service import EC2
77+
from prowler.providers.aws.services.vpc.vpc_service import VPC
7778

7879
current_audit_info = set_mocked_aws_audit_info(
7980
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -140,6 +141,7 @@ def test_ec2_compliant_default_sg(self):
140141
)
141142

142143
from prowler.providers.aws.services.ec2.ec2_service import EC2
144+
from prowler.providers.aws.services.vpc.vpc_service import VPC
143145

144146
current_audit_info = set_mocked_aws_audit_info(
145147
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -190,6 +192,7 @@ def test_ec2_default_sgs_ignoring(self):
190192
ec2_client.create_vpc(CidrBlock="10.0.0.0/16")
191193

192194
from prowler.providers.aws.services.ec2.ec2_service import EC2
195+
from prowler.providers.aws.services.vpc.vpc_service import VPC
193196

194197
current_audit_info = set_mocked_aws_audit_info(
195198
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -232,6 +235,7 @@ def test_ec2_default_sgs_ignoring_vpc_in_use(self):
232235
default_sg["GroupId"]
233236
default_sg["GroupName"]
234237
from prowler.providers.aws.services.ec2.ec2_service import EC2
238+
from prowler.providers.aws.services.vpc.vpc_service import VPC
235239

236240
current_audit_info = set_mocked_aws_audit_info(
237241
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -291,6 +295,7 @@ def test_ec2_non_compliant_default_sg_pass_to_avoid_fail_twice(self):
291295
)
292296

293297
from prowler.providers.aws.services.ec2.ec2_service import EC2
298+
from prowler.providers.aws.services.vpc.vpc_service import VPC
294299

295300
current_audit_info = set_mocked_aws_audit_info(
296301
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]

tests/providers/aws/services/ec2/ec2_securitygroup_allow_ingress_from_internet_to_tcp_port_22/ec2_securitygroup_allow_ingress_from_internet_to_tcp_port_22_test.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from boto3 import client, resource
55
from moto import mock_aws
66

7-
from prowler.providers.aws.services.vpc.vpc_service import VPC
87
from tests.providers.aws.audit_info_utils import (
98
AWS_REGION_EU_WEST_1,
109
AWS_REGION_US_EAST_1,
@@ -20,6 +19,7 @@ def test_ec2_default_sgs(self):
2019
ec2_client.create_vpc(CidrBlock="10.0.0.0/16")
2120

2221
from prowler.providers.aws.services.ec2.ec2_service import EC2
22+
from prowler.providers.aws.services.vpc.vpc_service import VPC
2323

2424
current_audit_info = set_mocked_aws_audit_info(
2525
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -73,6 +73,7 @@ def test_ec2_non_compliant_default_sg(self):
7373
)
7474

7575
from prowler.providers.aws.services.ec2.ec2_service import EC2
76+
from prowler.providers.aws.services.vpc.vpc_service import VPC
7677

7778
current_audit_info = set_mocked_aws_audit_info(
7879
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -141,6 +142,7 @@ def test_ec2_compliant_default_sg(self):
141142
)
142143

143144
from prowler.providers.aws.services.ec2.ec2_service import EC2
145+
from prowler.providers.aws.services.vpc.vpc_service import VPC
144146

145147
current_audit_info = set_mocked_aws_audit_info(
146148
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -189,6 +191,7 @@ def test_ec2_default_sgs_ignoring(self):
189191
ec2_client.create_vpc(CidrBlock="10.0.0.0/16")
190192

191193
from prowler.providers.aws.services.ec2.ec2_service import EC2
194+
from prowler.providers.aws.services.vpc.vpc_service import VPC
192195

193196
current_audit_info = set_mocked_aws_audit_info(
194197
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -229,6 +232,7 @@ def test_ec2_default_sgs_ignoring_vpc_in_use(self):
229232
default_sg["GroupId"]
230233
default_sg["GroupName"]
231234
from prowler.providers.aws.services.ec2.ec2_service import EC2
235+
from prowler.providers.aws.services.vpc.vpc_service import VPC
232236

233237
current_audit_info = set_mocked_aws_audit_info(
234238
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -286,6 +290,7 @@ def test_ec2_non_compliant_default_sg_pass_to_avoid_fail_twice(self):
286290
)
287291

288292
from prowler.providers.aws.services.ec2.ec2_service import EC2
293+
from prowler.providers.aws.services.vpc.vpc_service import VPC
289294

290295
current_audit_info = set_mocked_aws_audit_info(
291296
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]

tests/providers/aws/services/ec2/ec2_securitygroup_allow_ingress_from_internet_to_tcp_port_3389/ec2_securitygroup_allow_ingress_from_internet_to_tcp_port_3389_test.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from boto3 import client, resource
44
from moto import mock_aws
55

6-
from prowler.providers.aws.services.vpc.vpc_service import VPC
76
from tests.providers.aws.audit_info_utils import (
87
AWS_REGION_EU_WEST_1,
98
AWS_REGION_US_EAST_1,
@@ -19,6 +18,7 @@ def test_ec2_default_sgs(self):
1918
ec2_client.create_vpc(CidrBlock="10.0.0.0/16")
2019

2120
from prowler.providers.aws.services.ec2.ec2_service import EC2
21+
from prowler.providers.aws.services.vpc.vpc_service import VPC
2222

2323
current_audit_info = set_mocked_aws_audit_info(
2424
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -56,6 +56,7 @@ def test_ec2_default_sgs_ignoring(self):
5656
ec2_client.create_vpc(CidrBlock="10.0.0.0/16")
5757

5858
from prowler.providers.aws.services.ec2.ec2_service import EC2
59+
from prowler.providers.aws.services.vpc.vpc_service import VPC
5960

6061
current_audit_info = set_mocked_aws_audit_info(
6162
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -96,6 +97,7 @@ def test_ec2_default_sgs_ignoring_vpc_in_use(self):
9697
default_sg["GroupId"]
9798
default_sg["GroupName"]
9899
from prowler.providers.aws.services.ec2.ec2_service import EC2
100+
from prowler.providers.aws.services.vpc.vpc_service import VPC
99101

100102
current_audit_info = set_mocked_aws_audit_info(
101103
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -147,6 +149,7 @@ def test_ec2_non_compliant_default_sg(self):
147149
)
148150

149151
from prowler.providers.aws.services.ec2.ec2_service import EC2
152+
from prowler.providers.aws.services.vpc.vpc_service import VPC
150153

151154
current_audit_info = set_mocked_aws_audit_info(
152155
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -211,6 +214,7 @@ def test_ec2_compliant_default_sg(self):
211214
)
212215

213216
from prowler.providers.aws.services.ec2.ec2_service import EC2
217+
from prowler.providers.aws.services.vpc.vpc_service import VPC
214218

215219
current_audit_info = set_mocked_aws_audit_info(
216220
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -281,6 +285,7 @@ def test_ec2_non_compliant_default_sg_pass_to_avoid_fail_twice(self):
281285
)
282286

283287
from prowler.providers.aws.services.ec2.ec2_service import EC2
288+
from prowler.providers.aws.services.vpc.vpc_service import VPC
284289

285290
current_audit_info = set_mocked_aws_audit_info(
286291
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]

tests/providers/aws/services/ec2/ec2_securitygroup_allow_ingress_from_internet_to_tcp_port_cassandra_7199_9160_8888/ec2_securitygroup_allow_ingress_from_internet_to_tcp_port_cassandra_7199_9160_8888_test.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from boto3 import client, resource
44
from moto import mock_aws
55

6-
from prowler.providers.aws.services.vpc.vpc_service import VPC
76
from tests.providers.aws.audit_info_utils import (
87
AWS_REGION_EU_WEST_1,
98
AWS_REGION_US_EAST_1,
@@ -19,6 +18,7 @@ def test_ec2_default_sgs(self):
1918
ec2_client.create_vpc(CidrBlock="10.0.0.0/16")
2019

2120
from prowler.providers.aws.services.ec2.ec2_service import EC2
21+
from prowler.providers.aws.services.vpc.vpc_service import VPC
2222

2323
current_audit_info = set_mocked_aws_audit_info(
2424
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -74,6 +74,7 @@ def test_ec2_non_compliant_default_sg(self):
7474
)
7575

7676
from prowler.providers.aws.services.ec2.ec2_service import EC2
77+
from prowler.providers.aws.services.vpc.vpc_service import VPC
7778

7879
current_audit_info = set_mocked_aws_audit_info(
7980
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -140,6 +141,7 @@ def test_ec2_compliant_default_sg(self):
140141
)
141142

142143
from prowler.providers.aws.services.ec2.ec2_service import EC2
144+
from prowler.providers.aws.services.vpc.vpc_service import VPC
143145

144146
current_audit_info = set_mocked_aws_audit_info(
145147
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]
@@ -190,6 +192,7 @@ def test_ec2_default_sgs_ignoring(self):
190192
ec2_client.create_vpc(CidrBlock="10.0.0.0/16")
191193

192194
from prowler.providers.aws.services.ec2.ec2_service import EC2
195+
from prowler.providers.aws.services.vpc.vpc_service import VPC
193196

194197
current_audit_info = set_mocked_aws_audit_info(
195198
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -232,6 +235,7 @@ def test_ec2_default_sgs_ignoring_vpc_in_use(self):
232235
default_sg["GroupId"]
233236
default_sg["GroupName"]
234237
from prowler.providers.aws.services.ec2.ec2_service import EC2
238+
from prowler.providers.aws.services.vpc.vpc_service import VPC
235239

236240
current_audit_info = set_mocked_aws_audit_info(
237241
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1],
@@ -291,6 +295,7 @@ def test_ec2_non_compliant_default_sg_pass_to_avoid_fail_twice(self):
291295
)
292296

293297
from prowler.providers.aws.services.ec2.ec2_service import EC2
298+
from prowler.providers.aws.services.vpc.vpc_service import VPC
294299

295300
current_audit_info = set_mocked_aws_audit_info(
296301
[AWS_REGION_EU_WEST_1, AWS_REGION_US_EAST_1]

0 commit comments

Comments
 (0)