@@ -6244,18 +6244,11 @@ test_auto_datakeys (void *unused)
6244
6244
}
6245
6245
6246
6246
static void
6247
- _do_cec_test (void (* test ) (const char * kmsProvider , const bson_t * masterKey ))
6247
+ _do_cec_test (void (* test ) (const char * kmsProvider ))
6248
6248
{
6249
6249
// Run the test using the "local" key:
6250
- test ("local" , NULL );
6251
- // Run the test using an AWS key:
6252
- bsonBuildDecl (masterKey ,
6253
- kv ("region" , cstr ("us-east-1" )),
6254
- kv ("key" ,
6255
- cstr ("arn:aws:kms:us-east-1:579766882180:key/"
6256
- "89fcc2c4-08b0-4bd9-9f25-e30687b580d0" )));
6257
- test ("aws" , & masterKey );
6258
- bson_destroy (& masterKey );
6250
+ test ("local" );
6251
+ test ("aws" );
6259
6252
}
6260
6253
6261
6254
// Declare a createEncryptedCollection test case (See usage below)
@@ -6268,13 +6261,11 @@ _do_cec_test (void (*test) (const char *kmsProvider, const bson_t *masterKey))
6268
6261
} \
6269
6262
static void name##_impl (__VA_ARGS__)
6270
6263
6271
- CEC_TEST (test_create_encrypted_collection_simple ,
6272
- const char * kmsProvider ,
6273
- const bson_t * opt_masterKey )
6264
+ CEC_TEST (test_create_encrypted_collection_simple , const char * kmsProvider )
6274
6265
{
6275
6266
bson_error_t error = {0 };
6276
6267
mongoc_client_t * const client = test_framework_new_default_client ();
6277
- bson_t * const kmsProviders = _make_kms_providers (false , true);
6268
+ bson_t * const kmsProviders = _make_kms_providers (true , true);
6278
6269
6279
6270
const char * const dbName = "cec-test-db" ;
6280
6271
@@ -6315,17 +6306,13 @@ CEC_TEST (test_create_encrypted_collection_simple,
6315
6306
kv ("bsonType" , cstr ("string" )),
6316
6307
kv ("keyId" , null )))))));
6317
6308
mongoc_database_t * const db = mongoc_client_get_database (client , dbName );
6309
+ bson_t * const mkey = _make_kms_masterkey (kmsProvider );
6318
6310
mongoc_collection_t * const coll =
6319
- mongoc_client_encryption_create_encrypted_collection (ce ,
6320
- db ,
6321
- "test-coll" ,
6322
- & ccOpts ,
6323
- NULL ,
6324
- kmsProvider ,
6325
- opt_masterKey ,
6326
- & error );
6311
+ mongoc_client_encryption_create_encrypted_collection (
6312
+ ce , db , "test-coll" , & ccOpts , NULL , kmsProvider , mkey , & error );
6327
6313
ASSERT_OR_PRINT (coll , error );
6328
6314
bson_destroy (& ccOpts );
6315
+ bson_destroy (mkey );
6329
6316
6330
6317
bsonBuildDecl (doc , kv ("ssn" , cstr ("123-45-6789" )));
6331
6318
const bool okay =
@@ -6350,11 +6337,10 @@ test_create_encrypted_collection_no_encryptedFields_helper (
6350
6337
mongoc_client_t * client ,
6351
6338
const char * dbName ,
6352
6339
const char * collName ,
6353
- const char * kmsProvider ,
6354
- const bson_t * const opt_masterKey )
6340
+ const char * kmsProvider )
6355
6341
{
6356
6342
bson_error_t error = {0 };
6357
- bson_t * const kmsProviders = _make_kms_providers (false , true);
6343
+ bson_t * const kmsProviders = _make_kms_providers (true , true);
6358
6344
6359
6345
// Drop prior data
6360
6346
{
@@ -6388,14 +6374,16 @@ test_create_encrypted_collection_no_encryptedFields_helper (
6388
6374
// Create the encrypted collection
6389
6375
bsonBuildDecl (ccOpts , do ());
6390
6376
mongoc_database_t * const db = mongoc_client_get_database (client , dbName );
6377
+ bson_t * const mkey = _make_kms_masterkey (kmsProvider );
6391
6378
mongoc_collection_t * const coll =
6392
6379
mongoc_client_encryption_create_encrypted_collection (
6393
- ce , db , collName , & ccOpts , NULL , kmsProvider , opt_masterKey , & error );
6380
+ ce , db , collName , & ccOpts , NULL , kmsProvider , mkey , & error );
6394
6381
ASSERT_ERROR_CONTAINS (error ,
6395
6382
MONGOC_ERROR_COMMAND ,
6396
6383
MONGOC_ERROR_COMMAND_INVALID_ARG ,
6397
6384
"No 'encryptedFields' are defined" );
6398
6385
bson_destroy (& ccOpts );
6386
+ bson_destroy (mkey );
6399
6387
6400
6388
bson_destroy (kmsProviders );
6401
6389
mongoc_collection_destroy (coll );
@@ -6405,8 +6393,7 @@ test_create_encrypted_collection_no_encryptedFields_helper (
6405
6393
}
6406
6394
6407
6395
CEC_TEST (test_create_encrypted_collection_no_encryptedFields ,
6408
- const char * kmsProvider ,
6409
- const bson_t * const opt_masterKey )
6396
+ const char * kmsProvider )
6410
6397
{
6411
6398
const char * dbName = "cec-test-db" ;
6412
6399
const char * collName = "test-coll" ;
@@ -6415,7 +6402,7 @@ CEC_TEST (test_create_encrypted_collection_no_encryptedFields,
6415
6402
{
6416
6403
mongoc_client_t * const client = test_framework_new_default_client ();
6417
6404
test_create_encrypted_collection_no_encryptedFields_helper (
6418
- client , dbName , collName , kmsProvider , opt_masterKey );
6405
+ client , dbName , collName , kmsProvider );
6419
6406
mongoc_client_destroy (client );
6420
6407
}
6421
6408
@@ -6427,7 +6414,7 @@ CEC_TEST (test_create_encrypted_collection_no_encryptedFields,
6427
6414
mongoc_auto_encryption_opts_t * aeOpts =
6428
6415
mongoc_auto_encryption_opts_new ();
6429
6416
bson_t * const kmsProviders =
6430
- _make_kms_providers (false /* with aws */ , true /* with local */ );
6417
+ _make_kms_providers (true /* with aws */ , true /* with local */ );
6431
6418
char * namespace = bson_strdup_printf ("%s.%s" , dbName , collName );
6432
6419
bson_t * encryptedFieldsMap =
6433
6420
tmp_bson ("{'%s': {'fields': []}}" , namespace );
@@ -6442,7 +6429,7 @@ CEC_TEST (test_create_encrypted_collection_no_encryptedFields,
6442
6429
mongoc_client_enable_auto_encryption (client , aeOpts , & error ), error );
6443
6430
6444
6431
test_create_encrypted_collection_no_encryptedFields_helper (
6445
- client , dbName , collName , kmsProvider , opt_masterKey );
6432
+ client , dbName , collName , kmsProvider );
6446
6433
6447
6434
bson_free (namespace );
6448
6435
bson_destroy (kmsProviders );
@@ -6452,12 +6439,11 @@ CEC_TEST (test_create_encrypted_collection_no_encryptedFields,
6452
6439
}
6453
6440
6454
6441
CEC_TEST (test_create_encrypted_collection_bad_keyId ,
6455
- const char * const kmsProvider ,
6456
- const bson_t * const opt_masterKey )
6442
+ const char * const kmsProvider )
6457
6443
{
6458
6444
bson_error_t error = {0 };
6459
6445
mongoc_client_t * const client = test_framework_new_default_client ();
6460
- bson_t * const kmsProviders = _make_kms_providers (false , true);
6446
+ bson_t * const kmsProviders = _make_kms_providers (true , true);
6461
6447
6462
6448
const char * const dbName = "cec-test-db" ;
6463
6449
@@ -6498,20 +6484,16 @@ CEC_TEST (test_create_encrypted_collection_bad_keyId,
6498
6484
kv ("bsonType" , cstr ("string" )),
6499
6485
kv ("keyId" , bool (true))))))));
6500
6486
mongoc_database_t * const db = mongoc_client_get_database (client , dbName );
6487
+ bson_t * const mkey = _make_kms_masterkey (kmsProvider );
6501
6488
mongoc_collection_t * const coll =
6502
- mongoc_client_encryption_create_encrypted_collection (ce ,
6503
- db ,
6504
- "test-coll" ,
6505
- & ccOpts ,
6506
- NULL ,
6507
- kmsProvider ,
6508
- opt_masterKey ,
6509
- & error );
6489
+ mongoc_client_encryption_create_encrypted_collection (
6490
+ ce , db , "test-coll" , & ccOpts , NULL , kmsProvider , mkey , & error );
6510
6491
ASSERT_ERROR_CONTAINS (error ,
6511
6492
MONGOC_ERROR_QUERY ,
6512
6493
MONGOC_ERROR_PROTOCOL_INVALID_REPLY ,
6513
6494
"create.encryptedFields.fields.keyId" );
6514
6495
bson_destroy (& ccOpts );
6496
+ bson_destroy (mkey );
6515
6497
6516
6498
bson_destroy (kmsProviders );
6517
6499
mongoc_collection_destroy (coll );
@@ -6523,12 +6505,11 @@ CEC_TEST (test_create_encrypted_collection_bad_keyId,
6523
6505
6524
6506
// Implements Prose Test 21. Case: 4.
6525
6507
CEC_TEST (test_create_encrypted_collection_insert ,
6526
- const char * const kmsProvider ,
6527
- const bson_t * const opt_masterKey )
6508
+ const char * const kmsProvider )
6528
6509
{
6529
6510
bson_error_t error = {0 };
6530
6511
mongoc_client_t * const client = test_framework_new_default_client ();
6531
- bson_t * const kmsProviders = _make_kms_providers (false , true);
6512
+ bson_t * const kmsProviders = _make_kms_providers (true , true);
6532
6513
6533
6514
const char * const dbName = "cec-test-db" ;
6534
6515
@@ -6570,17 +6551,13 @@ CEC_TEST (test_create_encrypted_collection_insert,
6570
6551
kv ("keyId" , null )))))));
6571
6552
mongoc_database_t * const db = mongoc_client_get_database (client , dbName );
6572
6553
bson_t new_opts ;
6554
+ bson_t * const mkey = _make_kms_masterkey (kmsProvider );
6573
6555
mongoc_collection_t * const coll =
6574
- mongoc_client_encryption_create_encrypted_collection (ce ,
6575
- db ,
6576
- "testing1" ,
6577
- & ccOpts ,
6578
- & new_opts ,
6579
- kmsProvider ,
6580
- opt_masterKey ,
6581
- & error );
6556
+ mongoc_client_encryption_create_encrypted_collection (
6557
+ ce , db , "testing1" , & ccOpts , & new_opts , kmsProvider , mkey , & error );
6582
6558
ASSERT_OR_PRINT (coll , error );
6583
6559
bson_destroy (& ccOpts );
6560
+ bson_destroy (mkey );
6584
6561
6585
6562
// Extract the encryption key ID that was generated by
6586
6563
// CreateEncryptedCollection:
0 commit comments