From 6e6550c02004c4e28041b0f5dad980d0e1067b6d Mon Sep 17 00:00:00 2001 From: Gustavo Meyer Date: Sat, 27 Aug 2022 02:04:19 -0700 Subject: [PATCH 1/2] DTSERWONE-821 - Update Core SDK to handle HTTP 401 --- CHANGELOG.md | 3 +++ build.gradle | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8474b1a3e..8466e7232 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ Changelog ========= +[1.0.0-beta13](https://github.com/hyperwallet/hyperwallet-android-ui-sdk/releases/tag/1.0.0-beta13) +------------------- +* Handle HTTP 401 [1.0.0-beta12](https://github.com/hyperwallet/hyperwallet-android-ui-sdk/releases/tag/1.0.0-beta12) ------------------- diff --git a/build.gradle b/build.gradle index a60b5268a..92ebce59e 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ allprojects { } - project.version = "1.0.0-beta12" + project.version = "1.0.0-beta13" } @@ -38,7 +38,7 @@ subprojects { targetVersion = 30 codeVersion = 1 - hyperwalletCoreVersion = '1.0.0-beta10' + hyperwalletCoreVersion = '1.0.0-beta12' hyperwalletInsightVersion = '1.0.0-beta02' // androidMaterialVersion = '1.0.0' From aab1e7d8cbe175dbb36614a9a5bdfc005e602973 Mon Sep 17 00:00:00 2001 From: Gustavo Meyer Date: Tue, 30 Aug 2022 16:53:57 -0700 Subject: [PATCH 2/2] DTSERWONE-821 - Introduce UI test to display Authentication error on Rest and GraphQL request when HTTP 401 is returned --- .../ui/transfermethod/BankAccountTest.java | 21 +++++++++++++++++++ .../ListTransferMethodTest.java | 19 +++++++++++++++++ .../resources/error_jwt_token_revoked.json | 8 +++++++ 3 files changed, 48 insertions(+) create mode 100644 transfermethodui/src/test/resources/error_jwt_token_revoked.json diff --git a/transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/BankAccountTest.java b/transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/BankAccountTest.java index 608a19c5c..55720ac44 100644 --- a/transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/BankAccountTest.java +++ b/transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/BankAccountTest.java @@ -5,6 +5,7 @@ import static androidx.test.espresso.action.ViewActions.replaceText; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; @@ -21,6 +22,7 @@ import static java.net.HttpURLConnection.HTTP_BAD_REQUEST; import static java.net.HttpURLConnection.HTTP_CREATED; import static java.net.HttpURLConnection.HTTP_OK; +import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED; import static java.util.concurrent.TimeUnit.SECONDS; import static com.hyperwallet.android.model.transfermethod.BankAccount.Purpose.SAVINGS; @@ -429,6 +431,25 @@ public void testAddTransferMethod_displaysErrorOnInvalidRoutingNumber() { + "branch of your bank."))); } + @Test + public void testAddTransferMethod_displaysErrorOnUnauthorizedOnRestRequest() { + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_UNAUTHORIZED).withBody(sResourceManager + .getResourceContent("error_jwt_token_revoked.json")).mock(); + + mActivityTestRule.launchActivity(null); + + onView(withId(R.id.branchId)).perform(nestedScrollTo(), replaceText(INVALID_ROUTING_NUMBER)); + onView(withId(R.id.bankAccountId)).perform(nestedScrollTo(), replaceText(ACCOUNT_NUMBER)); + onView(withId(R.id.bankAccountPurpose)).perform(nestedScrollTo(), click()); + onView(allOf(withId(R.id.select_name), withText("Checking"))).perform(click()); + + onView(withId(R.id.add_transfer_method_button)).perform(nestedScrollTo(), click()); + + onView(withText(R.string.authentication_error_header)) + .inRoot(isDialog()) + .check(matches(isDisplayed())); + } + @Test public void testAddTransferMethod_verifyFieldFormatting() throws Exception { mMockWebServer.mockResponse().withHttpResponseCode(HTTP_CREATED).withBody(sResourceManager diff --git a/transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/ListTransferMethodTest.java b/transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/ListTransferMethodTest.java index ead445e23..ec63672f0 100644 --- a/transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/ListTransferMethodTest.java +++ b/transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/ListTransferMethodTest.java @@ -2,8 +2,10 @@ import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.replaceText; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; import static androidx.test.espresso.matcher.ViewMatchers.hasSibling; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; @@ -17,10 +19,12 @@ import static java.net.HttpURLConnection.HTTP_NO_CONTENT; import static java.net.HttpURLConnection.HTTP_OK; +import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED; import static java.util.concurrent.TimeUnit.SECONDS; import static com.hyperwallet.android.model.StatusTransition.StatusDefinition.DE_ACTIVATED; import static com.hyperwallet.android.ui.testutils.util.EspressoUtils.atPosition; +import static com.hyperwallet.android.ui.testutils.util.EspressoUtils.nestedScrollTo; import static com.hyperwallet.android.ui.testutils.util.EspressoUtils.withDrawable; import android.content.BroadcastReceiver; @@ -195,6 +199,20 @@ public void testListTransferMethod_userHasSingleTransferMethod() { } + @Test + public void testListTransferMethod_displaysErrorOnUnauthorizedOnGraphQLRequest() { + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_UNAUTHORIZED).withBody(sResourceManager + .getResourceContent("error_jwt_token_revoked.json")).mock(); + + // run test + mActivityTestRule.launchActivity(null); + + // assert + onView(withText(R.string.authentication_error_header)) + .inRoot(isDialog()) + .check(matches(isDisplayed())); + } + @Test public void testListTransferMethod_userHasNoTransferMethods() { mMockWebServer.mockResponse().withHttpResponseCode(HTTP_NO_CONTENT).withBody("").mock(); @@ -213,6 +231,7 @@ public void testListTransferMethod_userHasNoTransferMethods() { } + @Test public void testListTransferMethod_removeBankAccount() throws InterruptedException { mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager diff --git a/transfermethodui/src/test/resources/error_jwt_token_revoked.json b/transfermethodui/src/test/resources/error_jwt_token_revoked.json new file mode 100644 index 000000000..9f5b59ed6 --- /dev/null +++ b/transfermethodui/src/test/resources/error_jwt_token_revoked.json @@ -0,0 +1,8 @@ +{ + "errors":[ + { + "message":"JWT expired", + "code":"JWT_EXPIRED" + } + ] +}