aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_secrets_manager.py
diff options
context:
space:
mode:
authorlian-manonog <160282780+lian-manonog@users.noreply.github.com>2024-08-15 14:00:20 +0100
committerGitHub <noreply@github.com>2024-08-15 14:00:20 +0100
commit7642266611b370b6e945e132c8e7b26c8d6fe9f3 (patch)
tree1bdebb2046a9b1356faa2fe902d9187601ecb3f7 /test/test_secrets_manager.py
parent269422a158f8da80675c8b8331868be95952505c (diff)
parent2309062a8099c04bedd7f88638abf03ebf5f5171 (diff)
downloadde-project-bentley-7642266611b370b6e945e132c8e7b26c8d6fe9f3.tar.gz
de-project-bentley-7642266611b370b6e945e132c8e7b26c8d6fe9f3.zip
Merge pull request #34 from ajschofield/feature-extract-lambda-data-extraction
PR: merge feature-lambda to dev branch
Diffstat (limited to 'test/test_secrets_manager.py')
-rw-r--r--test/test_secrets_manager.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/test_secrets_manager.py b/test/test_secrets_manager.py
new file mode 100644
index 0000000..86533bc
--- /dev/null
+++ b/test/test_secrets_manager.py
@@ -0,0 +1,34 @@
+from src.secrets_manager import sm_client, create_secret, list_secret
+import boto3
+from moto import mock_aws
+import json
+import pytest
+import os
+
+pytest.fixture(scope='class')
+def mock_aws_credentials():
+ """Mocked AWS Credentials for moto."""
+ os.environ["AWS_ACCESS_KEY_ID"] = "testing"
+ os.environ["AWS_SECRET_ACCESS_KEY"] = "testing"
+ os.environ["AWS_SECURITY_TOKEN"] = "testing"
+ os.environ["AWS_SESSION_TOKEN"] = "testing"
+ os.environ["AWS_DEFAULT_REGION"] = "eu-west-2"
+
+@pytest.fixture(scope='class')
+def mock_sm_client(mock_aws_credentials):
+ with mock_aws():
+ yield boto3.client('secretsmanager')
+
+
+def test_create_secret_stores_secrets(mock_sm_client):
+ cohort_id = "test_cohort_id"
+ user = "test_user_id"
+ password = "test_password"
+ host = "test_host"
+ database = "test_database"
+ port = "test_port"
+
+ secret_name = "test_secret"
+ response = create_secret(mock_sm_client, secret_name, cohort_id, user, password, host, database, port)
+
+ assert response['Name'] == secret_name \ No newline at end of file
git.ajschof.me — hosted by ajschofield — powered by cgit