Skip to content

Commit b4a1e06

Browse files
committed
Various corrections and simplifications
1 parent 05d9740 commit b4a1e06

File tree

3 files changed

+69
-56
lines changed

3 files changed

+69
-56
lines changed

build.cake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ Task("TestX509")
261261
action: (BuildConfig buildConfig, Path testProject) =>
262262
RunTests(buildConfig, testProject, filter: "Category=\"X509\""));
263263

264+
Task("TestX509Net60").IsDependentOn("TestX509");
265+
264266
Task("Package")
265267
.IsDependentOn("PackageNugetPackages");
266268

evergreen/convert-client-cert-to-pkcs12.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,29 @@
22

33
set -o errexit # Exit the script with an error if any of the commands fail
44

5-
# Input environment variables
6-
: "${CLIENT_PEM_VAR_NAME:="CLIENT_PEM"}" # Name of the input variable for the client.pem file
7-
: "${OUTPUT_VAR_PREFIX:="MONGO_X509_CLIENT"}" # Prefix for output environment variables
8-
: "${FRIENDLY_NAME:="Drivers Client Certificate"}" # Friendly name for the exported certificate
5+
# Environment variables used as input:
6+
# CLIENT_PEM Path to mongo client.pem: must be set
7+
# P12_FILENAME Filename for client certificate in p12 format
8+
# P12_PASSWORD Password for client certificate in p12 format
9+
# FRIENDLY_NAME Friendly name for client certificate in p12 format
10+
# OUT_CLIENT_PATH_VAR Name of the output variable containing the path of the p12 certificate
11+
# OUT_CLIENT_PASSWORD_VAR Name of the output variable containing the password for the p12 certificate
12+
#
13+
# Environment variables produced as output:
14+
# {!OUT_CLIENT_PATH_VAR} Absolute path to client certificate in p12 format (OUT_CLIENT_PATH_VAR contains the actual variable being exported)
15+
# {!OUT_CLIENT_PASSWORD_VAR} Password for client certificate (OUT_CLIENT_PASSWORD_VAR contains the actual variable being exported)
16+
17+
18+
# Input environment variables and default values
19+
: "${CLIENT_PEM:=nil}"
20+
: "${FRIENDLY_NAME:="Drivers Client Certificate"}"
921
: "${P12_FILENAME:="client.p12"}"
1022
: "${P12_PASSWORD:="Picard-Alpha-Alpha-3-0-5"}"
11-
: "${OUT_CLIENT_PASSWORD_VAR:="MONGO_X509_CLIENT_CERTIFICATE_PASSWORD"}"
1223
: "${OUT_CLIENT_PATH_VAR:="MONGO_X509_CLIENT_CERTIFICATE_PATH"}"
13-
14-
CLIENT_PEM=${!CLIENT_PEM_VAR_NAME:-nil}
24+
: "${OUT_CLIENT_PASSWORD_VAR:="MONGO_X509_CLIENT_CERTIFICATE_PASSWORD"}"
1525

1626
if [[ "$CLIENT_PEM" == "nil" ]]; then
17-
echo "Error: ${CLIENT_PEM_VAR_NAME} must be set."
27+
echo "Error: CLIENT_PEM must be set."
1828
exit 1
1929
fi
2030

@@ -46,6 +56,7 @@ if [[ "$OS" =~ Windows|windows ]]; then
4656
CERT_PATH=$(cygpath -w "${CERT_PATH}")
4757
fi
4858

59+
# Output environment variables
4960
export "${OUT_CLIENT_PASSWORD_VAR}"="${P12_PASSWORD}"
5061
export "${OUT_CLIENT_PATH_VAR}"="${CERT_PATH}"
5162

