Skip to content

Commit f6323f6

Browse files
committed
DRIVERS-2585 Use AWS Secrets Manager for AWS-Related Test Secrets
1 parent b8c1364 commit f6323f6

File tree

3 files changed

+68
-9
lines changed

3 files changed

+68
-9
lines changed

.evergreen/config.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,29 @@ functions:
792792
python oidc_write_orchestration.py
793793
python oidc_get_tokens.py
794794
795+
"bootstrap aws-secrets":
796+
- command: ec2.assume_role
797+
params:
798+
role_arn: ${aws_test_secrets_role}
799+
- command: shell.exec
800+
type: test
801+
params:
802+
shell: bash
803+
script: |
804+
${PREPARE_SHELL}
805+
if [ "${skip_EC2_auth_test}" = "true" ]; then
806+
echo "This platform does not support aws secrets, skipping..."
807+
exit 0
808+
fi
809+
810+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
811+
python setup_secrets.py
812+
813+
- command: expansions.update
814+
params:
815+
file: secrets-expansion.yml
816+
817+
795818
"run oidc auth test with aws credentials":
796819
- command: shell.exec
797820
type: test

.evergreen/run-mongodb-oidc-test.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set -o errexit # Exit the script with error if any of the commands fail
1515

1616
echo "Running MONGODB-OIDC authentication tests"
1717
# ensure no secrets are printed in log files
18-
set +x
18+
#set +x
1919

2020
# load the script
2121
shopt -s expand_aliases # needed for `urlencode` alias
@@ -49,11 +49,11 @@ fi
4949
set -x
5050

5151
# Workaround macOS python 3.9 incompatibility with system virtualenv.
52-
if [ "$(uname -s)" = "Darwin" ]; then
53-
VIRTUALENV="/Library/Frameworks/Python.framework/Versions/3.9/bin/python3 -m virtualenv"
54-
else
52+
#if [ "$(uname -s)" = "Darwin" ]; then
53+
# VIRTUALENV="/Library/Frameworks/Python.framework/Versions/3.9/bin/python3 -m virtualenv"
54+
#else
5555
VIRTUALENV=$(command -v virtualenv)
56-
fi
56+
#fi
5757

5858
authtest () {
5959
if [ "Windows_NT" = "$OS" ]; then
@@ -71,7 +71,7 @@ authtest () {
7171
fi
7272
python -m pip install -U pip setuptools
7373
python -m pip install '.[aws]'
74-
python test/auth_aws/test_auth_oidc.py -v
74+
pytest -v test/auth_aws/test_auth_oidc.py
7575
deactivate
7676
rm -rf venvoidc
7777
}

tox.ini

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,17 @@ commands =
144144
sphinx-build -E -b linkcheck doc ./doc/_build/linkcheck
145145

146146
[testenv:test-atlas]
147-
description = run atlas connection tests
148147
deps =
149-
{[testenv:test]deps}
148+
PyYAML
149+
boto3
150+
pytest>=7
150151
passenv = *
152+
allowlist_externals =
153+
bash
151154
commands =
152-
python -m pytest -v {posargs} ./test/atlas/test_connection.py
155+
bash -c 'git -C drivers-evergreen-tools pull origin DRIVERS-2585 || git clone -b DRIVERS-2585 https://github.com/NoahStapp/drivers-evergreen-tools.git'
156+
python ./drivers-evergreen-tools/.evergreen/auth_aws/setup_secrets.py drivers/test
157+
bash -c 'source ./secrets-export.sh; python -m pytest -v {posargs} ./test/atlas/test_connection.py'
153158

154159
[testenv:test-mockupdb]
155160
description = run mockupdb tests
@@ -159,3 +164,34 @@ deps =
159164
passenv = *
160165
commands =
161166
python -m pytest -v {posargs} ./test/mockupdb
167+
168+
[testenv:test-aws-secrets]
169+
deps =
170+
PyYAML
171+
boto3
172+
pyjwkest
173+
pyop~=3.4.0
174+
azure-identity
175+
azure-keyvault-secrets
176+
pytest
177+
passenv = *
178+
setenv =
179+
OIDC_TOKEN_DIR=/tmp/tokens
180+
PYTHON_BINARY=python
181+
MONGODB_URI=mongodb+srv://oidc-rapid.oztdp.mongodb-dev.net
182+
MONGODB_URI_SINGLE="mongodb+srv://oidc-rapid.oztdp.mongodb-dev.net/?authMechanism=MONGODB-OIDC"
183+
MONGODB_URI_MULTIPLE="mongodb+srv://oidc-rapid.oztdp.mongodb-dev.net:27018/?authMechanism=MONGODB-OIDC&directConnection=true"
184+
allowlist_externals =
185+
bash
186+
source
187+
echo
188+
commands =
189+
; git clone -b DRIVERS-2585 https://github.com/NoahStapp/drivers-evergreen-tools.git
190+
python ./drivers-evergreen-tools/.evergreen/auth_aws/setup_secrets.py drivers/test
191+
bash ./secrets-export.sh
192+
193+
bash ./drivers-evergreen-tools/.evergreen/auth_oidc/activate-authoidcvenv.sh
194+
python ./drivers-evergreen-tools/.evergreen/auth_oidc/oidc_write_orchestration.py
195+
python ./drivers-evergreen-tools/.evergreen/auth_oidc/oidc_get_tokens.py
196+
197+
bash .evergreen/run-mongodb-oidc-test.sh

0 commit comments

Comments
 (0)