Skip to content

Commit 3a4edd5

Browse files
ci(NODE-6694): kerberos tests use secrets manager (#4396)
1 parent 58572de commit 3a4edd5

File tree

6 files changed

+25
-36
lines changed

6 files changed

+25
-36
lines changed

.evergreen/config.in.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,7 @@ functions:
411411
binary: bash
412412
working_dir: src
413413
env:
414-
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
415414
DRIVERS_TOOLS: ${DRIVERS_TOOLS}
416-
KRB5_KEYTAB: ${gssapi_auth_keytab_base64}
417-
KRB5_NEW_KEYTAB: ${gssapi_auth_new_keytab_base64}
418-
KRB5_PRINCIPAL: ${gssapi_auth_principal}
419-
MONGODB_URI: ${gssapi_auth_mongodb_uri}
420-
NODE_LTS_VERSION: ${NODE_LTS_VERSION}
421415
args:
422416
- .evergreen/run-kerberos-tests.sh
423417

.evergreen/config.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,7 @@ functions:
360360
binary: bash
361361
working_dir: src
362362
env:
363-
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
364363
DRIVERS_TOOLS: ${DRIVERS_TOOLS}
365-
KRB5_KEYTAB: ${gssapi_auth_keytab_base64}
366-
KRB5_NEW_KEYTAB: ${gssapi_auth_new_keytab_base64}
367-
KRB5_PRINCIPAL: ${gssapi_auth_principal}
368-
MONGODB_URI: ${gssapi_auth_mongodb_uri}
369-
NODE_LTS_VERSION: ${NODE_LTS_VERSION}
370364
args:
371365
- .evergreen/run-kerberos-tests.sh
372366
run ldap tests:

.evergreen/run-kerberos-tests.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
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

55
source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
66

7+
bash $DRIVERS_TOOLS/.evergreen/secrets_handling/setup-secrets.sh drivers/enterprise_auth
8+
source secrets-export.sh
9+
710
# set up keytab
811
mkdir -p "$(pwd)/.evergreen"
912
export KRB5_CONFIG="$(pwd)/.evergreen/krb5.conf.empty"
1013
echo "Writing keytab"
1114
# DON'T PRINT KEYTAB TO STDOUT
1215
set +o verbose
1316
if [[ "$OSTYPE" == "darwin"* ]]; then
14-
echo ${KRB5_NEW_KEYTAB} | base64 -D > "$(pwd)/.evergreen/drivers.keytab"
17+
echo ${KEYTAB_BASE64_AES} | base64 -D >"$(pwd)/.evergreen/drivers.keytab"
1518
else
16-
echo ${KRB5_NEW_KEYTAB} | base64 -d > "$(pwd)/.evergreen/drivers.keytab"
19+
echo ${KEYTAB_BASE64_AES} | base64 -d >"$(pwd)/.evergreen/drivers.keytab"
1720
fi
1821
echo "Running kdestroy"
1922
kdestroy -A
2023
echo "Running kinit"
21-
kinit -k -t "$(pwd)/.evergreen/drivers.keytab" -p ${KRB5_PRINCIPAL}
24+
kinit -k -t "$(pwd)/.evergreen/drivers.keytab" -p ${PRINCIPAL}
25+
26+
USER=$(node -p "encodeURIComponent(process.env.PRINCIPAL)")
27+
export MONGODB_URI="mongodb://${USER}@${SASL_HOST}/${GSSAPI_DB}?authMechanism=GSSAPI"
2228

2329
set -o xtrace
2430
npm install [email protected]

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,5 @@ expansions.sh
106106
.drivers-tools/
107107

108108
crypt_shared.sh
109+
110+
*keytab

test/manual/kerberos.test.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,14 @@ describe('Kerberos', function () {
3434
client = null;
3535
});
3636

37-
if (process.env.MONGODB_URI == null) {
38-
console.error('skipping Kerberos tests, MONGODB_URI environment variable is not defined');
39-
return;
40-
}
41-
let krb5Uri = process.env.MONGODB_URI;
42-
const parts = krb5Uri.split('@', 2);
43-
const host = parts[1].split('/')[0];
37+
const krb5Uri = process.env.MONGODB_URI;
38+
const host = process.env.SASL_HOST;
4439

45-
if (!process.env.KRB5_PRINCIPAL) {
46-
console.error('skipping Kerberos tests, KRB5_PRINCIPAL environment variable is not defined');
40+
if (!process.env.PRINCIPAL) {
41+
console.error('skipping Kerberos tests, PRINCIPAL environment variable is not defined');
4742
return;
4843
}
4944

50-
if (process.platform === 'win32') {
51-
console.error('Win32 run detected');
52-
if (process.env.LDAPTEST_PASSWORD == null) {
53-
throw new Error('The env parameter LDAPTEST_PASSWORD must be set');
54-
}
55-
krb5Uri = `${parts[0]}:${process.env.LDAPTEST_PASSWORD}@${parts[1]}`;
56-
}
57-
5845
it('should authenticate with original uri', async function () {
5946
client = new MongoClient(krb5Uri);
6047
await client.connect();
@@ -231,7 +218,9 @@ describe('Kerberos', function () {
231218
if (!expectedError) {
232219
expect.fail('Expected connect with invalid SERVICE_HOST to fail');
233220
}
234-
expect(expectedError.message).to.match(/GSS failure|UNKNOWN_SERVER/);
221+
expect(expectedError.message).to.match(
222+
/GSS failure|UNKNOWN_SERVER|Server not found in Kerberos database/
223+
);
235224
});
236225
});
237226

@@ -277,7 +266,7 @@ describe('Kerberos', function () {
277266

278267
it('should fail to authenticate with bad credentials', async function () {
279268
client = new MongoClient(
280-
krb5Uri.replace(encodeURIComponent(process.env.KRB5_PRINCIPAL), 'bad%40creds.cc')
269+
krb5Uri.replace(encodeURIComponent(process.env.PRINCIPAL), 'bad%40creds.cc')
281270
);
282271
const err = await client.connect().catch(e => e);
283272
expect(err.message).to.match(/Authentication failed/);

test/readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ about the types of tests and how to run them.
3838
- [Launching an Atlas Cluster](#launching-an-atlas-cluster)
3939
- [Search Indexes](#search-indexes)
4040
- [Deployed Lambda Tests](#deployed-lambda-tests)
41+
- [Kerberos Tests](#kerberos-tests)
4142
- [TODO Special Env Sections](#todo-special-env-sections)
4243
- [Testing driver changes with mongosh](#testing-driver-changes-with-mongosh)
4344
- [Point mongosh to the driver](#point-mongosh-to-the-driver)
@@ -614,9 +615,12 @@ The URI of the cluster is available in the `atlas-expansions.yml` file.
614615
615616
TODO(NODE-6698): Update deployed lambda test section.
616617
618+
### Kerberos Tests
619+
620+
Run `.evergreen/run-kerberos-tests.sh`.
621+
617622
### TODO Special Env Sections
618623
619-
- Kerberos
620624
- AWS Authentication
621625
- TLS
622626
- Atlas Data Lake

0 commit comments

Comments
 (0)