Skip to content

Commit 7520a74

Browse files
authored
chore(ci): add kerberos auth tests
NODE-876
1 parent 56298bf commit 7520a74

File tree

7 files changed

+153
-438
lines changed

7 files changed

+153
-438
lines changed

.evergreen/config.yml

Lines changed: 19 additions & 0 deletions
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
@@ -779,6 +788,13 @@ tasks:
779788
commands:
780789
- func: install dependencies
781790
- func: run atlas tests
791+
- name: test-auth-kerberos
792+
tags:
793+
- auth
794+
- kerberos
795+
commands:
796+
- func: install dependencies
797+
- func: run kerberos tests
782798
- name: test-auth-ldap
783799
tags:
784800
- auth
@@ -861,6 +877,7 @@ buildvariants:
861877
- test-2.6-replica_set-unified
862878
- test-2.6-sharded_cluster-unified
863879
- test-atlas-connectivity
880+
- test-auth-kerberos
864881
- test-auth-ldap
865882
- test-tls-support
866883
- name: macos-1014-dubnium
@@ -960,6 +977,7 @@ buildvariants:
960977
- test-2.6-replica_set-unified
961978
- test-2.6-sharded_cluster-unified
962979
- test-atlas-connectivity
980+
- test-auth-kerberos
963981
- test-auth-ldap
964982
- name: ubuntu-14.04-dubnium
965983
display_name: Ubuntu 14.04 Node Dubnium
@@ -1029,6 +1047,7 @@ buildvariants:
10291047
- test-3.2-replica_set-unified
10301048
- test-3.2-sharded_cluster-unified
10311049
- test-atlas-connectivity
1050+
- test-auth-kerberos
10321051
- test-auth-ldap
10331052
- test-tls-support
10341053
- name: ubuntu-18.04-dubnium

.evergreen/config.yml.in

Lines changed: 10 additions & 0 deletions
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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ TASKS.push(
107107
tags: ['atlas-connect'],
108108
commands: [{ func: 'install dependencies' }, { func: 'run atlas tests' }]
109109
},
110+
{
111+
name: 'test-auth-kerberos',
112+
tags: ['auth', 'kerberos'],
113+
commands: [
114+
{ func: 'install dependencies' },
115+
{ func: 'run kerberos tests' }
116+
]
117+
},
110118
{
111119
name: 'test-auth-ldap',
112120
tags: ['auth', 'ldap'],

.evergreen/run-kerberos-tests.sh

Lines changed: 29 additions & 0 deletions
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

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:kerberos": "mocha --opts '{}' test/manual/kerberos.test.js",
6869
"check:ldap": "mocha --opts '{}' test/manual/ldap.test.js",
6970
"check:tls": "mocha --opts '{}' test/manual/tls_support.test.js",
7071
"test": "npm run lint && mocha --recursive test/functional test/unit test/core",

0 commit comments

Comments
 (0)