Skip to content

Commit

Permalink
Use keyvault database for FLE tests
Browse files Browse the repository at this point in the history
This change was not done everywhere, so adding the rest of the places

JAVA-3702
  • Loading branch information
jyemin committed Feb 4, 2021
1 parent 9ea346b commit 351b524
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void main(final String[] args) throws InterruptedException {
}});
}};

String keyVaultNamespace = "admin.datakeys";
String keyVaultNamespace = "keyvault.datakeys";
ClientEncryptionSettings clientEncryptionSettings = ClientEncryptionSettings.builder()
.keyVaultMongoClientSettings(MongoClientSettings.builder()
.applyConnectionString(new ConnectionString("mongodb://localhost"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void main(final String[] args) throws InterruptedException {
}});
}};

String keyVaultNamespace = "admin.datakeys";
String keyVaultNamespace = "keyvault.datakeys";

AutoEncryptionSettings autoEncryptionSettings = AutoEncryptionSettings.builder()
.keyVaultNamespace(keyVaultNamespace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ public void setUp() throws IOException, URISyntaxException {
documentCallback.get();

// Step 3: Drop and create keyvault.datakeys
MongoDatabase adminDatabase = client.getDatabase("admin");
MongoCollection<BsonDocument> dataKeysCollection = adminDatabase.getCollection("datakeys", BsonDocument.class)
MongoDatabase keyvaultDatabase = client.getDatabase("keyvault");
MongoCollection<BsonDocument> dataKeysCollection = keyvaultDatabase.getCollection("datakeys", BsonDocument.class)
.withWriteConcern(WriteConcern.MAJORITY);

voidCallback = new FutureResultCallback<Void>();
Expand Down Expand Up @@ -150,7 +150,7 @@ public void setUp() throws IOException, URISyntaxException {
ClientEncryptionSettings clientEncryptionSettings = ClientEncryptionSettings.builder().
keyVaultMongoClientSettings(getMongoClientSettings()).
kmsProviders(kmsProviders).
keyVaultNamespace("admin.datakeys").build();
keyVaultNamespace("keyvault.datakeys").build();
clientEncryption = ClientEncryptions.create(clientEncryptionSettings);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public void setUp() throws IOException, URISyntaxException {

/* Step 1: get unencrypted client and recreate keys collection */
client = getMongoClient();
MongoDatabase admin = client.getDatabase("admin");
MongoCollection<BsonDocument> datakeys = admin.getCollection("datakeys", BsonDocument.class)
MongoDatabase keyvaultDatabase = client.getDatabase("keyvault");
MongoCollection<BsonDocument> datakeys = keyvaultDatabase.getCollection("datakeys", BsonDocument.class)
.withWriteConcern(WriteConcern.MAJORITY);
FutureResultCallback<Void> voidCallback = new FutureResultCallback<Void>();
datakeys.drop(voidCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class ClientSideEncryptionMongocryptdSpawnBypassTest extends DatabaseTestCase {
private final File pidFile;
private final Map<String, Map<String, Object>> kmsProviders;
private final MongoNamespace keyVaultNamespace = new MongoNamespace("admin.datakeys");
private final MongoNamespace keyVaultNamespace = new MongoNamespace("keyvault.datakeys");

public ClientSideEncryptionMongocryptdSpawnBypassTest() throws IOException {
assumeFalse(isNotAtLeastJava8());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public void setUp() {
callback.get(30, TimeUnit.SECONDS);
}

/* Insert data into the "admin.datakeys" key vault. */
collection = getMongoClient().getDatabase("admin").getCollection("datakeys", BsonDocument.class)
/* Insert data into the "keyvault.datakeys" key vault. */
collection = getMongoClient().getDatabase("keyvault").getCollection("datakeys", BsonDocument.class)
.withWriteConcern(WriteConcern.MAJORITY);
callback = new FutureResultCallback<Void>();
collection.drop(callback);
Expand Down Expand Up @@ -224,7 +224,7 @@ public void setUp() {
}
}

String keyVaultNamespace = "admin.datakeys";
String keyVaultNamespace = "keyvault.datakeys";
if (cryptOptions.containsKey("keyVaultNamespace")) {
keyVaultNamespace = cryptOptions.getString("keyVaultNamespace").getValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void setUp() {
kmsProviders.put("local", localMasterkey);

AutoEncryptionSettings.Builder autoEncryptionSettingsBuilder = AutoEncryptionSettings.builder()
.keyVaultNamespace("admin.datakeys")
.keyVaultNamespace("keyvault.datakeys")
.kmsProviders(kmsProviders);

AutoEncryptionSettings autoEncryptionSettings = autoEncryptionSettingsBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void main(final String[] args) {
}});
}};

String keyVaultNamespace = "admin.datakeys";
String keyVaultNamespace = "keyvault.datakeys";
ClientEncryptionSettings clientEncryptionSettings = ClientEncryptionSettings.builder()
.keyVaultMongoClientSettings(MongoClientSettings.builder()
.applyConnectionString(new ConnectionString("mongodb://localhost"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static void main(final String[] args) {
}});
}};

String keyVaultNamespace = "admin.datakeys";
String keyVaultNamespace = "keyvault.datakeys";

AutoEncryptionSettings autoEncryptionSettings = AutoEncryptionSettings.builder()
.keyVaultNamespace(keyVaultNamespace)
Expand Down

0 comments on commit 351b524

Please sign in to comment.