mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-23 20:04:27 +00:00
chore(aws): Replace audit_info for provider (#3521)
Co-authored-by: Sergio Garcia <38561120+sergargar@users.noreply.github.com>
This commit is contained in:
1 parent
2176fff8c3
commit
bda5d62c72
362 files changed
+5690
-6022
No files matched your search
@@ -3,10 +3,7 @@ from unittest.mock import patch
|
||||
import botocore
|
||||
|
||||
from prowler.providers.aws.services.securityhub.securityhub_service import SecurityHub
|
||||
from tests.providers.aws.audit_info_utils import (
|
||||
AWS_REGION_EU_WEST_1,
|
||||
set_mocked_aws_audit_info,
|
||||
)
|
||||
from tests.providers.aws.utils import AWS_REGION_EU_WEST_1, set_mocked_aws_provider
|
||||
|
||||
# Mocking Access Analyzer Calls
|
||||
make_api_call = botocore.client.BaseClient._make_api_call
|
||||
@@ -44,8 +41,8 @@ def mock_make_api_call(self, operation_name, kwarg):
|
||||
|
||||
|
||||
# Mock generate_regional_clients()
|
||||
def mock_generate_regional_clients(service, audit_info):
|
||||
regional_client = audit_info.audit_session.client(
|
||||
def mock_generate_regional_clients(provider, service):
|
||||
regional_client = provider._session.current_session.client(
|
||||
service, region_name=AWS_REGION_EU_WEST_1
|
||||
)
|
||||
regional_client.region = AWS_REGION_EU_WEST_1
|
||||
@@ -55,13 +52,13 @@ def mock_generate_regional_clients(service, audit_info):
|
||||
# Patch every AWS call using Boto3 and generate_regional_clients to have 1 client
|
||||
@patch("botocore.client.BaseClient._make_api_call", new=mock_make_api_call)
|
||||
@patch(
|
||||
"prowler.providers.aws.lib.service.service.generate_regional_clients",
|
||||
"prowler.providers.aws.aws_provider.AwsProvider.generate_regional_clients",
|
||||
new=mock_generate_regional_clients,
|
||||
)
|
||||
class Test_SecurityHub_Service:
|
||||
# Test SecurityHub Client
|
||||
def test__get_client__(self):
|
||||
security_hub = SecurityHub(set_mocked_aws_audit_info([AWS_REGION_EU_WEST_1]))
|
||||
security_hub = SecurityHub(set_mocked_aws_provider([AWS_REGION_EU_WEST_1]))
|
||||
assert (
|
||||
security_hub.regional_clients[AWS_REGION_EU_WEST_1].__class__.__name__
|
||||
== "SecurityHub"
|
||||
@@ -69,12 +66,12 @@ class Test_SecurityHub_Service:
|
||||
|
||||
# Test SecurityHub Session
|
||||
def test__get_session__(self):
|
||||
security_hub = SecurityHub(set_mocked_aws_audit_info([AWS_REGION_EU_WEST_1]))
|
||||
security_hub = SecurityHub(set_mocked_aws_provider([AWS_REGION_EU_WEST_1]))
|
||||
assert security_hub.session.__class__.__name__ == "Session"
|
||||
|
||||
def test__describe_hub__(self):
|
||||
# Set partition for the service
|
||||
securityhub = SecurityHub(set_mocked_aws_audit_info([AWS_REGION_EU_WEST_1]))
|
||||
securityhub = SecurityHub(set_mocked_aws_provider([AWS_REGION_EU_WEST_1]))
|
||||
assert len(securityhub.securityhubs) == 1
|
||||
assert (
|
||||
securityhub.securityhubs[0].arn
|
||||
|
||||
Reference in new issue
Block a user