Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/cli-repl/src/smoke-tests-fle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ assert(db.getName() === dbname, 'db name must match');

const local = { key: Buffer.from('kh4Gv2N8qopZQMQYMEtww/AkPsIrXNmEMxTrs3tUoTQZbZu4msdRUaR8U5fXD7A7QXYHcEvuu4WctJLoT+NvvV3eeIg3MD+K8H9SR794m/safgRHdIfy6PD+rFpvmFbY', 'base64') };

const keyMongo = Mongo(db.getMongo()._uri, {
const keyMongo = Mongo(db.getMongo(), {
keyVaultNamespace: dbname + '.__keyVault',
kmsProviders: { local }
});
Expand All @@ -51,7 +51,7 @@ schemaMap[dbname + '.employees'] = {

console.log('Using schema map', schemaMap);

const autoMongo = Mongo(db.getMongo()._uri, {
const autoMongo = Mongo(db.getMongo(), {
keyVaultNamespace: dbname + '.__keyVault',
kmsProviders: { local },
schemaMap
Expand Down
4 changes: 2 additions & 2 deletions packages/cli-repl/test/e2e-fle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ describe('FLE tests', () => {
// Wrapper for executeLine that expects single-line output
const runSingleLine = async(line) => (await shell.executeLine(line)).split('\n')[0].trim();
await runSingleLine('local = { key: BinData(0, "kh4Gv2N8qopZQMQYMEtww/AkPsIrXNmEMxTrs3tUoTQZbZu4msdRUaR8U5fXD7A7QXYHcEvuu4WctJLoT+NvvV3eeIg3MD+K8H9SR794m/safgRHdIfy6PD+rFpvmFbY") }');
await runSingleLine(`keyMongo = Mongo(db.getMongo()._uri, { \
await runSingleLine(`keyMongo = Mongo(db.getMongo(), { \
keyVaultNamespace: '${dbname}.keyVault', \
kmsProviders: { local }, \
explicitEncryptionOnly: true \
Expand Down Expand Up @@ -473,7 +473,7 @@ describe('FLE tests', () => {
// Wrapper for executeLine that expects single-line output
const runSingleLine = async(line) => (await shell.executeLine(line)).split('\n')[0].trim();
await runSingleLine('local = { key: BinData(0, "kh4Gv2N8qopZQMQYMEtww/AkPsIrXNmEMxTrs3tUoTQZbZu4msdRUaR8U5fXD7A7QXYHcEvuu4WctJLoT+NvvV3eeIg3MD+K8H9SR794m/safgRHdIfy6PD+rFpvmFbY") }');
await runSingleLine(`keyMongo = Mongo(db.getMongo()._uri, { \
await runSingleLine(`keyMongo = Mongo(db.getMongo(), { \
keyVaultNamespace: '${dbname}.keyVault', \
kmsProviders: { local }, \
explicitEncryptionOnly: true \
Expand Down
6 changes: 4 additions & 2 deletions packages/shell-api/src/mongo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class Mongo extends ShellApiClass {

constructor(
instanceState: ShellInstanceState,
uri?: string,
uri?: string | Mongo,
fleOptions?: ClientSideFieldLevelEncryptionOptions,
otherOptions?: { api?: ServerApi | ServerApiVersion },
sp?: ServiceProvider
Expand All @@ -92,7 +92,9 @@ export default class Mongo extends ShellApiClass {
if (sp) {
this.__serviceProvider = sp;
}
if (typeof uri !== 'string') {
if (typeof uri === 'object' && uri !== null && typeof uri._uri === 'string') {
uri = uri._uri;
} else if (typeof uri !== 'string') {
uri = sp?.getURI?.() ?? 'mongodb://localhost/';
}
this._connectionInfo = generateConnectionInfoFromCliArgs({
Expand Down