@@ -132,6 +132,20 @@ test_mongoc_scram_sasl_prep (void)
132
132
}
133
133
#endif
134
134
135
+ static void
136
+ _clear_scram_users (void )
137
+ {
138
+ mongoc_client_t * const client = test_framework_new_default_client ();
139
+ ASSERT (client );
140
+ mongoc_database_t * const db = mongoc_client_get_database (client , "admin" );
141
+ ASSERT (db );
142
+ (void ) mongoc_database_remove_user (db , "sha1" , NULL );
143
+ (void ) mongoc_database_remove_user (db , "sha256" , NULL );
144
+ (void ) mongoc_database_remove_user (db , "both" , NULL );
145
+ mongoc_database_destroy (db );
146
+ mongoc_client_destroy (client );
147
+ }
148
+
135
149
static void
136
150
_create_scram_users (void )
137
151
{
@@ -424,6 +438,8 @@ test_mongoc_scram_auth (void *ctx)
424
438
{
425
439
BSON_UNUSED (ctx );
426
440
441
+ _clear_scram_users ();
442
+
427
443
/* Auth spec: "Create three test users, one with only SHA-1, one with only
428
444
* SHA-256 and one with both" */
429
445
_create_scram_users ();
@@ -483,6 +499,19 @@ skip_if_icu (void)
483
499
return !skip_if_no_icu ();
484
500
}
485
501
502
+ static void
503
+ _clear_saslprep_users (void )
504
+ {
505
+ mongoc_client_t * const client = test_framework_new_default_client ();
506
+ ASSERT (client );
507
+ mongoc_database_t * const db = mongoc_client_get_database (client , "admin" );
508
+ ASSERT (db );
509
+ (void ) mongoc_database_remove_user (db , "IX" , NULL );
510
+ (void ) mongoc_database_remove_user (db , ROMAN_NUMERAL_NINE , NULL );
511
+ mongoc_database_destroy (db );
512
+ mongoc_client_destroy (client );
513
+ }
514
+
486
515
static void
487
516
_create_saslprep_users (void )
488
517
{
@@ -607,6 +636,7 @@ test_mongoc_saslprep_auth (void *ctx)
607
636
{
608
637
BSON_UNUSED (ctx );
609
638
639
+ _clear_saslprep_users ();
610
640
_create_saslprep_users ();
611
641
_test_mongoc_scram_saslprep_auth (false);
612
642
_test_mongoc_scram_saslprep_auth (true);
@@ -632,6 +662,7 @@ test_mongoc_saslprep_auth_no_icu (void *ctx)
632
662
{
633
663
BSON_UNUSED (ctx );
634
664
665
+ _clear_saslprep_users ();
635
666
_create_saslprep_users ();
636
667
_test_mongoc_scram_saslprep_auth_no_icu (false);
637
668
_test_mongoc_scram_saslprep_auth_no_icu (true);
0 commit comments