-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from noverde/feat/rename-secrets-module
Rename secrets module
- Loading branch information
Showing
5 changed files
with
14 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
coverage==6.2 | ||
black==21.7b0 | ||
black==22.3.0 | ||
flake8==4.0.1 | ||
|
||
boto3==1.20.26 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,37 @@ | ||
import json | ||
import secrets | ||
import unittest | ||
from unittest.mock import patch | ||
|
||
import secrets_manager | ||
|
||
class TestSecrets(unittest.TestCase): | ||
@patch("secrets.boto3") | ||
|
||
class TestSecretsManager(unittest.TestCase): | ||
@patch("secrets_manager.boto3") | ||
def test_retrieve_secret_value_without_keyname(self, m_boto3): | ||
aws_response = {"SecretString": '{"key": "s3CrE7-V@1u3"}'} | ||
m_boto3.client.return_value.get_secret_value.return_value = aws_response | ||
|
||
secret_value = secrets.get("Secret_Value") | ||
secret_value = secrets_manager.get("Secret_Value") | ||
|
||
self.assertDictEqual(secret_value, json.loads(aws_response["SecretString"])) | ||
self.assertEqual(m_boto3.client.call_count, 1) | ||
|
||
@patch("secrets.boto3") | ||
@patch("secrets_manager.boto3") | ||
def test_retrieve_secret_value_with_invalid_json(self, m_boto3): | ||
aws_response = {"SecretString": "s3CrE7-V@1u3"} | ||
m_boto3.client.return_value.get_secret_value.return_value = aws_response | ||
|
||
secret_value = secrets.get("Another_Secret_Value") | ||
secret_value = secrets_manager.get("Another_Secret_Value") | ||
|
||
self.assertEqual(secret_value, aws_response["SecretString"]) | ||
self.assertEqual(m_boto3.client.call_count, 1) | ||
|
||
@patch("secrets.boto3") | ||
@patch("secrets_manager.boto3") | ||
def test_retrieve_secret_value_with_keyname(self, m_boto3): | ||
aws_response = {"SecretString": '{"key": "s3CrE7-V@1u3"}'} | ||
m_boto3.client.return_value.get_secret_value.return_value = aws_response | ||
|
||
secret_value = secrets.get("Another_Secret_Value", "key") | ||
secret_value = secrets_manager.get("Another_Secret_Value", "key") | ||
|
||
self.assertEqual(secret_value, json.loads(aws_response["SecretString"])["key"]) | ||
self.assertEqual(m_boto3.client.call_count, 1) |