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

Commit db14001

Browse files
authored
Update since onboarding error code (Dev) (#5712)
1 parent 8225591 commit db14001

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

Corona-Warn-App/src/main/java/de/rki/coronawarnapp/srs/core/SrsLocalChecker.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class SrsLocalChecker @Inject constructor(
6060
onboardingInHours
6161
)
6262
throw SrsSubmissionException(
63-
errorCode = ErrorCode.TIME_SINCE_ONBOARDING_UNVERIFIED,
63+
errorCode = ErrorCode.MIN_TIME_SINCE_ONBOARDING,
6464
errorArgs = arrayOf(onboardingInHours.toHours(), onboardingInHours.toHours())
6565
)
6666
}

Corona-Warn-App/src/main/java/de/rki/coronawarnapp/srs/core/error/SrsSubmissionException.kt

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class SrsSubmissionException(
2222
TextKey.TIME_SINCE_ONBOARDING_UNVERIFIED
2323
),
2424

25+
MIN_TIME_SINCE_ONBOARDING("MIN_TIME_SINCE_ONBOARDING", TextKey.TIME_SINCE_ONBOARDING_UNVERIFIED),
26+
2527
SRS_OTP_CLIENT_ERROR("SRS_OTP_CLIENT_ERROR", TextKey.CALL_HOTLINE),
2628
SRS_OTP_NO_NETWORK("SRS_OTP_NO_NETWORK", TextKey.NO_NETWORK),
2729
SRS_OTP_SERVER_ERROR("SRS_OTP_SERVER_ERROR", TextKey.TRY_AGAIN_LATER),

Corona-Warn-App/src/main/java/de/rki/coronawarnapp/srs/core/server/SrsAuthorizationServer.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class SrsAuthorizationServer @Inject constructor(
8585
errorArgs = errorArgs(errorCode)
8686
)
8787
}
88+
8889
response?.expirationDate != null -> OffsetDateTime.parse(response.expirationDate).toInstant()
8990
else -> throw when (bodyResponse.code()) {
9091
400 -> SrsSubmissionException(ErrorCode.SRS_OTP_400)
@@ -107,7 +108,9 @@ class SrsAuthorizationServer @Inject constructor(
107108
.timeBetweenSubmissionsInDays
108109
.toDays()
109110
)
110-
ErrorCode.TIME_SINCE_ONBOARDING_UNVERIFIED -> {
111+
112+
ErrorCode.TIME_SINCE_ONBOARDING_UNVERIFIED,
113+
ErrorCode.MIN_TIME_SINCE_ONBOARDING -> {
111114
val hours = appConfigProvider
112115
.currentConfig
113116
.first()
@@ -117,6 +120,7 @@ class SrsAuthorizationServer @Inject constructor(
117120
.toHours()
118121
arrayOf(hours, hours)
119122
}
123+
120124
else -> emptyArray()
121125
}
122126

Corona-Warn-App/src/test/java/de/rki/coronawarnapp/srs/core/SrsLocalCheckerTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ internal class SrsLocalCheckerTest : BaseTest() {
7171
every { cwaSettings.firstReliableDeviceTime } returns flowOf(Instant.parse("2022-11-02T10:01:22Z"))
7272
shouldThrow<SrsSubmissionException> {
7373
instance().check()
74-
}.errorCode shouldBe SrsSubmissionException.ErrorCode.TIME_SINCE_ONBOARDING_UNVERIFIED
74+
}.errorCode shouldBe SrsSubmissionException.ErrorCode.MIN_TIME_SINCE_ONBOARDING
7575
}
7676

7777
@Test

Corona-Warn-App/src/test/java/de/rki/coronawarnapp/srs/core/server/SrsAuthorizationServerTest.kt

+6
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ internal class SrsAuthorizationServerTest : BaseTest() {
131131
"JWS_SIGNATURE_VERIFICATION_FAILED" to ErrorCode.JWS_SIGNATURE_VERIFICATION_FAILED,
132132
"NONCE_MISMATCH" to ErrorCode.NONCE_MISMATCH,
133133
"SALT_REDEEMED" to ErrorCode.SALT_REDEEMED,
134+
135+
// Should not be thrown by server ,but just in case it is also covered
136+
"TIME_SINCE_ONBOARDING_UNVERIFIED" to ErrorCode.TIME_SINCE_ONBOARDING_UNVERIFIED,
137+
"MIN_TIME_SINCE_ONBOARDING" to ErrorCode.MIN_TIME_SINCE_ONBOARDING,
138+
"SUBMISSION_TOO_EARLY" to ErrorCode.SUBMISSION_TOO_EARLY,
139+
134140
// iOS error that does not map to Android Error :D
135141
"API_TOKEN_ALREADY_ISSUED" to ErrorCode.SRS_OTP_SERVER_ERROR,
136142
).forEach { (serverErrorCode, errorCode) ->

0 commit comments

Comments
 (0)