Skip to content

Commit 74281a5

Browse files
ci(NODE-6737): LDAP tests use secrets manager (#4407)
1 parent dd9f2ce commit 74281a5

File tree

6 files changed

+30
-33
lines changed

6 files changed

+30
-33
lines changed

.evergreen/config.in.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,16 @@ functions:
416416
- .evergreen/run-kerberos-tests.sh
417417

418418
"run ldap tests":
419+
- command: ec2.assume_role
420+
params:
421+
role_arn: ${DRIVERS_SECRETS_ARN}
419422
- command: subprocess.exec
420423
type: test
421424
params:
422425
working_dir: src
423426
binary: bash
424427
env:
425-
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
426428
DRIVERS_TOOLS: ${DRIVERS_TOOLS}
427-
MONGODB_URI: ${plain_auth_mongodb_uri}
428429
NODE_LTS_VERSION: ${NODE_LTS_VERSION}
429430
args:
430431
- .evergreen/run-ldap-tests.sh

.evergreen/config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,15 +364,16 @@ functions:
364364
args:
365365
- .evergreen/run-kerberos-tests.sh
366366
run ldap tests:
367+
- command: ec2.assume_role
368+
params:
369+
role_arn: ${DRIVERS_SECRETS_ARN}
367370
- command: subprocess.exec
368371
type: test
369372
params:
370373
working_dir: src
371374
binary: bash
372375
env:
373-
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
374376
DRIVERS_TOOLS: ${DRIVERS_TOOLS}
375-
MONGODB_URI: ${plain_auth_mongodb_uri}
376377
NODE_LTS_VERSION: ${NODE_LTS_VERSION}
377378
args:
378379
- .evergreen/run-ldap-tests.sh

.evergreen/run-ldap-tests.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/bash
22

3-
set -o errexit # Exit the script with error if any of the commands fail
3+
set -o errexit # Exit the script with error if any of the commands fail
44

5+
bash $DRIVERS_TOOLS/.evergreen/secrets_handling/setup-secrets.sh drivers/enterprise_auth
6+
source secrets-export.sh
57
source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
68

79
npm run check:ldap

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
"check:oidc-k8s": "mocha --config test/mocha_mongodb.json test/integration/auth/mongodb_oidc_k8s.prose.07.test.ts",
155155
"check:kerberos": "nyc mocha --config test/manual/mocharc.json test/manual/kerberos.test.ts",
156156
"check:tls": "mocha --config test/manual/mocharc.json test/manual/tls_support.test.ts",
157-
"check:ldap": "nyc mocha --config test/manual/mocharc.json test/manual/ldap.test.js",
157+
"check:ldap": "nyc mocha --config test/manual/mocharc.json test/manual/ldap.test.ts",
158158
"check:socks5": "mocha --config test/manual/mocharc.json test/manual/socks5.test.ts",
159159
"check:csfle": "mocha --config test/mocha_mongodb.json test/integration/client-side-encryption",
160160
"check:snappy": "mocha test/unit/assorted/snappy.test.js",
@@ -175,4 +175,4 @@
175175
"moduleResolution": "node"
176176
}
177177
}
178-
}
178+
}

test/manual/ldap.test.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

test/manual/ldap.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { expect } from 'chai';
2+
3+
import { MongoClient } from '../mongodb';
4+
5+
describe('LDAP', function () {
6+
const { SASL_USER, SASL_PASS, SASL_HOST } = process.env;
7+
8+
const MONGODB_URI = `mongodb://${SASL_USER}:${SASL_PASS}@${SASL_HOST}?authMechanism=plain&authSource=$external`;
9+
10+
it('Should correctly authenticate against ldap', async function () {
11+
const client = new MongoClient(MONGODB_URI);
12+
await client.connect();
13+
14+
const doc = await client.db('ldap').collection('test').findOne();
15+
expect(doc).property('ldap').to.equal(true);
16+
17+
await client.close();
18+
});
19+
});

0 commit comments

Comments
 (0)