From c4299702994cdd55738de4591e85f4dc2a424d19 Mon Sep 17 00:00:00 2001 From: Joao Moreira <13685125+jagmoreira@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:16:34 -0400 Subject: [PATCH] Fix artifactory default aws (#239) * Fix aws default profile call in artifactory auth. * Remove file committed by mistake. --- CHANGELOG.md | 8 ++++++++ VERSION | 2 +- .../components/repository/artifactoryRepo.py | 2 +- ...test_components_repository_artifactoryRepo.py | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdb7bb6..64ffe0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,15 @@ Documenting All Changes to the Skelebot Project --- +## v1.36.1 +#### Changed +- **Artifactory** | Using the default aws profile should pass `None` to boto3 Session. + +--- + ## v1.36.0 +#### Merged: 2023-06-20 +#### Released: 2023-06-20 #### Changed - **Artifactory** | Added support for token and api key methods of Artifactory authentication. Also added support to read authentication credentials from AWS Secrets Manager. diff --git a/VERSION b/VERSION index d70132e..60b0043 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.0 \ No newline at end of file +1.36.1 \ No newline at end of file diff --git a/skelebot/components/repository/artifactoryRepo.py b/skelebot/components/repository/artifactoryRepo.py index ebbf4cb..d8951dc 100644 --- a/skelebot/components/repository/artifactoryRepo.py +++ b/skelebot/components/repository/artifactoryRepo.py @@ -33,7 +33,7 @@ class Auth(SkeleYaml): awsProfile = None awsRegion = None - def __init__(self, authType="user_pass", aws=False, awsSecret="Artifactory", awsProfile="default", + def __init__(self, authType="user_pass", aws=False, awsSecret="Artifactory", awsProfile=None, awsRegion="us-east-1"): """Instantiate the Auth Class Object based on the provided parameters""" self.authType = authType diff --git a/test/test_components_repository_artifactoryRepo.py b/test/test_components_repository_artifactoryRepo.py index b83b65b..4edd1ee 100644 --- a/test/test_components_repository_artifactoryRepo.py +++ b/test/test_components_repository_artifactoryRepo.py @@ -21,6 +21,22 @@ def test_load_aws_credentials(self, mock_boto3_session): mock_session.client.assert_called_with(service_name="secretsmanager", region_name="baz") mock_boto3_session.assert_called_with(profile_name="bar") + @mock.patch('boto3.Session') + def test_load_aws_default_credentials(self, mock_boto3_session): + mock_client = mock.Mock() + mock_session = mock.Mock() + mock_boto3_session.return_value = mock_session + mock_session.client.return_value = mock_client + mock_client.get_secret_value.return_value = {"SecretString": '{"a": 1}'} + + auth = sb.components.repository.artifactoryRepo.Auth(aws=True) + actual_creds = auth.loadAwsCredentials() + + assert actual_creds == {"a": 1} + mock_client.get_secret_value.assert_called_with(SecretId="Artifactory") + mock_session.client.assert_called_with(service_name="secretsmanager", region_name="us-east-1") + mock_boto3_session.assert_called_with(profile_name=None) + @mock.patch('boto3.Session') def test_get_credentials_aws_user_pass(self, mock_boto3_session): mock_client = mock.Mock()