Last active
July 20, 2020 11:02
-
-
Save mcasimir/0274c829fc858accafd5695f855effa6 to your computer and use it in GitHub Desktop.
Debug COMPASS-4319
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { MongoClient } = require('mongodb'); | |
const assert = require('assert'); | |
const HOST = 'centos-east.win.mongodb-field.com'; | |
const PORT = '27017'; | |
const PRINCIPAL = '[email protected]'; | |
const GSSAPI_SERVICE_NAME = 'mongo-ent'; | |
describe('MongoClient authentication with kerberos', () => { | |
const options = { | |
connectWithNoPrimary: true, | |
readPreference: 'primary', | |
useNewUrlParser: true | |
}; | |
const uri = `mongodb://${encodeURIComponent(PRINCIPAL)}@${HOST}:${PORT}?authMechanism=GSSAPI&gssapiServiceName=${GSSAPI_SERVICE_NAME}`; | |
console.log(uri); | |
[false, true].forEach((useUnifiedTopology) => { | |
context(`when useUnifiedTopology: ${useUnifiedTopology}`, () => { | |
let client; | |
afterEach(async () => { | |
if (client) { | |
await client.close(); | |
} | |
}); | |
it('should connect to kerberized mongo', async () => { | |
client = await MongoClient.connect(uri, { | |
...options, | |
useUnifiedTopology | |
}); | |
const result = await client.db().admin().listDatabases(); | |
assert.equal(result.ok, 1); | |
}).timeout(35000); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment