Skip to content

Commit 5876554

Browse files
blink1073pmereditmatthewdale
authored
GODRIVER-3278 Port OIDC machine callback to master (#1712)
Co-authored-by: Patrick Meredith <pmeredit@protonmail.com> Co-authored-by: Matt Dale <9760375+matthewdale@users.noreply.github.com>
1 parent 6f3105a commit 5876554

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2033
-240
lines changed

.evergreen/config.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,23 @@ functions:
350350
chmod +x $i
351351
done
352352
353+
assume-ec2-role:
354+
- command: ec2.assume_role
355+
params:
356+
role_arn: ${aws_test_secrets_role}
357+
358+
run-oidc-auth-test-with-test-credentials:
359+
- command: shell.exec
360+
type: test
361+
params:
362+
working_dir: src/go.mongodb.org/mongo-driver
363+
shell: bash
364+
include_expansions_in_env: ["DRIVERS_TOOLS", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]
365+
script: |
366+
${PREPARE_SHELL}
367+
export OIDC="oidc"
368+
bash ${PROJECT_DIRECTORY}/etc/run-oidc-test.sh
369+
353370
run-make:
354371
- command: shell.exec
355372
type: test
@@ -1949,6 +1966,10 @@ tasks:
19491966
popd
19501967
./.evergreen/run-deployed-lambda-aws-tests.sh
19511968
1969+
- name: "oidc-auth-test-latest"
1970+
commands:
1971+
- func: "run-oidc-auth-test-with-test-credentials"
1972+
19521973
- name: "test-search-index"
19531974
commands:
19541975
- func: "bootstrap-mongo-orchestration"
@@ -2231,6 +2252,31 @@ task_groups:
22312252
tasks:
22322253
- testazurekms-task
22332254

2255+
- name: testoidc_task_group
2256+
setup_group:
2257+
- func: fetch-source
2258+
- func: prepare-resources
2259+
- func: fix-absolute-paths
2260+
- func: make-files-executable
2261+
- func: assume-ec2-role
2262+
- command: shell.exec
2263+
params:
2264+
shell: bash
2265+
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]
2266+
script: |
2267+
${PREPARE_SHELL}
2268+
${DRIVERS_TOOLS}/.evergreen/auth_oidc/setup.sh
2269+
teardown_task:
2270+
- command: subprocess.exec
2271+
params:
2272+
binary: bash
2273+
args:
2274+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/teardown.sh
2275+
setup_group_can_fail_task: true
2276+
setup_group_timeout_secs: 1800
2277+
tasks:
2278+
- oidc-auth-test-latest
2279+
22342280
- name: test-aws-lambda-task-group
22352281
setup_group:
22362282
- func: fetch-source
@@ -2564,3 +2610,13 @@ buildvariants:
25642610
- name: testazurekms_task_group
25652611
batchtime: 20160 # Use a batchtime of 14 days as suggested by the CSFLE test README
25662612
- testazurekms-fail-task
2613+
2614+
- name: testoidc-variant
2615+
display_name: "OIDC"
2616+
run_on:
2617+
- ubuntu2204-large
2618+
expansions:
2619+
GO_DIST: "/opt/golang/go1.20"
2620+
tasks:
2621+
- name: testoidc_task_group
2622+
batchtime: 20160 # Use a batchtime of 14 days as suggested by the CSFLE test README

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ evg-test-atlas-data-lake:
127127
evg-test-enterprise-auth:
128128
go run -tags gssapi ./internal/cmd/testentauth/main.go
129129

130+
.PHONY: evg-test-oidc-auth
131+
evg-test-oidc-auth:
132+
go run ./internal/cmd/testoidcauth/main.go
133+
go run -race ./internal/cmd/testoidcauth/main.go
134+
130135
.PHONY: evg-test-kmip
131136
evg-test-kmip:
132137
go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./internal/integration -run TestClientSideEncryptionSpec/kmipKMS >> test.suite

etc/run-oidc-test.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
# run-oidc-test
3+
# Runs oidc auth tests.
4+
set -eu
5+
6+
echo "Running MONGODB-OIDC authentication tests"
7+
8+
OIDC_ENV="${OIDC_ENV:-"test"}"
9+
10+
if [ $OIDC_ENV == "test" ]; then
11+
# Make sure DRIVERS_TOOLS is set.
12+
if [ -z "$DRIVERS_TOOLS" ]; then
13+
echo "Must specify DRIVERS_TOOLS"
14+
exit 1
15+
fi
16+
source ${DRIVERS_TOOLS}/.evergreen/auth_oidc/secrets-export.sh
17+
18+
elif [ $OIDC_ENV == "azure" ]; then
19+
source ./env.sh
20+
21+
elif [ $OIDC_ENV == "gcp" ]; then
22+
source ./secrets-export.sh
23+
24+
else
25+
echo "Unrecognized OIDC_ENV $OIDC_ENV"
26+
exit 1
27+
fi
28+
29+
export TEST_AUTH_OIDC=1
30+
export COVERAGE=1
31+
export AUTH="auth"
32+
33+
make -s evg-test-oidc-auth

0 commit comments

Comments
 (0)