feat(aws): add custom exceptions class (#4847)

This commit is contained in:
Pedro Martín
2024-08-29 19:08:47 +02:00
committed by GitHub
parent 82c065bff4
commit b29f99441a
11 changed files with 438 additions and 133 deletions
+4 -3
View File
@@ -6,6 +6,7 @@ from mock import patch
from prowler.lib.cli.parser import ProwlerArgumentParser
from prowler.providers.aws.config import ROLE_SESSION_NAME
from prowler.providers.aws.exceptions.exceptions import AWSArgumentTypeValidationError
from prowler.providers.aws.lib.arguments.arguments import (
validate_bucket,
validate_role_session_name,
@@ -1325,13 +1326,13 @@ class Test_Parser:
"role-name?",
]
for role_name in bad_role_names:
with pytest.raises(ArgumentTypeError) as argument_error:
with pytest.raises(AWSArgumentTypeValidationError) as argument_error:
validate_role_session_name(role_name)
assert argument_error.type == ArgumentTypeError
assert argument_error.type == AWSArgumentTypeValidationError
assert (
argument_error.value.args[0]
== "Role Session Name must be 2-64 characters long and consist only of upper- and lower-case alphanumeric characters with no spaces. You can also include underscores or any of the following characters: =,.@-"
== "[1905] AWS argument type validation error - Role Session Name must be between 2 and 64 characters and may contain alphanumeric characters, periods, hyphens, and underscores."
)
def test_validate_role_session_name_valid_role_names(self):