-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PYTHON-3716 OIDC-SASL Follow-Up #1365
Changes from 36 commits
37e55b0
c52e10a
1b87e6a
69346bc
2971708
8426412
6cb708a
2ea10a2
4a2b10a
b40fab8
b5aae77
f1aa532
89bf558
bd7953d
7cf158f
1c39d65
4b1eb82
50186ff
5828512
3ddd737
9ae811e
96bf593
7109a47
47e3dea
9ad53d2
6dde30e
0e2de59
7226e0e
bffa4a8
501ae19
4bfa368
7a15bd0
f2bbacf
41a7a7d
c746b6d
b8fdaa3
3c614b0
2a6d315
237b273
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,48 @@ | ||
#!/bin/bash | ||
|
||
set -o xtrace | ||
set -o xtrace # Trace outputs. | ||
set -o errexit # Exit the script with error if any of the commands fail | ||
|
||
############################################ | ||
# Main Program # | ||
############################################ | ||
|
||
# Supported/used environment variables: | ||
# MONGODB_URI Set the URI, including an optional username/password to use | ||
# to connect to the server via MONGODB-OIDC authentication | ||
# mechanism. | ||
# PYTHON_BINARY The Python version to use. | ||
|
||
echo "Running MONGODB-OIDC authentication tests" | ||
# ensure no secrets are printed in log files | ||
set +x | ||
|
||
# load the script | ||
shopt -s expand_aliases # needed for `urlencode` alias | ||
[ -s "${PROJECT_DIRECTORY}/prepare_mongodb_oidc.sh" ] && source "${PROJECT_DIRECTORY}/prepare_mongodb_oidc.sh" | ||
|
||
MONGODB_URI=${MONGODB_URI:-"mongodb://localhost"} | ||
MONGODB_URI_SINGLE="${MONGODB_URI}/?authMechanism=MONGODB-OIDC" | ||
MONGODB_URI_MULTIPLE="${MONGODB_URI}:27018/?authMechanism=MONGODB-OIDC&directConnection=true" | ||
|
||
if [ -z "${OIDC_TOKEN_DIR}" ]; then | ||
echo "Must specify OIDC_TOKEN_DIR" | ||
# Make sure DRIVERS_TOOLS is set. | ||
if [ -z "$DRIVERS_TOOLS" ]; then | ||
echo "Must specify DRIVERS_TOOLS" | ||
exit 1 | ||
fi | ||
|
||
export MONGODB_URI_SINGLE="$MONGODB_URI_SINGLE" | ||
export MONGODB_URI_MULTIPLE="$MONGODB_URI_MULTIPLE" | ||
export MONGODB_URI="$MONGODB_URI" | ||
|
||
echo $MONGODB_URI_SINGLE | ||
echo $MONGODB_URI_MULTIPLE | ||
echo $MONGODB_URI | ||
# Get the drivers secrets. Use an existing secrets file first. | ||
if [ ! -f "./secrets-export.sh" ]; then | ||
bash .evergreen/tox.sh -m aws-secrets -- drivers/oidc | ||
fi | ||
source ./secrets-export.sh | ||
|
||
if [ "$ASSERT_NO_URI_CREDS" = "true" ]; then | ||
if echo "$MONGODB_URI" | grep -q "@"; then | ||
echo "MONGODB_URI unexpectedly contains user credentials!"; | ||
exit 1 | ||
fi | ||
# # If the file did not have our creds, get them from the vault. | ||
if [ -z "$OIDC_ATLAS_URI_SINGLE" ]; then | ||
bash .evergreen/tox.sh -m aws-secrets -- drivers/oidc | ||
source ./secrets-export.sh | ||
fi | ||
|
||
if [ -z "$PYTHON_BINARY" ]; then | ||
echo "Cannot test without specifying PYTHON_BINARY" | ||
exit 1 | ||
# Make the OIDC tokens. | ||
set -x | ||
pushd ${DRIVERS_TOOLS}/.evergreen/auth_oidc | ||
. ./oidc_get_tokens.sh | ||
popd | ||
|
||
# Set up variables and run the test. | ||
if [ -n "$LOCAL_OIDC_SERVER" ]; then | ||
export MONGODB_URI=${MONGODB_URI:-"mongodb://localhost"} | ||
export MONGODB_URI_SINGLE="${MONGODB_URI}/?authMechanism=MONGODB-OIDC" | ||
export MONGODB_URI_MULTI="${MONGODB_URI}:27018/?authMechanism=MONGODB-OIDC&directConnection=true" | ||
else | ||
set +x # turn off xtrace for this portion | ||
export MONGODB_URI="$OIDC_ATLAS_URI_SINGLE" | ||
export MONGODB_URI_SINGLE="$OIDC_ATLAS_URI_SINGLE/?authMechanism=MONGODB-OIDC" | ||
export MONGODB_URI_MULTI="$OIDC_ATLAS_URI_MULTI/?authMechanism=MONGODB-OIDC" | ||
set -x | ||
fi | ||
|
||
export TEST_AUTH_OIDC=1 | ||
export COVERAGE=1 | ||
export AUTH="auth" | ||
export SET_XTRACE_ON=1 | ||
bash ./.evergreen/tox.sh -m test-eg |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,9 @@ if [ "$AUTH" != "noauth" ]; then | |
elif [ ! -z "$TEST_SERVERLESS" ]; then | ||
export DB_USER=$SERVERLESS_ATLAS_USER | ||
export DB_PASSWORD=$SERVERLESS_ATLAS_PASSWORD | ||
elif [ ! -z "$TEST_AUTH_OIDC" ]; then | ||
export DB_USER=$OIDC_ALTAS_USER | ||
export DB_PASSWORD=$OIDC_ATLAS_PASSWORD | ||
else | ||
export DB_USER="bob" | ||
export DB_PASSWORD="pwd123" | ||
|
@@ -109,7 +112,7 @@ fi | |
if [ -n "$TEST_ENCRYPTION" ] || [ -n "$TEST_FLE_AZURE_AUTO" ] || [ -n "$TEST_FLE_GCP_AUTO" ]; then | ||
|
||
# Work around for root certifi not being installed. | ||
# TODO: Remove after PYTHON-3827 | ||
# TODO: Remove after PYTHON-3952 | ||
if [ "$(uname -s)" = "Darwin" ]; then | ||
python -m pip install certifi | ||
CERT_PATH=$(python -c "import certifi; print(certifi.where())") | ||
|
@@ -224,7 +227,18 @@ fi | |
|
||
if [ -n "$TEST_AUTH_OIDC" ]; then | ||
python -m pip install ".[aws]" | ||
TEST_ARGS="test/auth_aws/test_auth_oidc.py" | ||
|
||
# Work around for root certifi not being installed. | ||
# TODO: Remove after PYTHON-3952 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be removed now? If not can we open a new ticket so we don't forget? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to say "is deployed", I still need to coordinate that. |
||
if [ "$(uname -s)" = "Darwin" ]; then | ||
python -m pip install certifi | ||
CERT_PATH=$(python -c "import certifi; print(certifi.where())") | ||
export SSL_CERT_FILE=${CERT_PATH} | ||
export REQUESTS_CA_BUNDLE=${CERT_PATH} | ||
export AWS_CA_BUNDLE=${CERT_PATH} | ||
fi | ||
|
||
TEST_ARGS="test/auth_oidc/test_auth_oidc.py" | ||
fi | ||
|
||
if [ -n "$PERF_TEST" ]; then | ||
|
@@ -255,6 +269,9 @@ fi | |
# Show the installed packages | ||
PIP_QUIET=0 python -m pip list | ||
|
||
python -c "import urllib.request;urllib.request.urlopen('https://www.google.com')" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the purpose of this line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was for debugging, fixed |
||
exit 0 | ||
|
||
if [ -z "$GREEN_FRAMEWORK" ]; then | ||
if [ -z "$C_EXTENSIONS" ] && [ "$PYTHON_IMPL" = "CPython" ]; then | ||
python setup.py build_ext -i | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this
source
be under aset +x
for safety?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done