Skip to content

Commit d01d61a

Browse files
committed
Throw exception if auto-encryption is enabled for async MongoClient
JAVA-3313
1 parent dfd1c7d commit d01d61a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

driver-async/src/main/com/mongodb/async/client/MongoClientSettings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ private Builder() {
9595
}
9696

9797
private Builder(final com.mongodb.MongoClientSettings settings) {
98+
isTrue("auto-encryption settings is null", settings.getAutoEncryptionSettings() == null);
9899
notNull("settings", settings);
99100
wrappedBuilder = com.mongodb.MongoClientSettings.builder(settings);
100101
MongoCredential credential = settings.getCredential();

driver-async/src/test/functional/com/mongodb/async/client/MongoClientsSpecification.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.mongodb.async.client
1818

19+
import com.mongodb.AutoEncryptionSettings
1920
import com.mongodb.MongoCompressor
2021
import com.mongodb.MongoCredential
2122
import com.mongodb.MongoDriverInformation
@@ -252,4 +253,17 @@ class MongoClientsSpecification extends FunctionalSpecification {
252253
}
253254
client?.close()
254255
}
256+
257+
def 'should throw if AutoEncryptionSettings is not null'() {
258+
when:
259+
MongoClients.create(com.mongodb.MongoClientSettings.builder()
260+
.autoEncryptionSettings(AutoEncryptionSettings.builder()
261+
.keyVaultNamespace('test.keys')
262+
.kmsProviders([local: ['key': new byte[96]]])
263+
.build())
264+
.build())
265+
266+
then:
267+
thrown(IllegalStateException)
268+
}
255269
}

0 commit comments

Comments
 (0)