Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Update since onboarding error code (Dev) #5712

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class SrsLocalChecker @Inject constructor(
onboardingInHours
)
throw SrsSubmissionException(
errorCode = ErrorCode.TIME_SINCE_ONBOARDING_UNVERIFIED,
errorCode = ErrorCode.MIN_TIME_SINCE_ONBOARDING,
errorArgs = arrayOf(onboardingInHours.toHours(), onboardingInHours.toHours())
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class SrsSubmissionException(
TextKey.TIME_SINCE_ONBOARDING_UNVERIFIED
),

MIN_TIME_SINCE_ONBOARDING("MIN_TIME_SINCE_ONBOARDING", TextKey.TIME_SINCE_ONBOARDING_UNVERIFIED),

SRS_OTP_CLIENT_ERROR("SRS_OTP_CLIENT_ERROR", TextKey.CALL_HOTLINE),
SRS_OTP_NO_NETWORK("SRS_OTP_NO_NETWORK", TextKey.NO_NETWORK),
SRS_OTP_SERVER_ERROR("SRS_OTP_SERVER_ERROR", TextKey.TRY_AGAIN_LATER),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class SrsAuthorizationServer @Inject constructor(
errorArgs = errorArgs(errorCode)
)
}

response?.expirationDate != null -> OffsetDateTime.parse(response.expirationDate).toInstant()
else -> throw when (bodyResponse.code()) {
400 -> SrsSubmissionException(ErrorCode.SRS_OTP_400)
Expand All @@ -107,7 +108,9 @@ class SrsAuthorizationServer @Inject constructor(
.timeBetweenSubmissionsInDays
.toDays()
)
ErrorCode.TIME_SINCE_ONBOARDING_UNVERIFIED -> {

ErrorCode.TIME_SINCE_ONBOARDING_UNVERIFIED,
ErrorCode.MIN_TIME_SINCE_ONBOARDING -> {
val hours = appConfigProvider
.currentConfig
.first()
Expand All @@ -117,6 +120,7 @@ class SrsAuthorizationServer @Inject constructor(
.toHours()
arrayOf(hours, hours)
}

else -> emptyArray()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ internal class SrsLocalCheckerTest : BaseTest() {
every { cwaSettings.firstReliableDeviceTime } returns flowOf(Instant.parse("2022-11-02T10:01:22Z"))
shouldThrow<SrsSubmissionException> {
instance().check()
}.errorCode shouldBe SrsSubmissionException.ErrorCode.TIME_SINCE_ONBOARDING_UNVERIFIED
}.errorCode shouldBe SrsSubmissionException.ErrorCode.MIN_TIME_SINCE_ONBOARDING
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ internal class SrsAuthorizationServerTest : BaseTest() {
"JWS_SIGNATURE_VERIFICATION_FAILED" to ErrorCode.JWS_SIGNATURE_VERIFICATION_FAILED,
"NONCE_MISMATCH" to ErrorCode.NONCE_MISMATCH,
"SALT_REDEEMED" to ErrorCode.SALT_REDEEMED,

// Should not be thrown by server ,but just in case it is also covered
"TIME_SINCE_ONBOARDING_UNVERIFIED" to ErrorCode.TIME_SINCE_ONBOARDING_UNVERIFIED,
"MIN_TIME_SINCE_ONBOARDING" to ErrorCode.MIN_TIME_SINCE_ONBOARDING,
"SUBMISSION_TOO_EARLY" to ErrorCode.SUBMISSION_TOO_EARLY,

// iOS error that does not map to Android Error :D
"API_TOKEN_ALREADY_ISSUED" to ErrorCode.SRS_OTP_SERVER_ERROR,
).forEach { (serverErrorCode, errorCode) ->
Expand Down