@@ -445,7 +445,6 @@ static void _test_create_datakey_with_retry(_mongocrypt_tester_t *tester) {
445
445
ASSERT_OK (mongocrypt_kms_ctx_feed (kms_ctx , TEST_FILE ("./test/data/rmd/kms-decrypt-reply-429.txt" )), kms_ctx );
446
446
// In-place retry is indicated.
447
447
ASSERT (mongocrypt_kms_ctx_should_retry (kms_ctx ));
448
- ASSERT (mongocrypt_kms_ctx_fail (kms_ctx ));
449
448
// Feed a successful response.
450
449
ASSERT_OK (mongocrypt_kms_ctx_feed (kms_ctx , TEST_FILE ("./test/data/kms-aws/encrypt-response.txt" )), kms_ctx );
451
450
ASSERT_OK (mongocrypt_ctx_kms_done (ctx ), ctx );
@@ -454,6 +453,44 @@ static void _test_create_datakey_with_retry(_mongocrypt_tester_t *tester) {
454
453
mongocrypt_destroy (crypt );
455
454
}
456
455
456
+ // Test that HTTP error can be retried after two retryable errors:
457
+ {
458
+ mongocrypt_t * crypt = _mongocrypt_tester_mongocrypt (TESTER_MONGOCRYPT_DEFAULT );
459
+ mongocrypt_ctx_t * ctx = mongocrypt_ctx_new (crypt );
460
+ ASSERT_OK (
461
+ mongocrypt_ctx_setopt_key_encryption_key (ctx ,
462
+ TEST_BSON ("{'provider': 'aws', 'key': 'foo', 'region': 'bar'}" )),
463
+ ctx );
464
+ ASSERT_OK (mongocrypt_ctx_datakey_init (ctx ), ctx );
465
+ ASSERT_STATE_EQUAL (mongocrypt_ctx_state (ctx ), MONGOCRYPT_CTX_NEED_KMS );
466
+ mongocrypt_kms_ctx_t * kms = mongocrypt_ctx_next_kms_ctx (ctx );
467
+ ASSERT_OK (kms , ctx );
468
+ mongocrypt_binary_t * retryable_http = TEST_FILE ("./test/data/rmd/kms-decrypt-reply-429.txt" );
469
+
470
+ // Feed a retryable HTTP error:
471
+ {
472
+ ASSERT_OK (mongocrypt_kms_ctx_feed (kms , retryable_http ), kms );
473
+ ASSERT (mongocrypt_kms_ctx_should_retry (kms ));
474
+ }
475
+
476
+ // Feed a retryable HTTP error again:
477
+ {
478
+ ASSERT_OK (mongocrypt_kms_ctx_feed (kms , retryable_http ), kms );
479
+ ASSERT (mongocrypt_kms_ctx_should_retry (kms ));
480
+ }
481
+
482
+ // Feed a successful response:
483
+ {
484
+ ASSERT_OK (mongocrypt_kms_ctx_feed (kms , TEST_FILE ("./test/data/kms-aws/encrypt-response.txt" )), kms );
485
+ ASSERT_OK (mongocrypt_ctx_kms_done (ctx ), ctx );
486
+ _mongocrypt_tester_run_ctx_to (tester , ctx , MONGOCRYPT_CTX_DONE );
487
+ }
488
+
489
+ _mongocrypt_tester_run_ctx_to (tester , ctx , MONGOCRYPT_CTX_DONE );
490
+ mongocrypt_ctx_destroy (ctx );
491
+ mongocrypt_destroy (crypt );
492
+ }
493
+
457
494
// Test that a network error is retried.
458
495
{
459
496
mongocrypt_t * crypt = _mongocrypt_tester_mongocrypt (TESTER_MONGOCRYPT_DEFAULT );
0 commit comments