@@ -2641,9 +2641,10 @@ test_bypass_spawning_via_helper (const char *auto_encryption_opt)
2641
2641
mongoc_auto_encryption_opts_t * auto_encryption_opts ;
2642
2642
bson_t * kms_providers ;
2643
2643
bson_t * doc_to_insert ;
2644
- bson_t * extra ;
2644
+ bson_t * extra = bson_new () ;
2645
2645
bool ret ;
2646
2646
bson_error_t error ;
2647
+ bool check_crypt_shared = false;
2647
2648
mongoc_collection_t * coll ;
2648
2649
2649
2650
auto_encryption_opts = mongoc_auto_encryption_opts_new ();
@@ -2658,24 +2659,38 @@ test_bypass_spawning_via_helper (const char *auto_encryption_opt)
2658
2659
} else if (0 == strcmp (auto_encryption_opt , "bypass_query_analysis" )) {
2659
2660
mongoc_auto_encryption_opts_set_bypass_query_analysis (
2660
2661
auto_encryption_opts , true);
2662
+ } else if (0 == strcmp (auto_encryption_opt , "cryptSharedLibRequired" )) {
2663
+ check_crypt_shared = true;
2664
+ char * env_cryptSharedLibPath =
2665
+ test_framework_getenv ("MONGOC_TEST_CRYPT_SHARED_LIB_PATH" );
2666
+ BSON_ASSERT (env_cryptSharedLibPath );
2667
+ BSON_APPEND_UTF8 (extra , "cryptSharedLibPath" , env_cryptSharedLibPath );
2668
+ BSON_APPEND_BOOL (extra , "cryptSharedLibRequired" , true);
2669
+ bson_free (env_cryptSharedLibPath );
2661
2670
} else {
2662
2671
test_error ("Unexpected 'auto_encryption_opt' argument: %s" ,
2663
2672
auto_encryption_opt );
2664
2673
}
2665
2674
2666
2675
/* Create a MongoClient with encryption enabled */
2667
2676
client_encrypted = test_framework_new_default_client ();
2668
- extra = BCON_NEW ("mongocryptdSpawnArgs" ,
2669
- "[" ,
2670
- "--pidfilepath=bypass-spawning-mongocryptd.pid" ,
2671
- "--port=27021" ,
2672
- "]" );
2677
+ BCON_APPEND (extra ,
2678
+ "mongocryptdSpawnArgs" ,
2679
+ "[" ,
2680
+ "--pidfilepath=bypass-spawning-mongocryptd.pid" ,
2681
+ "--port=27021" ,
2682
+ "]" );
2673
2683
mongoc_auto_encryption_opts_set_extra (auto_encryption_opts , extra );
2674
2684
bson_destroy (extra );
2675
2685
ret = mongoc_client_enable_auto_encryption (
2676
2686
client_encrypted , auto_encryption_opts , & error );
2677
2687
ASSERT_OR_PRINT (ret , error );
2678
2688
2689
+ if (check_crypt_shared ) {
2690
+ BSON_ASSERT (mongoc_client_get_crypt_shared_version (client_encrypted ) !=
2691
+ NULL );
2692
+ }
2693
+
2679
2694
/* Insert { 'encrypt': 'test' }. Should succeed. */
2680
2695
coll = mongoc_client_get_collection (client_encrypted , "db" , "coll" );
2681
2696
doc_to_insert = BCON_NEW ("unencrypted" , "test" );
@@ -2710,6 +2725,24 @@ test_bypass_spawning_via_bypassQueryAnalysis (void *unused)
2710
2725
test_bypass_spawning_via_helper ("bypass_query_analysis" );
2711
2726
}
2712
2727
2728
+ static void
2729
+ test_bypass_spawning_via_cryptSharedLibRequired (void * unused )
2730
+ {
2731
+ BSON_UNUSED (unused );
2732
+ test_bypass_spawning_via_helper ("cryptSharedLibRequired" );
2733
+ }
2734
+
2735
+ static int
2736
+ _skip_if_no_crypt_shared (void )
2737
+ {
2738
+ char * env = test_framework_getenv ("MONGOC_TEST_CRYPT_SHARED_LIB_PATH" );
2739
+ if (!env ) {
2740
+ return 0 ; // Skip!
2741
+ }
2742
+ bson_free (env );
2743
+ return 1 ; // Do not skip
2744
+ }
2745
+
2713
2746
static mongoc_client_encryption_t *
2714
2747
_make_kms_certificate_client_encryption (mongoc_client_t * client ,
2715
2748
bson_error_t * error )
@@ -5413,6 +5446,15 @@ test_client_side_encryption_install (TestSuite *suite)
5413
5446
NULL ,
5414
5447
test_framework_skip_if_no_client_side_encryption ,
5415
5448
test_framework_skip_if_max_wire_version_less_than_8 );
5449
+ TestSuite_AddFull (suite ,
5450
+ "/client_side_encryption/bypass_spawning_mongocryptd/"
5451
+ "cryptSharedLibRequired" ,
5452
+ test_bypass_spawning_via_cryptSharedLibRequired ,
5453
+ NULL ,
5454
+ NULL ,
5455
+ test_framework_skip_if_no_client_side_encryption ,
5456
+ test_framework_skip_if_max_wire_version_less_than_8 ,
5457
+ _skip_if_no_crypt_shared );
5416
5458
TestSuite_AddFull (suite ,
5417
5459
"/client_side_encryption/kms_tls/valid" ,
5418
5460
test_kms_tls_cert_valid ,
0 commit comments