From 0786af176466029269264bd6a9797fe8b1f67627 Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Wed, 8 Mar 2023 15:01:34 +0200 Subject: [PATCH] Refactored code.| #2162 --- .../ui/FesDuringSetupConsumerFlowTest.kt | 28 ++----------------- .../ui/FesDuringSetupEnterpriseFlowTest.kt | 2 ++ 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/FesDuringSetupConsumerFlowTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/FesDuringSetupConsumerFlowTest.kt index 773ca83fdd..1cd9fcbd26 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/FesDuringSetupConsumerFlowTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/FesDuringSetupConsumerFlowTest.kt @@ -25,8 +25,6 @@ import com.flowcrypt.email.rules.ScreenshotTestRule import com.flowcrypt.email.ui.base.BaseFesDuringSetupFlowTest import com.flowcrypt.email.util.TestGeneralUtil import com.flowcrypt.email.util.exception.ApiException -import com.google.api.client.json.gson.GsonFactory -import com.google.api.services.gmail.model.ListMessagesResponse import com.google.gson.Gson import okhttp3.mockwebserver.MockResponse import okhttp3.mockwebserver.RecordedRequest @@ -58,24 +56,6 @@ class FesDuringSetupConsumerFlowTest : BaseFesDuringSetupFlowTest() { override fun handleAPI(request: RecordedRequest, gson: Gson): MockResponse { return when { request.path?.startsWith("/ekm") == true -> handleEkmAPI(request, gson) - - request.requestUrl?.encodedPath == "/gmail/v1/users/me/messages" - && request.requestUrl?.queryParameterNames?.contains("q") == true -> { - val q = requireNotNull(request.requestUrl?.queryParameter("q")) - return when { - q.startsWith("from:${EMAIL_FES_ENFORCE_ATTESTER_SUBMIT}") -> MockResponse() - .setResponseCode(HttpURLConnection.HTTP_OK) - .setBody( - ListMessagesResponse().apply { - factory = GsonFactory.getDefaultInstance() - messages = emptyList() - resultSizeEstimate = 0 - }.toString() - ) - - else -> MockResponse().setResponseCode(HttpURLConnection.HTTP_NOT_FOUND) - } - } else -> MockResponse().setResponseCode(HttpURLConnection.HTTP_NOT_FOUND) } } @@ -118,16 +98,12 @@ class FesDuringSetupConsumerFlowTest : BaseFesDuringSetupFlowTest() { override fun handleClientConfigurationAPI(gson: Gson): MockResponse { val responseCode = when (testNameRule.methodName) { - "testFesServerAvailableGetClientConfigurationFailed" -> HttpURLConnection.HTTP_FORBIDDEN "testFesAvailableWrongServiceName" -> HttpURLConnection.HTTP_NOT_ACCEPTABLE - "testCallFesUrlToGetClientConfigurationForEnterpriseUser" -> HttpURLConnection.HTTP_UNAUTHORIZED else -> HttpURLConnection.HTTP_OK } val body = when (testNameRule.methodName) { - "testFesServerAvailableGetClientConfigurationFailed", - "testFesAvailableWrongServiceName", - "testCallFesUrlToGetClientConfigurationForEnterpriseUser" -> null + "testFesAvailableWrongServiceName" -> null else -> gson.toJson( ClientConfigurationResponse( clientConfiguration = ClientConfiguration( @@ -224,6 +200,7 @@ class FesDuringSetupConsumerFlowTest : BaseFesDuringSetupFlowTest() { @Test fun testFesAvailableSuccess() { setupAndClickSignInButton(genMockGoogleSignInAccountJson(EMAIL_FES_SUCCESS)) + Thread.sleep(2000) onView(withText(R.string.set_pass_phrase)) .check(matches(isDisplayed())) } @@ -261,7 +238,6 @@ class FesDuringSetupConsumerFlowTest : BaseFesDuringSetupFlowTest() { private const val EMAIL_FES_HTTP_404 = "fes_404@flowcrypt.test" private const val EMAIL_FES_HTTP_NOT_404_NOT_SUCCESS = "fes_not404_not_success@flowcrypt.test" private const val EMAIL_FES_NOT_ALLOWED_SERVER = "fes_not_allowed_server@flowcrypt.test" - private const val EMAIL_FES_ENFORCE_ATTESTER_SUBMIT = "enforce_attester_submit@flowcrypt.test" private const val EMAIL_FES_SUCCESS = "fes_success@flowcrypt.test" private const val EMAIL_FES_SSL_ERROR = "fes_ssl_error@wrongssl.test" diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/FesDuringSetupEnterpriseFlowTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/FesDuringSetupEnterpriseFlowTest.kt index fc1d5fcbee..db2b0a6433 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/FesDuringSetupEnterpriseFlowTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/FesDuringSetupEnterpriseFlowTest.kt @@ -34,6 +34,7 @@ import okhttp3.mockwebserver.RecordedRequest import org.hamcrest.Matchers.containsString import org.hamcrest.Matchers.`is` import org.hamcrest.Matchers.not +import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.rules.RuleChain @@ -48,6 +49,7 @@ import java.util.concurrent.TimeUnit */ @MediumTest @RunWith(AndroidJUnit4::class) +@Ignore("not completed") class FesDuringSetupEnterpriseFlowTest : BaseFesDuringSetupFlowTest() { @get:Rule var ruleChain: TestRule = RuleChain