Skip to content

Commit a017e94

Browse files
committed
Remove legacy shell from test scripts
The legacy shell was only used in AWS authentication tests, so updating those gets rid of the last remaining use of the legacy shell. JAVA-4791
1 parent 2412cbd commit a017e94

File tree

2 files changed

+29
-188
lines changed

2 files changed

+29
-188
lines changed

.evergreen/.evg.yml

Lines changed: 27 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ functions:
154154
${PREPARE_SHELL}
155155
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} LOAD_BALANCER=${LOAD_BALANCER} MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} \
156156
AUTH=${AUTH} SSL=${SSL} STORAGE_ENGINE=${STORAGE_ENGINE} ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
157-
INSTALL_LEGACY_SHELL=${INSTALL_LEGACY_SHELL} bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
157+
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
158158
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
159159
- command: expansions.update
160160
params:
@@ -346,241 +346,100 @@ functions:
346346
JAVA_VERSION="8" MONGODB_URI="${plain_auth_mongodb_uri}" .evergreen/run-plain-auth-test.sh
347347
348348
"add aws auth variables to file":
349+
- command: ec2.assume_role
350+
params:
351+
role_arn: ${aws_test_secrets_role}
349352
- command: shell.exec
350353
type: test
351354
params:
355+
include_expansions_in_env: [ "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN" ]
356+
shell: "bash"
352357
working_dir: "src"
353-
silent: true
354358
script: |
355-
cat <<EOF > ${DRIVERS_TOOLS}/.evergreen/auth_aws/aws_e2e_setup.json
356-
{
357-
"iam_auth_ecs_account" : "${iam_auth_ecs_account}",
358-
"iam_auth_ecs_secret_access_key" : "${iam_auth_ecs_secret_access_key}",
359-
"iam_auth_ecs_account_arn": "arn:aws:iam::557821124784:user/authtest_fargate_user",
360-
"iam_auth_ecs_cluster": "${iam_auth_ecs_cluster}",
361-
"iam_auth_ecs_task_definition": "${iam_auth_ecs_task_definition}",
362-
"iam_auth_ecs_subnet_a": "${iam_auth_ecs_subnet_a}",
363-
"iam_auth_ecs_subnet_b": "${iam_auth_ecs_subnet_b}",
364-
"iam_auth_ecs_security_group": "${iam_auth_ecs_security_group}",
365-
366-
"iam_auth_assume_aws_account" : "${iam_auth_assume_aws_account}",
367-
"iam_auth_assume_aws_secret_access_key" : "${iam_auth_assume_aws_secret_access_key}",
368-
"iam_auth_assume_role_name" : "${iam_auth_assume_role_name}",
369-
370-
"iam_auth_ec2_instance_account" : "${iam_auth_ec2_instance_account}",
371-
"iam_auth_ec2_instance_secret_access_key" : "${iam_auth_ec2_instance_secret_access_key}",
372-
"iam_auth_ec2_instance_profile" : "${iam_auth_ec2_instance_profile}",
373-
374-
"iam_auth_assume_web_role_name": "${iam_auth_assume_web_role_name}",
375-
"iam_web_identity_issuer": "${iam_web_identity_issuer}",
376-
"iam_web_identity_rsa_key": "${iam_web_identity_rsa_key}",
377-
"iam_web_identity_jwks_uri": "${iam_web_identity_jwks_uri}",
378-
"iam_web_identity_token_file": "${iam_web_identity_token_file}"
379-
}
380-
EOF
359+
${PREPARE_SHELL}
360+
cd $DRIVERS_TOOLS/.evergreen/auth_aws
361+
./setup_secrets.sh drivers/aws_auth
381362
382363
"run aws auth test with regular aws credentials":
383364
- command: shell.exec
384365
type: test
385366
params:
386-
working_dir: "src"
387367
shell: "bash"
388-
script: |
389-
${PREPARE_SHELL}
390-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
391-
. ./activate-authawsvenv.sh
392-
mongo aws_e2e_regular_aws.js
393-
- command: shell.exec
394-
type: test
395-
params:
396368
working_dir: "src"
397-
silent: true
398369
script: |
399-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
400-
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
401-
USER=$(urlencode ${iam_auth_ecs_account})
402-
PASS=$(urlencode ${iam_auth_ecs_secret_access_key})
403-
MONGODB_URI="mongodb://$USER:$PASS@localhost"
404-
EOF
405-
JAVA_VERSION=${JAVA_VERSION} PROJECT_DIRECTORY=${PROJECT_DIRECTORY} \
406-
AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} \
407-
.evergreen/run-mongodb-aws-test.sh
370+
${PREPARE_SHELL}
371+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh regular
408372
409373
"run aws auth test with assume role credentials":
410374
- command: shell.exec
411375
type: test
412376
params:
413-
working_dir: "src"
414377
shell: "bash"
415-
script: |
416-
${PREPARE_SHELL}
417-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
418-
. ./activate-authawsvenv.sh
419-
mongo aws_e2e_assume_role.js
420-
- command: shell.exec
421-
type: test
422-
params:
423378
working_dir: "src"
424-
silent: true
425379
script: |
426-
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
427-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
428-
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
429-
USER=$(jq -r '.AccessKeyId' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
430-
USER=$(urlencode $USER)
431-
PASS=$(jq -r '.SecretAccessKey' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
432-
PASS=$(urlencode $PASS)
433-
SESSION_TOKEN=$(jq -r '.SessionToken' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
434-
SESSION_TOKEN=$(urlencode $SESSION_TOKEN)
435-
MONGODB_URI="mongodb://$USER:$PASS@localhost"
436-
EOF
437-
JAVA_VERSION=${JAVA_VERSION} PROJECT_DIRECTORY=${PROJECT_DIRECTORY} DRIVERS_TOOLS=${DRIVERS_TOOLS} \
438-
AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} \
439-
.evergreen/run-mongodb-aws-test.sh
380+
${PREPARE_SHELL}
381+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh assume-role
440382
441383
"run aws auth test with aws EC2 credentials":
442384
- command: shell.exec
443385
type: test
444386
params:
445-
working_dir: "src"
446387
shell: "bash"
447-
script: |
448-
${PREPARE_SHELL}
449-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
450-
. ./activate-authawsvenv.sh
451-
mongo aws_e2e_ec2.js
452-
- command: shell.exec
453-
type: test
454-
params:
455388
working_dir: "src"
456-
shell: "bash"
457389
script: |
458390
${PREPARE_SHELL}
459-
# Write an empty prepare_mongodb_aws so no auth environment variables are set.
460-
echo "" > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
461-
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh
391+
if [ "${SKIP_EC2_AUTH_TEST}" = "true" ]; then
392+
echo "This platform does not support the EC2 auth test, skipping..."
393+
exit 0
394+
fi
395+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh ec2
462396
463397
"run aws auth test with web identity credentials":
464398
- command: shell.exec
465399
type: test
466400
params:
467-
working_dir: "src"
468-
shell: "bash"
469-
script: |
470-
${PREPARE_SHELL}
471-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
472-
. ./activate-authawsvenv.sh
473-
mongo aws_e2e_web_identity.js
474-
- command: shell.exec
475-
type: test
476-
params:
477-
working_dir: "src"
478401
shell: "bash"
479-
silent: true
480-
script: |
481-
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
482-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
483-
export AWS_ROLE_ARN="${iam_auth_assume_web_role_name}"
484-
export AWS_WEB_IDENTITY_TOKEN_FILE="${iam_web_identity_token_file}"
485-
EOF
486-
- command: shell.exec
487-
type: test
488-
params:
489402
working_dir: "src"
490-
shell: "bash"
491403
script: |
492404
${PREPARE_SHELL}
493-
if [ "${AWS_CREDENTIAL_PROVIDER}" = "builtIn" ]; then
494-
echo "Built-in AWS credential provider does not support the web identity auth test, skipping..."
405+
if [ "${SKIP_WEB_IDENTITY_AUTH_TEST}" = "true" ]; then
406+
echo "This platform does not support the web identity auth test, skipping..."
495407
exit 0
496408
fi
497-
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} ASSERT_NO_URI_CREDS=true .evergreen/run-mongodb-aws-test.sh
409+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh web-identity
498410
- command: shell.exec
499411
type: test
500412
params:
501-
working_dir: "src"
502413
shell: "bash"
503-
silent: true
504-
script: |
505-
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
506-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
507-
export AWS_ROLE_ARN="${iam_auth_assume_web_role_name}"
508-
export AWS_WEB_IDENTITY_TOKEN_FILE="${iam_web_identity_token_file}"
509-
export AWS_ROLE_SESSION_NAME="test"
510-
EOF
511-
- command: shell.exec
512-
type: test
513-
params:
514414
working_dir: "src"
515-
shell: "bash"
516415
script: |
517416
${PREPARE_SHELL}
518-
if [ "${AWS_CREDENTIAL_PROVIDER}" = "builtIn" ]; then
519-
echo "Built-in AWS credential provider does not support the web identity auth test, skipping..."
417+
if [ "${SKIP_WEB_IDENTITY_AUTH_TEST}" = "true" ]; then
418+
echo "This platform does not support the web identity auth test, skipping..."
520419
exit 0
521420
fi
522-
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} ASSERT_NO_URI_CREDS=true .evergreen/run-mongodb-aws-test.sh
421+
export AWS_ROLE_SESSION_NAME="test"
422+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh web-identity
523423
524424
"run aws auth test with aws credentials as environment variables":
525425
- command: shell.exec
526426
type: test
527427
params:
528-
working_dir: "src"
529428
shell: "bash"
530-
script: |
531-
${PREPARE_SHELL}
532-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
533-
. ./activate-authawsvenv.sh
534-
mongo aws_e2e_regular_aws.js
535-
- command: shell.exec
536-
type: test
537-
params:
538-
working_dir: "src"
539-
silent: true
540-
script: |
541-
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
542-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
543-
export AWS_ACCESS_KEY_ID=${iam_auth_ecs_account}
544-
export AWS_SECRET_ACCESS_KEY=${iam_auth_ecs_secret_access_key}
545-
EOF
546-
- command: shell.exec
547-
type: test
548-
params:
549429
working_dir: "src"
550430
script: |
551431
${PREPARE_SHELL}
552-
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh
432+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh env-creds
553433
554434
"run aws auth test with aws credentials and session token as environment variables":
555435
- command: shell.exec
556436
type: test
557437
params:
558-
working_dir: "src"
559438
shell: "bash"
560-
script: |
561-
${PREPARE_SHELL}
562-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
563-
. ./activate-authawsvenv.sh
564-
mongo aws_e2e_assume_role.js
565-
- command: shell.exec
566-
type: test
567-
params:
568-
working_dir: "src"
569-
silent: true
570-
script: |
571-
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
572-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
573-
export AWS_ACCESS_KEY_ID=$(jq -r '.AccessKeyId' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
574-
export AWS_SECRET_ACCESS_KEY=$(jq -r '.SecretAccessKey' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
575-
export AWS_SESSION_TOKEN=$(jq -r '.SessionToken' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
576-
EOF
577-
- command: shell.exec
578-
type: test
579-
params:
580439
working_dir: "src"
581440
script: |
582441
${PREPARE_SHELL}
583-
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh
442+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh session-creds
584443
585444
"run aws ECS auth test":
586445
- command: shell.exec
@@ -1063,7 +922,6 @@ tasks:
1063922
AUTH: "auth"
1064923
ORCHESTRATION_FILE: "auth-aws.json"
1065924
TOPOLOGY: "server"
1066-
INSTALL_LEGACY_SHELL: "true"
1067925
- func: "add aws auth variables to file"
1068926
- func: "run aws auth test with regular aws credentials"
1069927

@@ -1074,7 +932,6 @@ tasks:
1074932
AUTH: "auth"
1075933
ORCHESTRATION_FILE: "auth-aws.json"
1076934
TOPOLOGY: "server"
1077-
INSTALL_LEGACY_SHELL: "true"
1078935
- func: "add aws auth variables to file"
1079936
- func: "run aws auth test with assume role credentials"
1080937

@@ -1085,7 +942,6 @@ tasks:
1085942
AUTH: "auth"
1086943
ORCHESTRATION_FILE: "auth-aws.json"
1087944
TOPOLOGY: "server"
1088-
INSTALL_LEGACY_SHELL: "true"
1089945
- func: "add aws auth variables to file"
1090946
- func: "run aws auth test with aws credentials as environment variables"
1091947

@@ -1096,7 +952,6 @@ tasks:
1096952
AUTH: "auth"
1097953
ORCHESTRATION_FILE: "auth-aws.json"
1098954
TOPOLOGY: "server"
1099-
INSTALL_LEGACY_SHELL: "true"
1100955
- func: "add aws auth variables to file"
1101956
- func: "run aws auth test with aws credentials and session token as environment variables"
1102957

@@ -1107,7 +962,6 @@ tasks:
1107962
AUTH: "auth"
1108963
ORCHESTRATION_FILE: "auth-aws.json"
1109964
TOPOLOGY: "server"
1110-
INSTALL_LEGACY_SHELL: "true"
1111965
- func: "add aws auth variables to file"
1112966
- func: "run aws auth test with aws EC2 credentials"
1113967

@@ -1118,7 +972,6 @@ tasks:
1118972
AUTH: "auth"
1119973
ORCHESTRATION_FILE: "auth-aws.json"
1120974
TOPOLOGY: "server"
1121-
INSTALL_LEGACY_SHELL: "true"
1122975
- func: "add aws auth variables to file"
1123976
- func: "run aws auth test with web identity credentials"
1124977

@@ -1129,7 +982,6 @@ tasks:
1129982
AUTH: "auth"
1130983
ORCHESTRATION_FILE: "auth-aws.json"
1131984
TOPOLOGY: "server"
1132-
INSTALL_LEGACY_SHELL: "true"
1133985
- func: "add aws auth variables to file"
1134986
- func: "run aws ECS auth test"
1135987

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,8 @@ RELATIVE_DIR_PATH="$(dirname "${BASH_SOURCE:-$0}")"
1515

1616
echo "Running MONGODB-AWS authentication tests"
1717

18-
19-
# ensure no secrets are printed in log files
20-
set +x
21-
22-
# load the script
23-
shopt -s expand_aliases # needed for `urlencode` alias
24-
[ -s "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh" ] && source "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
25-
26-
MONGODB_URI=${MONGODB_URI:-"mongodb://localhost"}
27-
MONGODB_URI="${MONGODB_URI}/aws?authMechanism=MONGODB-AWS"
28-
if [[ -n ${SESSION_TOKEN} ]]; then
29-
MONGODB_URI="${MONGODB_URI}&authMechanismProperties=AWS_SESSION_TOKEN:${SESSION_TOKEN}"
30-
fi
18+
# Handle credentials and environment setup.
19+
. $DRIVERS_TOOLS/.evergreen/auth_aws/aws_setup.sh $1
3120

3221
# show test output
3322
set -x

0 commit comments

Comments
 (0)