Skip to content

Commit 02adce8

Browse files
committed
test: add config tests
1 parent 32490b5 commit 02adce8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/client-side-encryption/auto_encrypter.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ import { autoSelectSocketOptions } from './client_encryption';
1717
import * as cryptoCallbacks from './crypto_callbacks';
1818
import { MongoCryptInvalidArgumentError } from './errors';
1919
import { MongocryptdManager } from './mongocryptd_manager';
20-
import { type CredentialProviders, type KMSProviders, refreshKMSCredentials } from './providers';
20+
import {
21+
type CredentialProviders,
22+
isEmptyCredentials,
23+
type KMSProviders,
24+
refreshKMSCredentials
25+
} from './providers';
2126
import { type CSFLEKMSTlsOptions, StateMachine } from './state_machine';
2227

2328
/** @public */
@@ -242,6 +247,15 @@ export class AutoEncrypter {
242247
this._kmsProviders = options.kmsProviders || {};
243248
this._credentialProviders = options.credentialProviders;
244249

250+
if (
251+
options.credentialProviders?.aws &&
252+
!isEmptyCredentials('aws', options.kmsProviders || {})
253+
) {
254+
throw new MongoCryptInvalidArgumentError(
255+
'Cannot provide both a custom credential provider and credentials. Please specify one or the other.'
256+
);
257+
}
258+
245259
const mongoCryptOptions: MongoCryptOptions = {
246260
cryptoCallbacks
247261
};

0 commit comments

Comments
 (0)