mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 13:01:56 +00:00
fix(connection): return Connection on generic exception (#5636)
This commit is contained in:
@@ -1262,7 +1262,9 @@ class AwsProvider(Provider):
|
||||
logger.critical(
|
||||
f"{error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
raise error
|
||||
if raise_on_exception:
|
||||
raise error
|
||||
return Connection(error=error)
|
||||
|
||||
@staticmethod
|
||||
def create_sts_session(
|
||||
|
||||
@@ -1443,6 +1443,18 @@ aws:
|
||||
)
|
||||
assert connection.error.code == 1015
|
||||
|
||||
@mock_aws
|
||||
def test_test_connection_generic_exception(self):
|
||||
with patch(
|
||||
"prowler.providers.aws.aws_provider.AwsProvider.setup_session",
|
||||
side_effect=Exception(),
|
||||
):
|
||||
connection = AwsProvider.test_connection(raise_on_exception=False)
|
||||
|
||||
assert isinstance(connection, Connection)
|
||||
assert not connection.is_connected
|
||||
assert isinstance(connection.error, Exception)
|
||||
|
||||
@mock_aws
|
||||
def test_create_sts_session(self):
|
||||
current_session = session.Session()
|
||||
|
||||
Reference in New Issue
Block a user