Skip to content

Commit 5255657

Browse files
authored
chore(ci): add plain ldap auth test
NODE-875
1 parent 40b1d17 commit 5255657

File tree

8 files changed

+76
-122
lines changed

8 files changed

+76
-122
lines changed

.evergreen/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ functions:
171171
rm -f ./prepare_atlas_connectivity.sh
172172
173173
NODE_LTS_NAME='${NODE_LTS_NAME}' bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh
174+
run ldap tests:
175+
- command: shell.exec
176+
type: test
177+
params:
178+
working_dir: src
179+
script: |
180+
MONGODB_URI='${plain_auth_mongodb_uri}' NODE_LTS_NAME='${NODE_LTS_NAME}' \
181+
bash ${PROJECT_DIRECTORY}/.evergreen/run-ldap-tests.sh
174182
pre:
175183
- func: fetch source
176184
- func: prepare resources
@@ -761,6 +769,13 @@ tasks:
761769
commands:
762770
- func: install dependencies
763771
- func: run atlas tests
772+
- name: test-auth-ldap
773+
tags:
774+
- auth
775+
- ldap
776+
commands:
777+
- func: install dependencies
778+
- func: run ldap tests
764779
- name: run-checks
765780
tags:
766781
- run-checks
@@ -825,6 +840,7 @@ buildvariants:
825840
- test-2.6-replica_set-unified
826841
- test-2.6-sharded_cluster-unified
827842
- test-atlas-connectivity
843+
- test-auth-ldap
828844
- name: macos-1014-dubnium
829845
display_name: macOS 10.14 Node Dubnium
830846
run_on: macos-1014
@@ -922,6 +938,7 @@ buildvariants:
922938
- test-2.6-replica_set-unified
923939
- test-2.6-sharded_cluster-unified
924940
- test-atlas-connectivity
941+
- test-auth-ldap
925942
- name: ubuntu-14.04-dubnium
926943
display_name: Ubuntu 14.04 Node Dubnium
927944
run_on: ubuntu1404-test
@@ -990,6 +1007,7 @@ buildvariants:
9901007
- test-3.2-replica_set-unified
9911008
- test-3.2-sharded_cluster-unified
9921009
- test-atlas-connectivity
1010+
- test-auth-ldap
9931011
- name: ubuntu-18.04-dubnium
9941012
display_name: Ubuntu 18.04 Node Dubnium
9951013
run_on: ubuntu1804-test

.evergreen/config.yml.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ functions:
207207

208208
NODE_LTS_NAME='${NODE_LTS_NAME}' bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh
209209

210+
"run ldap tests":
211+
- command: shell.exec
212+
type: test
213+
params:
214+
working_dir: "src"
215+
script: |
216+
MONGODB_URI='${plain_auth_mongodb_uri}' NODE_LTS_NAME='${NODE_LTS_NAME}' \
217+
bash ${PROJECT_DIRECTORY}/.evergreen/run-ldap-tests.sh
210218
pre:
211219
- func: "fetch source"
212220
- func: "prepare resources"

.evergreen/generate_evergreen_tasks.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,18 @@ MONGODB_VERSIONS.forEach(mongoVersion => {
101101
});
102102

103103
// singleton task for connectivity tests
104-
TASKS.push({
105-
name: 'test-atlas-connectivity',
106-
tags: ['atlas-connect'],
107-
commands: [{ func: 'install dependencies' }, { func: 'run atlas tests' }]
108-
});
104+
TASKS.push(
105+
{
106+
name: 'test-atlas-connectivity',
107+
tags: ['atlas-connect'],
108+
commands: [{ func: 'install dependencies' }, { func: 'run atlas tests' }]
109+
},
110+
{
111+
name: 'test-auth-ldap',
112+
tags: ['auth', 'ldap'],
113+
commands: [{ func: 'install dependencies' }, { func: 'run ldap tests' }]
114+
}
115+
);
109116

110117
const BUILD_VARIANTS = [];
111118

.evergreen/run-ldap-tests.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -o errexit # Exit the script with error if any of the commands fail
4+
5+
export PROJECT_DIRECTORY="$(pwd)"
6+
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
7+
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
8+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
9+
10+
npm run check:ldap

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
},
6666
"scripts": {
6767
"atlas": "mocha --opts '{}' ./test/manual/atlas_connectivity.test.js",
68+
"check:ldap": "mocha --config \"test/manual/mocharc.json\" test/manual/ldap.test.js",
6869
"test": "npm run lint && mocha --recursive test/functional test/unit test/core",
6970
"test-nolint": "mocha --recursive test/functional test/unit test/core",
7071
"coverage": "istanbul cover mongodb-test-runner -- -t 60000 test/core test/unit test/functional",

test/functional/ldap.test.js

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

test/manual/ldap.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
const MongoClient = require('../..').MongoClient;
3+
var test = require('../functional/shared').assert;
4+
5+
describe('LDAP', function() {
6+
if (process.env.MONGODB_URI == null) {
7+
throw new Error(`skipping SSL tests, MONGODB_URI environment variable is not defined`);
8+
}
9+
10+
it('Should correctly authenticate against ldap', function(done) {
11+
const client = new MongoClient(process.env.MONGODB_URI);
12+
client.connect(function(err, client) {
13+
test.equal(null, err);
14+
15+
client
16+
.db('ldap')
17+
.collection('test')
18+
.findOne(function(err, doc) {
19+
test.equal(null, err);
20+
test.equal(true, doc.ldap);
21+
22+
client.close(done);
23+
});
24+
});
25+
});
26+
});

test/spec/apm/updateOne.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
},
132132
{
133133
"description": "A successful update one command with write errors",
134+
"ignore_if_server_version_greater_than": "4.5",
134135
"operation": {
135136
"name": "updateOne",
136137
"arguments": {

0 commit comments

Comments
 (0)