@@ -2511,10 +2511,11 @@ static void _test_encrypt_fle2_explicit(_mongocrypt_tester_t *tester) {
25112511 }
25122512
25132513 {
2514+ // "suffixPreview" is a deprecated alias for "suffix" and must produce identical output.
25142515 ee_testcase tc = {0 };
2515- tc .desc = "find suffix " ;
2516+ tc .desc = "find suffixPreview " ;
25162517 tc .algorithm = MONGOCRYPT_ALGORITHM_STRING_STR ;
2517- tc .query_type = MONGOCRYPT_QUERY_TYPE_SUFFIX_STR ;
2518+ tc .query_type = MONGOCRYPT_QUERY_TYPE_SUFFIXPREVIEW_DEPRECATED_STR ;
25182519 tc .contention_factor = OPT_I64 (1 );
25192520 tc .msg = TEST_BSON ("{'v': 'abc'}" );
25202521 tc .user_key_id = & keyABC_id ;
@@ -2529,10 +2530,11 @@ static void _test_encrypt_fle2_explicit(_mongocrypt_tester_t *tester) {
25292530 }
25302531
25312532 {
2533+ // "prefixPreview" is a deprecated alias for "prefix" and must produce identical output.
25322534 ee_testcase tc = {0 };
2533- tc .desc = "find prefix " ;
2535+ tc .desc = "find prefixPreview " ;
25342536 tc .algorithm = MONGOCRYPT_ALGORITHM_STRING_STR ;
2535- tc .query_type = MONGOCRYPT_QUERY_TYPE_PREFIX_STR ;
2537+ tc .query_type = MONGOCRYPT_QUERY_TYPE_PREFIXPREVIEW_DEPRECATED_STR ;
25362538 tc .contention_factor = OPT_I64 (1 );
25372539 tc .msg = TEST_BSON ("{'v': 'abc'}" );
25382540 tc .user_key_id = & keyABC_id ;
@@ -4410,8 +4412,9 @@ static void _test_rangePreview_fails(_mongocrypt_tester_t *tester) {
44104412 bson_free (local_kek );
44114413}
44124414
4413- // `_test_prefixPreview_suffixPreview_fails` tests that use of "prefixPreview" or "suffixPreview" errors.
4414- static void _test_prefixPreview_suffixPreview_fails (_mongocrypt_tester_t * tester ) {
4415+ // `_test_prefixPreview_suffixPreview_succeeds` tests that "prefixPreview" and "suffixPreview" are accepted as
4416+ // deprecated aliases for "prefix" and "suffix".
4417+ static void _test_prefixPreview_suffixPreview_succeeds (_mongocrypt_tester_t * tester ) {
44154418#define TF (suffix ) TEST_FILE("./test/data/fle2-insert-text-search-preview/" suffix)
44164419
44174420 // local_kek is the KEK used to encrypt the keyMaterial in ./test/data/key-document-local.json
@@ -4420,35 +4423,31 @@ static void _test_prefixPreview_suffixPreview_fails(_mongocrypt_tester_t *tester
44204423 mongocrypt_binary_t * kms_providers =
44214424 TEST_BSON (BSON_STR ({"local" : {"key" : {"$binary" : {"base64" : "%s ", " subType " : " 00 "}}}}), local_kek);
44224425
4423- // Test setting 'prefixPreview' as an explicit encryption queryType results in error .
4426+ // Test setting 'prefixPreview' as an explicit encryption queryType succeeds .
44244427 {
44254428 mongocrypt_t * crypt = mongocrypt_new ();
44264429 mongocrypt_setopt_kms_providers (crypt , kms_providers );
44274430 ASSERT_OK (mongocrypt_init (crypt ), crypt );
44284431 mongocrypt_ctx_t * ctx = mongocrypt_ctx_new (crypt );
44294432 ASSERT_OK (ctx , crypt );
4430- ASSERT_FAILS (mongocrypt_ctx_setopt_query_type (ctx , MONGOCRYPT_QUERY_TYPE_PREFIXPREVIEW_DEPRECATED_STR , -1 ),
4431- ctx ,
4432- "Query type 'prefixPreview' is deprecated" );
4433+ ASSERT_OK (mongocrypt_ctx_setopt_query_type (ctx , MONGOCRYPT_QUERY_TYPE_PREFIXPREVIEW_DEPRECATED_STR , -1 ), ctx );
44334434 mongocrypt_ctx_destroy (ctx );
44344435 mongocrypt_destroy (crypt );
44354436 }
44364437
4437- // Test setting 'suffixPreview' as an explicit encryption queryType results in error .
4438+ // Test setting 'suffixPreview' as an explicit encryption queryType succeeds .
44384439 {
44394440 mongocrypt_t * crypt = mongocrypt_new ();
44404441 mongocrypt_setopt_kms_providers (crypt , kms_providers );
44414442 ASSERT_OK (mongocrypt_init (crypt ), crypt );
44424443 mongocrypt_ctx_t * ctx = mongocrypt_ctx_new (crypt );
44434444 ASSERT_OK (ctx , crypt );
4444- ASSERT_FAILS (mongocrypt_ctx_setopt_query_type (ctx , MONGOCRYPT_QUERY_TYPE_SUFFIXPREVIEW_DEPRECATED_STR , -1 ),
4445- ctx ,
4446- "Query type 'suffixPreview' is deprecated" );
4445+ ASSERT_OK (mongocrypt_ctx_setopt_query_type (ctx , MONGOCRYPT_QUERY_TYPE_SUFFIXPREVIEW_DEPRECATED_STR , -1 ), ctx );
44474446 mongocrypt_ctx_destroy (ctx );
44484447 mongocrypt_destroy (crypt );
44494448 }
44504449
4451- // Test setting 'prefixPreview' from encryptedFields results in error .
4450+ // Test setting 'prefixPreview' from encryptedFields succeeds .
44524451 {
44534452 mongocrypt_t * crypt = mongocrypt_new ();
44544453 mongocrypt_setopt_kms_providers (crypt , kms_providers );
@@ -4457,14 +4456,12 @@ static void _test_prefixPreview_suffixPreview_fails(_mongocrypt_tester_t *tester
44574456 ASSERT_OK (mongocrypt_init (crypt ), crypt );
44584457 mongocrypt_ctx_t * ctx = mongocrypt_ctx_new (crypt );
44594458 ASSERT_OK (ctx , crypt );
4460- ASSERT_FAILS (mongocrypt_ctx_encrypt_init (ctx , "db" , -1 , TF ("cmd.json" )),
4461- ctx ,
4462- "Cannot use field 'encrypted' with 'prefixPreview' queries" );
4459+ ASSERT_OK (mongocrypt_ctx_encrypt_init (ctx , "db" , -1 , TF ("cmd.json" )), ctx );
44634460 mongocrypt_ctx_destroy (ctx );
44644461 mongocrypt_destroy (crypt );
44654462 }
44664463
4467- // Test setting 'suffixPreview' from encryptedFields results in error .
4464+ // Test setting 'suffixPreview' from encryptedFields succeeds .
44684465 {
44694466 mongocrypt_t * crypt = mongocrypt_new ();
44704467 mongocrypt_setopt_kms_providers (crypt , kms_providers );
@@ -4473,9 +4470,7 @@ static void _test_prefixPreview_suffixPreview_fails(_mongocrypt_tester_t *tester
44734470 ASSERT_OK (mongocrypt_init (crypt ), crypt );
44744471 mongocrypt_ctx_t * ctx = mongocrypt_ctx_new (crypt );
44754472 ASSERT_OK (ctx , crypt );
4476- ASSERT_FAILS (mongocrypt_ctx_encrypt_init (ctx , "db" , -1 , TF ("cmd.json" )),
4477- ctx ,
4478- "Cannot use field 'encrypted' with 'suffixPreview' queries" );
4473+ ASSERT_OK (mongocrypt_ctx_encrypt_init (ctx , "db" , -1 , TF ("cmd.json" )), ctx );
44794474 mongocrypt_ctx_destroy (ctx );
44804475 mongocrypt_destroy (crypt );
44814476 }
@@ -6904,7 +6899,7 @@ void _mongocrypt_tester_install_ctx_encrypt(_mongocrypt_tester_t *tester) {
69046899 INSTALL_TEST (_test_encrypt_fle2_insert_text_search_payload_with_str_encode_version );
69056900 INSTALL_TEST (_test_bulkWrite );
69066901 INSTALL_TEST (_test_rangePreview_fails );
6907- INSTALL_TEST (_test_prefixPreview_suffixPreview_fails );
6902+ INSTALL_TEST (_test_prefixPreview_suffixPreview_succeeds );
69086903 INSTALL_TEST (_test_textPreview_fails );
69096904 INSTALL_TEST (_test_no_trimFactor );
69106905 INSTALL_TEST (_test_range_sends_cryptoParams );
0 commit comments