Skip to content

Commit

Permalink
CSHARP-4448: Implement OIDC SASL mechanism (#1259)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanych-sun authored Apr 11, 2024
1 parent 1bb081a commit 6817795
Show file tree
Hide file tree
Showing 67 changed files with 6,809 additions and 853 deletions.
9 changes: 8 additions & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,13 @@ Task("TestGssapiNetStandard20").IsDependentOn("TestGssapi");
Task("TestGssapiNetStandard21").IsDependentOn("TestGssapi");
Task("TestGssapiNet60").IsDependentOn("TestGssapi");

Task("TestMongoDbOidc")
.IsDependentOn("Build")
.DoesForEach(
items: GetFiles("./**/MongoDB.Driver.Tests.csproj"),
action: (BuildConfig buildConfig, Path testProject) =>
RunTests(buildConfig, testProject, filter: "Category=\"MongoDbOidc\""));

Task("TestServerless")
.IsDependentOn("Build")
.DoesForEach(
Expand Down Expand Up @@ -692,7 +699,7 @@ public class BuildConfig
string[] CreateLoggers(string projectName)
{
var testResultsFile = outputDirectory.Combine("test-results").Combine($"TEST-{projectName}-{target.ToLowerInvariant()}-{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}.xml");

// Evergreen CI server requires JUnit output format to display test results
var junitLogger = $"junit;LogFilePath={testResultsFile};FailureBodyFormat=Verbose";
var consoleLogger = "console;verbosity=detailed";
Expand Down
110 changes: 109 additions & 1 deletion evergreen/evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ functions:
params:
script: |
${PREPARE_SHELL}
bash ${PROJECT_DIRECTORY}/evergreen/install-dotnet.sh
OS=${OS} bash ${PROJECT_DIRECTORY}/evergreen/install-dotnet.sh
prepare-resources:
- command: shell.exec
Expand Down Expand Up @@ -452,6 +452,11 @@ functions:
params:
file: mongo-csharp-driver/benchmarks/MongoDB.Driver.Benchmarks/Benchmark.Artifacts/results/evergreen-results.json

assume-ec2-role:
- command: ec2.assume_role
params:
role_arn: ${aws_test_secrets_role}

add-aws-auth-variables-to-file:
- command: ec2.assume_role
params:
Expand Down Expand Up @@ -707,6 +712,19 @@ functions:
-v \
--fault revoked
run-mongodb-oidc-tests:
- command: subprocess.exec
type: test
params:
working_dir: mongo-csharp-driver
binary: bash
include_expansions_in_env:
- "DRIVERS_TOOLS"
- "OS"
- "FRAMEWORK"
args:
- evergreen/run-mongodb-oidc-tests.sh

run-serverless-tests:
- command: shell.exec
type: test
Expand Down Expand Up @@ -1237,6 +1255,27 @@ tasks:
commands:
- func: run-atlas-search-index-helpers-test

- name: test-oidc-auth
commands:
- func: run-mongodb-oidc-tests

- name: test-oidc-azure
commands:
- command: shell.exec
params:
shell: bash
working_dir: mongo-csharp-driver
script: |-
set -o errexit
${PREPARE_SHELL}
dotnet build ./tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj
tar czf /tmp/mongo-csharp-driver.tgz ./tests/MongoDB.Driver.Tests/bin/Debug/net6.0 ./evergreen/run-mongodb-oidc-azure-tests.sh
export AZUREOIDC_DRIVERS_TAR_FILE=/tmp/mongo-csharp-driver.tgz
export AZUREOIDC_TEST_CMD="./evergreen/run-mongodb-oidc-azure-tests.sh"
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/azure/run-driver-test.sh
- name: test-serverless
exec_timeout_secs: 2700 # 45 minutes: 15 for setup + 30 for tests
commands:
Expand Down Expand Up @@ -2101,6 +2140,61 @@ task_groups:
tasks:
- test-aws-lambda-deployed

- name: oidc-auth-test-task-group
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800 # 30 minutes
setup_group:
- func: fetch-source
- func: prepare-resources
- func: fix-absolute-paths
- func: init-test-results
- func: make-files-executable
- func: assume-ec2-role
- command: subprocess.exec
params:
binary: bash
include_expansions_in_env:
- "AWS_ACCESS_KEY_ID"
- "AWS_SECRET_ACCESS_KEY"
- "AWS_SESSION_TOKEN"
args:
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/setup.sh
teardown_group:
- func: upload-test-results
- command: subprocess.exec
params:
binary: bash
args:
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/teardown.sh
tasks:
- test-oidc-auth

- name: oidc-auth-azure-task-group
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800 # 30 minutes
setup_group:
- func: fetch-source
- func: prepare-resources
- func: fix-absolute-paths
- func: make-files-executable
- func: install-dotnet
- command: subprocess.exec
params:
binary: bash
env:
AZUREOIDC_VMNAME_PREFIX: "CSHARP_DRIVER"
args:
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/azure/create-and-setup-vm.sh
teardown_group:
- func: upload-test-results
- command: subprocess.exec
params:
binary: bash
args:
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/azure/delete-vm.sh
tasks:
- test-oidc-azure

buildvariants:
- matrix_name: stable-api-tests
matrix_spec: { version: ["5.0", "6.0", "7.0", "rapid", "latest"], topology: "standalone", auth: "auth", ssl: "nossl", os: "windows-64" }
Expand Down Expand Up @@ -2218,6 +2312,20 @@ buildvariants:
tasks:
- name: plain-auth-tests

- matrix_name: mongodb-oidc-test-tests
matrix_spec: { os: [ "ubuntu-2004", "macos-1100" ] }
display_name: "MongoDB-OIDC Auth (test) - ${os}"
batchtime: 20160 # 14 days
tasks:
- name: oidc-auth-test-task-group

- matrix_name: mongodb-oidc-azure-tests
matrix_spec: { os: [ "ubuntu-2004" ] }
display_name: "MongoDB-OIDC Auth (azure) - ${os}"
batchtime: 20160 # 14 days
tasks:
- name: oidc-auth-azure-task-group

- matrix_name: "ocsp-tests"
matrix_spec: { version: ["4.4", "5.0", "6.0", "7.0", "rapid", "latest"], auth: "noauth", ssl: "ssl", topology: "standalone", os: "windows-64" }
display_name: "OCSP ${version} ${os}"
Expand Down
Loading

0 comments on commit 6817795

Please sign in to comment.