From 2a1f046a4b39d677d986038e8b0518cd888f41f4 Mon Sep 17 00:00:00 2001 From: Alex Paulescu Date: Thu, 30 Mar 2023 14:18:32 +0300 Subject: [PATCH 1/2] Fix invalid certs wru z (EXPOSUREAPP-14998) (#5912) * Prevent reset when switching to wru-z after eol. * Add eol to test. * Lint * Rename function. --- .../ui/DebugOptionsFragmentViewModel.kt | 13 +++++++++---- .../ui/DebugOptionsFragmentViewModelTest.kt | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/debugoptions/ui/DebugOptionsFragmentViewModel.kt b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/debugoptions/ui/DebugOptionsFragmentViewModel.kt index 2cc6daf4114..e3305a73673 100644 --- a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/debugoptions/ui/DebugOptionsFragmentViewModel.kt +++ b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/debugoptions/ui/DebugOptionsFragmentViewModel.kt @@ -5,6 +5,7 @@ import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import de.rki.coronawarnapp.environment.EnvironmentSetup import de.rki.coronawarnapp.environment.EnvironmentSetup.Type.Companion.toEnvironmentType +import de.rki.coronawarnapp.eol.AppEol import de.rki.coronawarnapp.eol.EolSetting import de.rki.coronawarnapp.test.debugoptions.ui.EnvironmentState.Companion.toEnvironmentState import de.rki.coronawarnapp.util.coroutine.AppScope @@ -14,11 +15,13 @@ import de.rki.coronawarnapp.util.viewmodel.CWAViewModel import de.rki.coronawarnapp.util.viewmodel.SimpleCWAViewModelFactory import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch class DebugOptionsFragmentViewModel @AssistedInject constructor( private val envSetup: EnvironmentSetup, private val eolSetting: EolSetting, + private val eol: AppEol, dispatcherProvider: DispatcherProvider, private val environmentSunset: EnvironmentSunset, @AppScope private val appScope: CoroutineScope, @@ -36,7 +39,7 @@ class DebugOptionsFragmentViewModel @AssistedInject constructor( environmentStateFlow.value = it environmentStateChange.postValue(it) } - cleanCachedData() + cleanCachedDataIfNotEol() } fun selectEnvironmentType(type: String) { @@ -44,15 +47,17 @@ class DebugOptionsFragmentViewModel @AssistedInject constructor( envSetup.toEnvironmentState().let { environmentStateFlow.value = it } - cleanCachedData() + cleanCachedDataIfNotEol() } fun setAllowedFlag(flag: Boolean) = launch { eolSetting.setLoggerAllowed(flag) } - private fun cleanCachedData() = appScope.launch { - environmentSunset.reset() + private fun cleanCachedDataIfNotEol() = appScope.launch { + if (!eol.isEol.first()) { + environmentSunset.reset() + } } @AssistedFactory diff --git a/Corona-Warn-App/src/testDeviceForTesters/java/de/rki/coronawarnapp/test/debugoptions/ui/DebugOptionsFragmentViewModelTest.kt b/Corona-Warn-App/src/testDeviceForTesters/java/de/rki/coronawarnapp/test/debugoptions/ui/DebugOptionsFragmentViewModelTest.kt index a13cf1998ef..3976c012901 100644 --- a/Corona-Warn-App/src/testDeviceForTesters/java/de/rki/coronawarnapp/test/debugoptions/ui/DebugOptionsFragmentViewModelTest.kt +++ b/Corona-Warn-App/src/testDeviceForTesters/java/de/rki/coronawarnapp/test/debugoptions/ui/DebugOptionsFragmentViewModelTest.kt @@ -1,6 +1,7 @@ package de.rki.coronawarnapp.test.debugoptions.ui import de.rki.coronawarnapp.environment.EnvironmentSetup +import de.rki.coronawarnapp.eol.AppEol import de.rki.coronawarnapp.eol.EolSetting import io.kotest.matchers.shouldBe import io.mockk.MockKAnnotations @@ -21,6 +22,7 @@ class DebugOptionsFragmentViewModelTest : testhelpers.BaseTest() { @MockK private lateinit var environmentSetup: EnvironmentSetup @MockK private lateinit var environmentSunset: EnvironmentSunset @MockK private lateinit var eolSetting: EolSetting + @MockK private lateinit var eol: AppEol private var currentEnvironment = EnvironmentSetup.Type.DEV @@ -44,6 +46,7 @@ class DebugOptionsFragmentViewModelTest : testhelpers.BaseTest() { every { environmentSetup.currentEnvironment } answers { currentEnvironment } every { environmentSetup.launchEnvironment } returns null every { eolSetting.isLoggerAllowed } returns flowOf(false) + every { eol.isEol } returns flowOf(false) } private fun createViewModel(): DebugOptionsFragmentViewModel = DebugOptionsFragmentViewModel( @@ -52,6 +55,7 @@ class DebugOptionsFragmentViewModelTest : testhelpers.BaseTest() { environmentSunset = environmentSunset, appScope = TestScope(), eolSetting = eolSetting, + eol = eol ) @Test From 188a7255b7deedcfc39afa9bc6cb07dffd276e6d Mon Sep 17 00:00:00 2001 From: Alex Paulescu Date: Thu, 30 Mar 2023 14:19:15 +0300 Subject: [PATCH 2/2] Enable rampdown notice. (#5913) --- .../ui/main/home/HomeFragmentTest.kt | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentTest.kt index a58f61fef7b..ce90d66fea0 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentTest.kt @@ -43,6 +43,7 @@ import testhelpers.recyclerScrollTo import testhelpers.setViewVisibility import testhelpers.takeScreenshot import timber.log.Timber +import java.util.Locale @RunWith(AndroidJUnit4::class) class HomeFragmentTest : BaseUITest() { @@ -400,13 +401,22 @@ class HomeFragmentTest : BaseUITest() { private fun homeFragmentItemsLiveData( tracingStateItem: TracingStateItem = HomeData.Tracing.LOW_RISK_ITEM_WITH_ENCOUNTERS, submissionTestResultItems: List = listOf(HomeData.Submission.TEST_UNREGISTERED_ITEM), - showRampDownNotice: Boolean = false + showRampDownNotice: Boolean = true ): LiveData> = MutableLiveData( mutableListOf().apply { if (showRampDownNotice) { - add(getRampDownNotice()) + val germanTitle = "Acthung!" + val englishTitle = "Important!" + val germanSubtitle = + "Es wird nur noch bis zum 30. April 2023 möglich sein, andere Personen über die Corona-Warn-App zu warnen!" + val englishSubtitle = + "You will only be able to warn others through the Crorona-Warn-App until April 30, 2023" + when (Locale.getDefault().displayLanguage) { + "de" -> add(getRampDownNotice(germanTitle, germanSubtitle)) + else -> add(getRampDownNotice(englishTitle, englishSubtitle)) + } } val hideTracingState = submissionTestResultItems.any { @@ -428,12 +438,12 @@ class HomeFragmentTest : BaseUITest() { } ) - private fun getRampDownNotice() = RampDownNoticeCard.Item( + private fun getRampDownNotice(title: String, subtitle: String) = RampDownNoticeCard.Item( onClickAction = {}, rampDownNotice = RampDownNotice( visible = true, - title = "Betriebsende", - subtitle = "Der Betrieb der Corona-Warn-App wird am xx.xx.xxxx eingestellt.", + title = title, + subtitle = subtitle, description = "", faqUrl = null )