From c5f3f9e077751a69555b0c535d2649f6e17aa63f Mon Sep 17 00:00:00 2001 From: Sofia Sazonova Date: Wed, 2 Oct 2024 15:41:16 +0100 Subject: [PATCH] CICD Integration test: iam client fix (#1604) ### Feature or Bugfix - Bugfix ### Detail - iam client tries to get_role and creates one if it's none. ### Relates - ### Security Please answer the questions below briefly where applicable, or write `N/A`. Based on [OWASP 10](https://owasp.org/Top10/en/). - Does this PR introduce or modify any input fields or queries - this includes fetching data from storage outside the application (e.g. a database, an S3 bucket)? - Is the input sanitized? - What precautions are you taking before deserializing the data you consume? - Is injection prevented by parametrizing queries? - Have you ensured no `eval` or similar functions are used? - Does this PR introduce any functionality or component that requires authorization? - How have you ensured it respects the existing AuthN/AuthZ mechanisms? - Are you logging failed auth attempts? - Are you using or adding any cryptographic features? - Do you use a standard proven implementations? - Are the used keys controlled by the customer? Where are they stored? - Are you introducing any new policies/roles/users? - Have you used the least-privilege principle? How? By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: Sofia Sazonova --- tests_new/integration_tests/aws_clients/iam.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests_new/integration_tests/aws_clients/iam.py b/tests_new/integration_tests/aws_clients/iam.py index 73050c748..1006d3871 100644 --- a/tests_new/integration_tests/aws_clients/iam.py +++ b/tests_new/integration_tests/aws_clients/iam.py @@ -16,8 +16,12 @@ def __init__(self, session=boto3.Session(), region=os.environ.get('AWS_REGION', self._region = region def get_role(self, role_name): - role = self._client.get_role(RoleName=role_name) - return role + try: + role = self._client.get_role(RoleName=role_name) + return role + except self._client.exceptions.NoSuchEntityException as e: + log.info(f'Error occurred: {e}') + return None def delete_role(self, role_name): self._client.delete_role(RoleName=role_name)