diff --git a/.evergreen/config.in.yml b/.evergreen/config.in.yml index d28c00109f2..83204a04349 100644 --- a/.evergreen/config.in.yml +++ b/.evergreen/config.in.yml @@ -416,15 +416,16 @@ functions: - .evergreen/run-kerberos-tests.sh "run ldap tests": + - command: ec2.assume_role + params: + role_arn: ${DRIVERS_SECRETS_ARN} - command: subprocess.exec type: test params: working_dir: src binary: bash env: - PROJECT_DIRECTORY: ${PROJECT_DIRECTORY} DRIVERS_TOOLS: ${DRIVERS_TOOLS} - MONGODB_URI: ${plain_auth_mongodb_uri} NODE_LTS_VERSION: ${NODE_LTS_VERSION} args: - .evergreen/run-ldap-tests.sh diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 5537e9b1c64..517f40fe824 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -364,15 +364,16 @@ functions: args: - .evergreen/run-kerberos-tests.sh run ldap tests: + - command: ec2.assume_role + params: + role_arn: ${DRIVERS_SECRETS_ARN} - command: subprocess.exec type: test params: working_dir: src binary: bash env: - PROJECT_DIRECTORY: ${PROJECT_DIRECTORY} DRIVERS_TOOLS: ${DRIVERS_TOOLS} - MONGODB_URI: ${plain_auth_mongodb_uri} NODE_LTS_VERSION: ${NODE_LTS_VERSION} args: - .evergreen/run-ldap-tests.sh diff --git a/.evergreen/run-ldap-tests.sh b/.evergreen/run-ldap-tests.sh index 574359fe8b3..b4ee8015bd6 100644 --- a/.evergreen/run-ldap-tests.sh +++ b/.evergreen/run-ldap-tests.sh @@ -1,7 +1,9 @@ #!/bin/bash -set -o errexit # Exit the script with error if any of the commands fail +set -o errexit # Exit the script with error if any of the commands fail +bash $DRIVERS_TOOLS/.evergreen/secrets_handling/setup-secrets.sh drivers/enterprise_auth +source secrets-export.sh source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh npm run check:ldap diff --git a/package.json b/package.json index 38e3a891cd5..fe5c2394d31 100644 --- a/package.json +++ b/package.json @@ -154,7 +154,7 @@ "check:oidc-k8s": "mocha --config test/mocha_mongodb.json test/integration/auth/mongodb_oidc_k8s.prose.07.test.ts", "check:kerberos": "nyc mocha --config test/manual/mocharc.json test/manual/kerberos.test.ts", "check:tls": "mocha --config test/manual/mocharc.json test/manual/tls_support.test.ts", - "check:ldap": "nyc mocha --config test/manual/mocharc.json test/manual/ldap.test.js", + "check:ldap": "nyc mocha --config test/manual/mocharc.json test/manual/ldap.test.ts", "check:socks5": "mocha --config test/manual/mocharc.json test/manual/socks5.test.ts", "check:csfle": "mocha --config test/mocha_mongodb.json test/integration/client-side-encryption", "check:snappy": "mocha test/unit/assorted/snappy.test.js", @@ -175,4 +175,4 @@ "moduleResolution": "node" } } -} +} \ No newline at end of file diff --git a/test/manual/ldap.test.js b/test/manual/ldap.test.js deleted file mode 100644 index 6ef27377d47..00000000000 --- a/test/manual/ldap.test.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; -const { MongoClient } = require('../mongodb'); -const { expect } = require('chai'); - -describe('LDAP', function () { - if (process.env.MONGODB_URI == null) { - throw new Error(`skipping SSL tests, MONGODB_URI environment variable is not defined`); - } - - it('Should correctly authenticate against ldap', function (done) { - const client = new MongoClient(process.env.MONGODB_URI); - client.connect(function (err, client) { - expect(err).to.not.exist; - - client - .db('ldap') - .collection('test') - .findOne(function (err, doc) { - expect(err).to.not.exist; - expect(doc).property('ldap').to.equal(true); - - client.close(done); - }); - }); - }); -}); diff --git a/test/manual/ldap.test.ts b/test/manual/ldap.test.ts new file mode 100644 index 00000000000..cec70308d57 --- /dev/null +++ b/test/manual/ldap.test.ts @@ -0,0 +1,19 @@ +import { expect } from 'chai'; + +import { MongoClient } from '../mongodb'; + +describe('LDAP', function () { + const { SASL_USER, SASL_PASS, SASL_HOST } = process.env; + + const MONGODB_URI = `mongodb://${SASL_USER}:${SASL_PASS}@${SASL_HOST}?authMechanism=plain&authSource=$external`; + + it('Should correctly authenticate against ldap', async function () { + const client = new MongoClient(MONGODB_URI); + await client.connect(); + + const doc = await client.db('ldap').collection('test').findOne(); + expect(doc).property('ldap').to.equal(true); + + await client.close(); + }); +});