Skip to content

Commit 3cda5c4

Browse files
authored
chore(ci): add kerberos auth tests
NODE-876
1 parent d3a1d54 commit 3cda5c4

7 files changed

+166
-454
lines changed

.evergreen/config.yml

+28-9
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,15 @@ functions:
172172
rm -f ./prepare_atlas_connectivity.sh
173173
174174
NODE_LTS_NAME='${NODE_LTS_NAME}' bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh
175+
run kerberos tests:
176+
- command: shell.exec
177+
type: test
178+
params:
179+
working_dir: src
180+
script: |
181+
KRB5_KEYTAB='${gssapi_auth_keytab_base64}' KRB5_PRINCIPAL='${gssapi_auth_principal}' \
182+
MONGODB_URI='${gssapi_auth_mongodb_uri}' \
183+
NODE_LTS_NAME='${NODE_LTS_NAME}' bash ${PROJECT_DIRECTORY}/.evergreen/run-kerberos-tests.sh
175184
run ldap tests:
176185
- command: shell.exec
177186
type: test
@@ -1065,6 +1074,20 @@ tasks:
10651074
commands:
10661075
- func: install dependencies
10671076
- func: run atlas tests
1077+
- name: test-auth-kerberos
1078+
tags:
1079+
- auth
1080+
- kerberos
1081+
commands:
1082+
- func: install dependencies
1083+
- func: run kerberos tests
1084+
- name: test-auth-ldap
1085+
tags:
1086+
- auth
1087+
- ldap
1088+
commands:
1089+
- func: install dependencies
1090+
- func: run ldap tests
10681091
- name: test-tls-support
10691092
tags:
10701093
- tls-support
@@ -1076,13 +1099,6 @@ tasks:
10761099
VERSION: latest
10771100
TOPOLOGY: server
10781101
- func: run tls tests
1079-
- name: test-auth-ldap
1080-
tags:
1081-
- auth
1082-
- ldap
1083-
commands:
1084-
- func: install dependencies
1085-
- func: run ldap tests
10861102
- name: test-latest-ocsp-valid-cert-server-staples
10871103
tags:
10881104
- ocsp
@@ -1377,8 +1393,9 @@ buildvariants:
13771393
- test-2.6-replica_set-unified
13781394
- test-2.6-sharded_cluster-unified
13791395
- test-atlas-connectivity
1380-
- test-tls-support
1396+
- test-auth-kerberos
13811397
- test-auth-ldap
1398+
- test-tls-support
13821399
- test-latest-ocsp-valid-cert-server-staples
13831400
- test-latest-ocsp-invalid-cert-server-staples
13841401
- test-latest-ocsp-valid-cert-server-does-not-staple
@@ -1490,6 +1507,7 @@ buildvariants:
14901507
- test-2.6-replica_set-unified
14911508
- test-2.6-sharded_cluster-unified
14921509
- test-atlas-connectivity
1510+
- test-auth-kerberos
14931511
- test-auth-ldap
14941512
- name: ubuntu-14.04-dubnium
14951513
display_name: Ubuntu 14.04 Node Dubnium
@@ -1565,8 +1583,9 @@ buildvariants:
15651583
- test-3.2-replica_set-unified
15661584
- test-3.2-sharded_cluster-unified
15671585
- test-atlas-connectivity
1568-
- test-tls-support
1586+
- test-auth-kerberos
15691587
- test-auth-ldap
1588+
- test-tls-support
15701589
- test-latest-ocsp-valid-cert-server-staples
15711590
- test-latest-ocsp-invalid-cert-server-staples
15721591
- test-latest-ocsp-valid-cert-server-does-not-staple

.evergreen/config.yml.in

+10
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,16 @@ functions:
211211

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

214+
"run kerberos tests":
215+
- command: shell.exec
216+
type: test
217+
params:
218+
working_dir: src
219+
script: |
220+
KRB5_KEYTAB='${gssapi_auth_keytab_base64}' KRB5_PRINCIPAL='${gssapi_auth_principal}' \
221+
MONGODB_URI='${gssapi_auth_mongodb_uri}' \
222+
NODE_LTS_NAME='${NODE_LTS_NAME}' bash ${PROJECT_DIRECTORY}/.evergreen/run-kerberos-tests.sh
223+
214224
"run ldap tests":
215225
- command: shell.exec
216226
type: test

.evergreen/generate_evergreen_tasks.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,21 @@ TASKS.push(
106106
{
107107
name: 'test-atlas-connectivity',
108108
tags: ['atlas-connect'],
109+
commands: [{ func: 'install dependencies' }, { func: 'run atlas tests' }]
110+
},
111+
{
112+
name: 'test-auth-kerberos',
113+
tags: ['auth', 'kerberos'],
109114
commands: [
110115
{ func: 'install dependencies' },
111-
{ func: 'run atlas tests' }
116+
{ func: 'run kerberos tests' }
112117
]
113118
},
119+
{
120+
name: 'test-auth-ldap',
121+
tags: ['auth', 'ldap'],
122+
commands: [{ func: 'install dependencies' }, { func: 'run ldap tests' }]
123+
},
114124
{
115125
name: 'test-tls-support',
116126
tags: ['tls-support'],
@@ -126,11 +136,6 @@ TASKS.push(
126136
},
127137
{ func: 'run tls tests' }
128138
]
129-
},
130-
{
131-
name: 'test-auth-ldap',
132-
tags: ['auth', 'ldap'],
133-
commands: [{ func: 'install dependencies' }, { func: 'run ldap tests' }]
134139
}
135140
);
136141

.evergreen/run-kerberos-tests.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
# set up keytab
11+
mkdir -p "$(pwd)/.evergreen"
12+
touch "$(pwd)/.evergreen/krb5.conf.empty"
13+
export KRB5_CONFIG="$(pwd)/.evergreen/krb5.conf.empty"
14+
echo "Writing keytab"
15+
# DON'T PRINT KEYTAB TO STDOUT
16+
set +o verbose
17+
if [[ "$OSTYPE" == "darwin"* ]]; then
18+
echo ${KRB5_KEYTAB} | base64 -D > "$(pwd)/.evergreen/drivers.keytab"
19+
else
20+
echo ${KRB5_KEYTAB} | base64 -d > "$(pwd)/.evergreen/drivers.keytab"
21+
fi
22+
echo "Running kinit"
23+
kinit -k -t "$(pwd)/.evergreen/drivers.keytab" -p ${KRB5_PRINCIPAL}
24+
25+
npm install kerberos
26+
npm run check:kerberos
27+
28+
# destroy ticket
29+
kdestroy

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@
6565
},
6666
"scripts": {
6767
"atlas": "mocha --opts '{}' ./test/manual/atlas_connectivity.test.js",
68-
"check:tls": "mocha --opts '{}' test/manual/tls_support.test.js",
68+
"check:kerberos": "mocha --opts '{}' test/manual/kerberos.test.js",
6969
"check:ldap": "mocha --opts '{}' test/manual/ldap.test.js",
70+
"check:tls": "mocha --opts '{}' test/manual/tls_support.test.js",
7071
"test": "npm run lint && mocha --recursive test/functional test/unit test/core",
7172
"test-nolint": "mocha --recursive test/functional test/unit test/core",
7273
"coverage": "istanbul cover mongodb-test-runner -- -t 60000 test/core test/unit test/functional",

0 commit comments

Comments
 (0)