@@ -50,6 +50,67 @@ describe('Client Side Encryption Functional', function () {
50
50
const keyVaultCollName = 'datakeys' ;
51
51
const keyVaultNamespace = `${ keyVaultDbName } .${ keyVaultCollName } ` ;
52
52
53
+ describe ( 'ClientEncryption' , metadata , function ( ) {
54
+ describe ( '#constructor' , function ( ) {
55
+ context ( 'when a custom credential provider and credentials are provided' , function ( ) {
56
+ let client ;
57
+
58
+ before ( function ( ) {
59
+ client = this . configuration . newClient ( { } ) ;
60
+ } ) ;
61
+
62
+ it ( 'throws an error' , function ( ) {
63
+ expect ( ( ) => {
64
+ new ClientEncryption ( client , {
65
+ keyVaultNamespace : 'test.keyvault' ,
66
+ kmsProviders : {
67
+ aws : { secretAccessKey : 'test' , accessKeyId : 'test' }
68
+ } ,
69
+ credentialProviders : {
70
+ aws : async ( ) => {
71
+ return {
72
+ sessionToken : 'test' ,
73
+ secretAccessKey : 'test' ,
74
+ accessKeyId : 'test'
75
+ } ;
76
+ }
77
+ }
78
+ } ) ;
79
+ } ) . to . throw ( / c u s t o m c r e d e n t i a l p r o v i d e r a n d c r e d e n t i a l s / ) ;
80
+ } ) ;
81
+ } ) ;
82
+ } ) ;
83
+ } ) ;
84
+
85
+ describe ( 'AutoEncrypter' , metadata , function ( ) {
86
+ context ( 'when a custom credential provider and credentials are provided' , function ( ) {
87
+ it ( 'throws an error' , function ( ) {
88
+ expect ( ( ) => {
89
+ this . configuration . newClient (
90
+ { } ,
91
+ {
92
+ autoEncryption : {
93
+ keyVaultNamespace : 'test.keyvault' ,
94
+ kmsProviders : {
95
+ aws : { secretAccessKey : 'test' , accessKeyId : 'test' }
96
+ } ,
97
+ credentialProviders : {
98
+ aws : async ( ) => {
99
+ return {
100
+ sessionToken : 'test' ,
101
+ secretAccessKey : 'test' ,
102
+ accessKeyId : 'test'
103
+ } ;
104
+ }
105
+ }
106
+ }
107
+ }
108
+ ) ;
109
+ } ) . to . throw ( / c u s t o m c r e d e n t i a l p r o v i d e r a n d c r e d e n t i a l s / ) ;
110
+ } ) ;
111
+ } ) ;
112
+ } ) ;
113
+
53
114
describe ( 'Collection' , metadata , function ( ) {
54
115
describe ( '#bulkWrite()' , metadata , function ( ) {
55
116
context ( 'when encryption errors' , function ( ) {
0 commit comments