Skip to content

Commit 6817795

Browse files
authored
CSHARP-4448: Implement OIDC SASL mechanism (#1259)
1 parent 1bb081a commit 6817795

File tree

67 files changed

+6809
-853
lines changed

Some content is hidden

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

67 files changed

+6809
-853
lines changed

build.cake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@ Task("TestGssapiNetStandard20").IsDependentOn("TestGssapi");
257257
Task("TestGssapiNetStandard21").IsDependentOn("TestGssapi");
258258
Task("TestGssapiNet60").IsDependentOn("TestGssapi");
259259

260+
Task("TestMongoDbOidc")
261+
.IsDependentOn("Build")
262+
.DoesForEach(
263+
items: GetFiles("./**/MongoDB.Driver.Tests.csproj"),
264+
action: (BuildConfig buildConfig, Path testProject) =>
265+
RunTests(buildConfig, testProject, filter: "Category=\"MongoDbOidc\""));
266+
260267
Task("TestServerless")
261268
.IsDependentOn("Build")
262269
.DoesForEach(
@@ -692,7 +699,7 @@ public class BuildConfig
692699
string[] CreateLoggers(string projectName)
693700
{
694701
var testResultsFile = outputDirectory.Combine("test-results").Combine($"TEST-{projectName}-{target.ToLowerInvariant()}-{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}.xml");
695-
702+
696703
// Evergreen CI server requires JUnit output format to display test results
697704
var junitLogger = $"junit;LogFilePath={testResultsFile};FailureBodyFormat=Verbose";
698705
var consoleLogger = "console;verbosity=detailed";

evergreen/evergreen.yml

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ functions:
101101
params:
102102
script: |
103103
${PREPARE_SHELL}
104-
bash ${PROJECT_DIRECTORY}/evergreen/install-dotnet.sh
104+
OS=${OS} bash ${PROJECT_DIRECTORY}/evergreen/install-dotnet.sh
105105
106106
prepare-resources:
107107
- command: shell.exec
@@ -452,6 +452,11 @@ functions:
452452
params:
453453
file: mongo-csharp-driver/benchmarks/MongoDB.Driver.Benchmarks/Benchmark.Artifacts/results/evergreen-results.json
454454

455+
assume-ec2-role:
456+
- command: ec2.assume_role
457+
params:
458+
role_arn: ${aws_test_secrets_role}
459+
455460
add-aws-auth-variables-to-file:
456461
- command: ec2.assume_role
457462
params:
@@ -707,6 +712,19 @@ functions:
707712
-v \
708713
--fault revoked
709714
715+
run-mongodb-oidc-tests:
716+
- command: subprocess.exec
717+
type: test
718+
params:
719+
working_dir: mongo-csharp-driver
720+
binary: bash
721+
include_expansions_in_env:
722+
- "DRIVERS_TOOLS"
723+
- "OS"
724+
- "FRAMEWORK"
725+
args:
726+
- evergreen/run-mongodb-oidc-tests.sh
727+
710728
run-serverless-tests:
711729
- command: shell.exec
712730
type: test
@@ -1237,6 +1255,27 @@ tasks:
12371255
commands:
12381256
- func: run-atlas-search-index-helpers-test
12391257

1258+
- name: test-oidc-auth
1259+
commands:
1260+
- func: run-mongodb-oidc-tests
1261+
1262+
- name: test-oidc-azure
1263+
commands:
1264+
- command: shell.exec
1265+
params:
1266+
shell: bash
1267+
working_dir: mongo-csharp-driver
1268+
script: |-
1269+
set -o errexit
1270+
${PREPARE_SHELL}
1271+
1272+
dotnet build ./tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj
1273+
tar czf /tmp/mongo-csharp-driver.tgz ./tests/MongoDB.Driver.Tests/bin/Debug/net6.0 ./evergreen/run-mongodb-oidc-azure-tests.sh
1274+
1275+
export AZUREOIDC_DRIVERS_TAR_FILE=/tmp/mongo-csharp-driver.tgz
1276+
export AZUREOIDC_TEST_CMD="./evergreen/run-mongodb-oidc-azure-tests.sh"
1277+
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/azure/run-driver-test.sh
1278+
12401279
- name: test-serverless
12411280
exec_timeout_secs: 2700 # 45 minutes: 15 for setup + 30 for tests
12421281
commands:
@@ -2101,6 +2140,61 @@ task_groups:
21012140
tasks:
21022141
- test-aws-lambda-deployed
21032142

2143+
- name: oidc-auth-test-task-group
2144+
setup_group_can_fail_task: true
2145+
setup_group_timeout_secs: 1800 # 30 minutes
2146+
setup_group:
2147+
- func: fetch-source
2148+
- func: prepare-resources
2149+
- func: fix-absolute-paths
2150+
- func: init-test-results
2151+
- func: make-files-executable
2152+
- func: assume-ec2-role
2153+
- command: subprocess.exec
2154+
params:
2155+
binary: bash
2156+
include_expansions_in_env:
2157+
- "AWS_ACCESS_KEY_ID"
2158+
- "AWS_SECRET_ACCESS_KEY"
2159+
- "AWS_SESSION_TOKEN"
2160+
args:
2161+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/setup.sh
2162+
teardown_group:
2163+
- func: upload-test-results
2164+
- command: subprocess.exec
2165+
params:
2166+
binary: bash
2167+
args:
2168+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/teardown.sh
2169+
tasks:
2170+
- test-oidc-auth
2171+
2172+
- name: oidc-auth-azure-task-group
2173+
setup_group_can_fail_task: true
2174+
setup_group_timeout_secs: 1800 # 30 minutes
2175+
setup_group:
2176+
- func: fetch-source
2177+
- func: prepare-resources
2178+
- func: fix-absolute-paths
2179+
- func: make-files-executable
2180+
- func: install-dotnet
2181+
- command: subprocess.exec
2182+
params:
2183+
binary: bash
2184+
env:
2185+
AZUREOIDC_VMNAME_PREFIX: "CSHARP_DRIVER"
2186+
args:
2187+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/azure/create-and-setup-vm.sh
2188+
teardown_group:
2189+
- func: upload-test-results
2190+
- command: subprocess.exec
2191+
params:
2192+
binary: bash
2193+
args:
2194+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/azure/delete-vm.sh
2195+
tasks:
2196+
- test-oidc-azure
2197+
21042198
buildvariants:
21052199
- matrix_name: stable-api-tests
21062200
matrix_spec: { version: ["5.0", "6.0", "7.0", "rapid", "latest"], topology: "standalone", auth: "auth", ssl: "nossl", os: "windows-64" }
@@ -2218,6 +2312,20 @@ buildvariants:
22182312
tasks:
22192313
- name: plain-auth-tests
22202314

2315+
- matrix_name: mongodb-oidc-test-tests
2316+
matrix_spec: { os: [ "ubuntu-2004", "macos-1100" ] }
2317+
display_name: "MongoDB-OIDC Auth (test) - ${os}"
2318+
batchtime: 20160 # 14 days
2319+
tasks:
2320+
- name: oidc-auth-test-task-group
2321+
2322+
- matrix_name: mongodb-oidc-azure-tests
2323+
matrix_spec: { os: [ "ubuntu-2004" ] }
2324+
display_name: "MongoDB-OIDC Auth (azure) - ${os}"
2325+
batchtime: 20160 # 14 days
2326+
tasks:
2327+
- name: oidc-auth-azure-task-group
2328+
22212329
- matrix_name: "ocsp-tests"
22222330
matrix_spec: { version: ["4.4", "5.0", "6.0", "7.0", "rapid", "latest"], auth: "noauth", ssl: "ssl", topology: "standalone", os: "windows-64" }
22232331
display_name: "OCSP ${version} ${os}"

0 commit comments

Comments
 (0)