From 11b7d5e89c82859baba78bb2e543cae944fa5c4f Mon Sep 17 00:00:00 2001 From: Michael Law <1365977+lawmicha@users.noreply.github.com> Date: Mon, 22 Jan 2024 13:04:28 -0500 Subject: [PATCH] fix(DataStore): retry on session expired requests (#3477) * fix(DataStore): retry on session expired requests * add test --- .../Sync/RequestRetryablePolicyTests.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/RequestRetryablePolicyTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/RequestRetryablePolicyTests.swift index 39a83e9015..bf4e51baa7 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/RequestRetryablePolicyTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/RequestRetryablePolicyTests.swift @@ -199,6 +199,17 @@ class RequestRetryablePolicyTests: XCTestCase { assertMilliseconds(retryAdvice.retryInterval, greaterThan: 200, lessThan: 300) } + func testUserAuthenticationRequiredError() { + let retryableErrorCode = URLError.init(.userAuthenticationRequired) + + let retryAdvice = retryPolicy.retryRequestAdvice(urlError: retryableErrorCode, + httpURLResponse: nil, + attemptNumber: 1) + + XCTAssert(retryAdvice.shouldRetry) + assertMilliseconds(retryAdvice.retryInterval, greaterThan: 200, lessThan: 300) + } + func testHTTPTooManyRedirectsError() { let nonRetryableErrorCode = URLError.init(.httpTooManyRedirects)