@@ -5365,6 +5365,45 @@ _not_have_aws_creds_env (void *unused)
5365
5365
return !_have_aws_creds_env (unused );
5366
5366
}
5367
5367
5368
+ // Test calling mongoc_collection_drop with a NULL bson_error_t when the state
5369
+ // collections do not exist. This is a regression test for CDRIVER-4457.
5370
+ static void
5371
+ test_drop_qe_null_error (void * unused )
5372
+ {
5373
+ bson_error_t error ;
5374
+ mongoc_client_t * const client = test_framework_new_default_client ();
5375
+ bson_t * const kmsProviders =
5376
+ _make_kms_providers (false /* with aws */ , true /* with local */ );
5377
+ bson_t * encryptedFieldsMap ;
5378
+ mongoc_client_t * encryptedClient ;
5379
+ mongoc_auto_encryption_opts_t * aeOpts ;
5380
+ mongoc_collection_t * coll ;
5381
+
5382
+ BSON_UNUSED (unused );
5383
+
5384
+ /* Create an encryptedFieldsMap. */
5385
+ encryptedFieldsMap = BCON_NEW ("db.encrypted" , "{" , "fields" , "[" , "]" , "}" );
5386
+ encryptedClient = test_framework_new_default_client ();
5387
+ aeOpts = mongoc_auto_encryption_opts_new ();
5388
+ mongoc_auto_encryption_opts_set_kms_providers (aeOpts , kmsProviders );
5389
+ mongoc_auto_encryption_opts_set_keyvault_namespace (
5390
+ aeOpts , "keyvault" , "datakeys" );
5391
+ mongoc_auto_encryption_opts_set_encrypted_fields_map (aeOpts ,
5392
+ encryptedFieldsMap );
5393
+ ASSERT_OR_PRINT (
5394
+ mongoc_client_enable_auto_encryption (encryptedClient , aeOpts , & error ),
5395
+ error );
5396
+ coll = mongoc_client_get_collection (encryptedClient , "db" , "encrypted" );
5397
+ ASSERT (mongoc_collection_drop (coll , NULL ));
5398
+
5399
+ mongoc_collection_destroy (coll );
5400
+ mongoc_auto_encryption_opts_destroy (aeOpts );
5401
+ mongoc_client_destroy (encryptedClient );
5402
+ bson_destroy (encryptedFieldsMap );
5403
+ bson_destroy (kmsProviders );
5404
+ mongoc_client_destroy (client );
5405
+ }
5406
+
5368
5407
void
5369
5408
test_client_side_encryption_install (TestSuite * suite )
5370
5409
{
@@ -5657,4 +5696,12 @@ test_client_side_encryption_install (TestSuite *suite)
5657
5696
test_framework_skip_if_no_client_side_encryption ,
5658
5697
test_framework_skip_if_max_wire_version_less_than_8 ,
5659
5698
_have_aws_creds_env );
5699
+
5700
+ TestSuite_AddFull (suite ,
5701
+ "/client_side_encryption/drop_qe_null_error" ,
5702
+ test_drop_qe_null_error ,
5703
+ NULL ,
5704
+ NULL ,
5705
+ test_framework_skip_if_no_client_side_encryption ,
5706
+ test_framework_skip_if_max_wire_version_less_than_8 );
5660
5707
}
0 commit comments