@@ -4910,7 +4910,7 @@ _test_rewrap_with_separate_client_encryption (const char *src_provider,
49104910 mongoc_client_destroy (src_client );
49114911}
49124912
4913- /* Prose Test 16: Rewrap with separate ClientEncryption */
4913+ /* Prose Test 16: Case 1: Rewrap with separate ClientEncryption */
49144914static void
49154915test_rewrap_with_separate_client_encryption (void * unused )
49164916{
@@ -4934,6 +4934,80 @@ test_rewrap_with_separate_client_encryption (void *unused)
49344934 }
49354935}
49364936
4937+ /* Prose Test 16: Case 2: RewrapManyDataKeyOpts.provider is not optional. */
4938+ static void
4939+ test_rewrap_without_provider (void * unused )
4940+ {
4941+ BSON_UNUSED (unused );
4942+
4943+ mongoc_uri_t * const uri = test_framework_get_uri ();
4944+ mongoc_client_encryption_opts_t * const ce_opts =
4945+ mongoc_client_encryption_opts_new ();
4946+ mongoc_client_t * const key_vault_client =
4947+ test_framework_client_new_from_uri (uri , NULL );
4948+
4949+ bson_error_t error = {0 };
4950+
4951+ BSON_ASSERT (uri );
4952+ BSON_ASSERT (ce_opts );
4953+ BSON_ASSERT (key_vault_client );
4954+
4955+ test_framework_set_ssl_opts (key_vault_client );
4956+
4957+ {
4958+ mongoc_client_encryption_opts_set_keyvault_client (ce_opts ,
4959+ key_vault_client );
4960+ mongoc_client_encryption_opts_set_keyvault_namespace (
4961+ ce_opts , "keyvault" , "datakeys" );
4962+
4963+ {
4964+ bson_t * const kms_providers = _make_kms_providers (true, true);
4965+ BSON_ASSERT (kms_providers );
4966+ mongoc_client_encryption_opts_set_kms_providers (ce_opts ,
4967+ kms_providers );
4968+ bson_destroy (kms_providers );
4969+ }
4970+
4971+ {
4972+ bson_t * const tls_opts = _make_tls_opts ();
4973+ BSON_ASSERT (tls_opts );
4974+ mongoc_client_encryption_opts_set_tls_opts (ce_opts , tls_opts );
4975+ bson_destroy (tls_opts );
4976+ }
4977+ }
4978+
4979+ // 1. Create a ClientEncryption object named clientEncryption with these
4980+ // options: (see ce_opts).
4981+ mongoc_client_encryption_t * clientEncryption =
4982+ mongoc_client_encryption_new (ce_opts , & error );
4983+ ASSERT_OR_PRINT (clientEncryption , error );
4984+
4985+ // 2. Call ``clientEncryption.rewrapManyDataKey`` with an empty ``filter``
4986+ // and these options: (see below).
4987+ {
4988+ bool ok =
4989+ mongoc_client_encryption_rewrap_many_datakey (clientEncryption ,
4990+ NULL /* filter */ ,
4991+ NULL /* kms_provider */ ,
4992+ tmp_bson ("{}" ),
4993+ NULL /* result */ ,
4994+ & error );
4995+ // Assert an error is returned from the driver suggesting that the
4996+ // ``provider`` option is required.
4997+ ASSERT_WITH_MSG (!ok , "expected error, but got success" );
4998+ ASSERT_ERROR_CONTAINS (
4999+ error ,
5000+ MONGOC_ERROR_CLIENT ,
5001+ MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG ,
5002+ "expected 'provider' to be set to identify type of 'master_key'" );
5003+ }
5004+
5005+ mongoc_client_encryption_destroy (clientEncryption );
5006+ mongoc_client_encryption_opts_destroy (ce_opts );
5007+ mongoc_uri_destroy (uri );
5008+ mongoc_client_destroy (key_vault_client );
5009+ }
5010+
49375011/* test_qe_docs_example tests the documentation example requested in
49385012 * CDRIVER-4379. */
49395013static void
@@ -5534,13 +5608,20 @@ test_client_side_encryption_install (TestSuite *suite)
55345608 test_framework_skip_if_no_client_side_encryption ,
55355609 test_framework_skip_if_max_wire_version_less_than_8 );
55365610 TestSuite_AddFull (suite ,
5537- "/client_side_encryption/prose_test_16" ,
5611+ "/client_side_encryption/prose_test_16/case1 " ,
55385612 test_rewrap_with_separate_client_encryption ,
55395613 NULL ,
55405614 NULL ,
55415615 test_framework_skip_if_no_client_side_encryption ,
55425616 test_framework_skip_if_max_wire_version_less_than_8 ,
55435617 test_framework_skip_if_slow );
5618+ TestSuite_AddFull (suite ,
5619+ "/client_side_encryption/prose_test_16/case2" ,
5620+ test_rewrap_without_provider ,
5621+ NULL ,
5622+ NULL ,
5623+ test_framework_skip_if_no_client_side_encryption ,
5624+ test_framework_skip_if_max_wire_version_less_than_8 );
55445625
55455626 /* Other, C driver specific, tests. */
55465627 TestSuite_AddFull (suite ,
0 commit comments