This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* date formatter crash due to translation merging fixed (#271) Co-authored-by: harambasicluka <[email protected]> * Improved UI on the QR Code scan screen (#272) * Tests/others (#204) * transaction tests * transaction test fixes Co-authored-by: Jakob Möller <[email protected]> Co-authored-by: Hee Tatt Ooi <[email protected]> Co-authored-by: harambasicluka <[email protected]> * version bumped to 0.8.8 (#275) Co-authored-by: Fabian-K <[email protected]> Co-authored-by: harambasicluka <[email protected]> Co-authored-by: Kolya Opahle <[email protected]> Co-authored-by: ksergeevit <[email protected]> Co-authored-by: Hee Tatt Ooi <[email protected]> Co-authored-by: oemerb <[email protected]>
- Loading branch information
1 parent
360f581
commit ef8e465
Showing
9 changed files
with
200 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Corona-Warn-App/src/main/res/drawable/ic_submission_qr_code_scan_close.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="40dp" | ||
android:height="40dp" | ||
android:viewportWidth="40" | ||
android:viewportHeight="40"> | ||
|
||
<group | ||
android:pivotX="20" | ||
android:pivotY="20" | ||
android:scaleX="2" | ||
android:scaleY="2"> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:fillType="nonZero" | ||
android:pathData="M14.2843,13l-1.2843,1.2843l5.7157,5.7157l-5.7157,5.7157l1.2843,1.2843l5.7157,-5.7157l5.7157,5.7157l1.2843,-1.2843l-5.7157,-5.7157l5.7157,-5.7157l-1.2843,-1.2843l-5.7157,5.7157z" | ||
android:strokeWidth="1" | ||
android:strokeColor="#00FFFFFF" /> | ||
</group> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...pp/src/test/java/de/rki/coronawarnapp/transaction/RetrieveDiagnosisKeysTransactionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package de.rki.coronawarnapp.transaction | ||
|
||
import com.google.android.gms.nearby.exposurenotification.ExposureConfiguration | ||
import de.rki.coronawarnapp.nearby.InternalExposureNotificationClient | ||
import de.rki.coronawarnapp.service.applicationconfiguration.ApplicationConfigurationService | ||
import de.rki.coronawarnapp.storage.LocalData | ||
import io.mockk.Runs | ||
import io.mockk.coEvery | ||
import io.mockk.coVerifyOrder | ||
import io.mockk.every | ||
import io.mockk.just | ||
import io.mockk.mockk | ||
import io.mockk.mockkObject | ||
import io.mockk.unmockkAll | ||
import kotlinx.coroutines.runBlocking | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Test | ||
import java.io.File | ||
import java.nio.file.Paths | ||
import java.util.Date | ||
|
||
/** | ||
* RetrieveDiagnosisKeysTransaction test. | ||
*/ | ||
class RetrieveDiagnosisKeysTransactionTest { | ||
|
||
@Before | ||
fun setUp() { | ||
mockkObject(InternalExposureNotificationClient) | ||
mockkObject(ApplicationConfigurationService) | ||
mockkObject(RetrieveDiagnosisKeysTransaction) | ||
mockkObject(LocalData) | ||
|
||
coEvery { InternalExposureNotificationClient.asyncIsEnabled() } returns true | ||
coEvery { InternalExposureNotificationClient.asyncProvideDiagnosisKeys(any(), any(), any()) } returns mockk() | ||
coEvery { ApplicationConfigurationService.asyncRetrieveExposureConfiguration() } returns mockk() | ||
every { LocalData.googleApiToken(any()) } just Runs | ||
every { LocalData.lastTimeDiagnosisKeysFromServerFetch() } returns Date() | ||
every { LocalData.lastTimeDiagnosisKeysFromServerFetch(any()) } just Runs | ||
} | ||
|
||
@Test | ||
fun testTransactionNoFiles() { | ||
coEvery { RetrieveDiagnosisKeysTransaction["executeFetchKeyFilesFromServer"](any<Date>()) } returns listOf<File>() | ||
|
||
runBlocking { | ||
RetrieveDiagnosisKeysTransaction.start() | ||
|
||
coVerifyOrder { | ||
RetrieveDiagnosisKeysTransaction["executeSetup"]() | ||
RetrieveDiagnosisKeysTransaction["executeRetrieveRiskScoreParams"]() | ||
RetrieveDiagnosisKeysTransaction["executeFetchKeyFilesFromServer"](any<Date>()) | ||
RetrieveDiagnosisKeysTransaction["executeFetchDateUpdate"](any<Date>()) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun testTransactionHasFiles() { | ||
val file = Paths.get("src", "test", "resources", "keys.bin").toFile() | ||
|
||
coEvery { RetrieveDiagnosisKeysTransaction["executeFetchKeyFilesFromServer"](any<Date>()) } returns listOf(file) | ||
|
||
runBlocking { | ||
RetrieveDiagnosisKeysTransaction.start() | ||
|
||
coVerifyOrder { | ||
RetrieveDiagnosisKeysTransaction["executeSetup"]() | ||
RetrieveDiagnosisKeysTransaction["executeRetrieveRiskScoreParams"]() | ||
RetrieveDiagnosisKeysTransaction["executeFetchKeyFilesFromServer"](any<Date>()) | ||
RetrieveDiagnosisKeysTransaction["executeAPISubmission"](any<String>(), listOf(file), any<ExposureConfiguration>()) | ||
RetrieveDiagnosisKeysTransaction["executeFetchDateUpdate"](any<Date>()) | ||
} | ||
} | ||
} | ||
|
||
@After | ||
fun cleanUp() { | ||
unmockkAll() | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...-App/src/test/java/de/rki/coronawarnapp/transaction/SubmitDiagnosisKeysTransactionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package de.rki.coronawarnapp.transaction | ||
|
||
import com.google.android.gms.nearby.exposurenotification.TemporaryExposureKey | ||
import de.rki.coronawarnapp.nearby.InternalExposureNotificationClient | ||
import de.rki.coronawarnapp.service.diagnosiskey.DiagnosisKeyService | ||
import de.rki.coronawarnapp.service.submission.SubmissionService | ||
import de.rki.coronawarnapp.storage.LocalData | ||
import io.mockk.Runs | ||
import io.mockk.coEvery | ||
import io.mockk.coVerifyOrder | ||
import io.mockk.every | ||
import io.mockk.just | ||
import io.mockk.mockkObject | ||
import io.mockk.slot | ||
import io.mockk.unmockkAll | ||
import kotlinx.coroutines.runBlocking | ||
import org.hamcrest.CoreMatchers.`is` | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class SubmitDiagnosisKeysTransactionTest { | ||
private val authString = "authString" | ||
|
||
@Before | ||
fun setUp() { | ||
mockkObject(LocalData) | ||
mockkObject(SubmissionService) | ||
mockkObject(InternalExposureNotificationClient) | ||
mockkObject(DiagnosisKeyService) | ||
every { LocalData.numberOfSuccessfulSubmissions(any()) } just Runs | ||
coEvery { SubmissionService.asyncRequestAuthCode(any()) } returns authString | ||
} | ||
|
||
@Test | ||
fun testTransactionNoKeys() { | ||
coEvery { InternalExposureNotificationClient.asyncGetTemporaryExposureKeyHistory() } returns listOf() | ||
coEvery { DiagnosisKeyService.asyncSubmitKeys(authString, listOf()) } just Runs | ||
|
||
runBlocking { | ||
SubmitDiagnosisKeysTransaction.start("123") | ||
|
||
coVerifyOrder { | ||
DiagnosisKeyService.asyncSubmitKeys(authString, listOf()) | ||
SubmissionService.submissionSuccessful() | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun testTransactionHasKeys() { | ||
val key = TemporaryExposureKey.TemporaryExposureKeyBuilder() | ||
.setKeyData(ByteArray(1)) | ||
.setRollingPeriod(1) | ||
.setRollingStartIntervalNumber(1) | ||
.setTransmissionRiskLevel(1) | ||
.build() | ||
val testList = slot<List<KeyExportFormat.TemporaryExposureKey>>() | ||
coEvery { InternalExposureNotificationClient.asyncGetTemporaryExposureKeyHistory() } returns listOf(key) | ||
coEvery { DiagnosisKeyService.asyncSubmitKeys(authString, capture(testList)) } just Runs | ||
|
||
runBlocking { | ||
SubmitDiagnosisKeysTransaction.start("123") | ||
|
||
coVerifyOrder { | ||
DiagnosisKeyService.asyncSubmitKeys(authString, any()) | ||
SubmissionService.submissionSuccessful() | ||
} | ||
assertThat(testList.isCaptured, `is`(true)) | ||
assertThat(testList.captured.size, `is`(1)) | ||
} | ||
} | ||
|
||
@After | ||
fun cleanUp() { | ||
unmockkAll() | ||
} | ||
} |
Binary file not shown.