evergreen/evergreen.yml

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -359,48 +359,6 @@ functions:
359359
cd ${DRIVERS_TOOLS}/.evergreen
360360
DRIVERS_TOOLS=${DRIVERS_TOOLS} MONGODB_URI=${MONGODB_URI} bash ${DRIVERS_TOOLS}/.evergreen/run-load-balancer.sh stop
361361
362-
363-
setup-x509-tests:
364-
- command: shell.exec
365-
params:
366-
shell: "bash"
367-
include_expansions_in_env:
368-
- "AWS_ACCESS_KEY_ID"
369-
- "AWS_SECRET_ACCESS_KEY"
370-
- "AWS_SESSION_TOKEN"
371-
script: |
372-
${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/atlas_connect
373-
source secrets-export.sh
374-
375-
echo $ATLAS_X509_DEV_CERT_BASE64 | base64 --decode > ${DRIVERS_TOOLS}/CLIENT_CERT.pem
376-
echo $ATLAS_X509_DEV_CERT_NOUSER_BASE64 | base64 --decode > ${DRIVERS_TOOLS}/CLIENT_NO_USER_CERT.pem
377-
378-
run-x509-tests:
379-
- command: shell.exec
380-
type: test
381-
params:
382-
shell: "bash"
383-
working_dir: mongo-csharp-driver
384-
script: |
385-
source ../secrets-export.sh
386-
${PREPARE_SHELL}
387-
OS=${OS} \
388-
evergreen/add-ca-certs.sh
389-
CLIENT_PEM_VAR_NAME="CLIENT_NO_USER_PEM" \
390-
FRIENDLY_NAME="Drivers No-User Client Certificate" \
391-
P12_FILENAME="client_no_user.p12" \
392-
OUT_CLIENT_PASSWORD_VAR="MONGO_X509_CLIENT_NO_USER_CERTIFICATE_PASSWORD" \
393-
OUT_CLIENT_PATH_VAR="MONGO_X509_CLIENT_NO_USER_CERTIFICATE_PATH" \
394-
CLIENT_NO_USER_PEM=${DRIVERS_TOOLS}/CLIENT_NO_USER_CERT.pem \
395-
source evergreen/convert-client-cert-to-pkcs12.sh
396-
MONGODB_URI="$ATLAS_X509_DEV" \
397-
CLIENT_PEM=${DRIVERS_TOOLS}/CLIENT_CERT.pem \
398-
TOPOLOGY=${TOPOLOGY} \
399-
OS=${OS} \
400-
FRAMEWORK=${FRAMEWORK} \
401-
TARGET="TestX509" \
402-
evergreen/run-tests.sh
403-
404362
run-unit-tests:
405363
- command: shell.exec
406364
type: test
@@ -1071,6 +1029,46 @@ functions:
10711029
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/run-driver-test.sh
10721030
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/teardown-pod.sh
10731031
1032+
setup-x509-tests:
1033+
- command: shell.exec
1034+
params:
1035+
shell: "bash"
1036+
include_expansions_in_env:
1037+
- "AWS_ACCESS_KEY_ID"
1038+
- "AWS_SECRET_ACCESS_KEY"
1039+
- "AWS_SESSION_TOKEN"
1040+
script: |
1041+
${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/atlas_connect
1042+
source secrets-export.sh
1043+
1044+
echo $ATLAS_X509_DEV_CERT_BASE64 | base64 --decode > ${DRIVERS_TOOLS}/CLIENT_CERT.pem
1045+
echo $ATLAS_X509_DEV_CERT_NOUSER_BASE64 | base64 --decode > ${DRIVERS_TOOLS}/CLIENT_NO_USER_CERT.pem
1046+
1047+
run-x509-tests:
1048+
- command: shell.exec
1049+
type: test
1050+
params:
1051+
shell: "bash"
1052+
working_dir: mongo-csharp-driver
1053+
script: |
1054+
source ../secrets-export.sh
1055+
${PREPARE_SHELL}
1056+
OS=${OS} \
1057+
evergreen/add-ca-certs.sh
1058+
FRIENDLY_NAME="Drivers No-User Client Certificate" \
1059+
P12_FILENAME="client_no_user.p12" \
1060+
OUT_CLIENT_PASSWORD_VAR="MONGO_X509_CLIENT_NO_USER_CERTIFICATE_PASSWORD" \
1061+
OUT_CLIENT_PATH_VAR="MONGO_X509_CLIENT_NO_USER_CERTIFICATE_PATH" \
1062+
CLIENT_PEM=${DRIVERS_TOOLS}/CLIENT_NO_USER_CERT.pem \
1063+
source evergreen/convert-client-cert-to-pkcs12.sh
1064+
MONGODB_URI="$ATLAS_X509_DEV" \
1065+
CLIENT_PEM=${DRIVERS_TOOLS}/CLIENT_CERT.pem \
1066+
TOPOLOGY=${TOPOLOGY} \
1067+
OS=${OS} \
1068+
FRAMEWORK=${FRAMEWORK} \
1069+
TARGET="TestX509" \
1070+
evergreen/run-tests.sh
1071+
10741072
pre:
10751073
- func: fetch-source
10761074
- func: prepare-resources
@@ -1261,12 +1259,6 @@ tasks:
12611259
- func: run-aws-auth-test-with-aws-ECS-credentials
12621260
- func: run-aws-auth-test-with-aws-web-identity-credentials
12631261

1264-
- name: x509-auth-tests
1265-
commands:
1266-
- func: assume-ec2-role
1267-
- func: setup-x509-tests
1268-
- func: run-x509-tests
1269-
12701262
- name: stable-api-tests-net472
12711263
commands:
12721264
- func: setup-csfle-secrets
@@ -1765,6 +1757,14 @@ tasks:
17651757
${PREPARE_SHELL}
17661758
CRYPT_SHARED_LIB_PATH="${CRYPT_SHARED_LIB_PATH}" DRIVER_VERSION="${PACKAGE_VERSION}" MONGODB_VERSION="${VERSION}" bash ./evergreen/run-tests.sh
17671759
1760+
- name: x509-auth-tests
1761+
commands:
1762+
- func: assume-ec2-role
1763+
- func: setup-x509-tests
1764+
- func: run-x509-tests
1765+
vars:
1766+
FRAMEWORK: net60
1767+
17681768
axes:
17691769
- id: version
17701770
display_name: MongoDB Version

0 commit comments

Comments
 (0)