Skip to content

Commit 587d879

Browse files
DTSERWONE-821 - Handle HTTP 401 (#280)
* DTSERWONE-821 - Update Core SDK to handle HTTP 401 * DTSERWONE-821 - Introduce UI test to display Authentication error on Rest and GraphQL request when HTTP 401 is returned
1 parent 35126da commit 587d879

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Changelog
22
=========
3+
[1.0.0-beta13](https://github.com/hyperwallet/hyperwallet-android-ui-sdk/releases/tag/1.0.0-beta13)
4+
-------------------
5+
* Handle HTTP 401
36

47
[1.0.0-beta12](https://github.com/hyperwallet/hyperwallet-android-ui-sdk/releases/tag/1.0.0-beta12)
58
-------------------

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ allprojects {
2424

2525
}
2626

27-
project.version = "1.0.0-beta12"
27+
project.version = "1.0.0-beta13"
2828

2929
}
3030

@@ -38,7 +38,7 @@ subprojects {
3838
targetVersion = 30
3939
codeVersion = 1
4040

41-
hyperwalletCoreVersion = '1.0.0-beta10'
41+
hyperwalletCoreVersion = '1.0.0-beta12'
4242
hyperwalletInsightVersion = '1.0.0-beta02'
4343
//
4444
androidMaterialVersion = '1.0.0'

transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/BankAccountTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static androidx.test.espresso.action.ViewActions.replaceText;
66
import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist;
77
import static androidx.test.espresso.assertion.ViewAssertions.matches;
8+
import static androidx.test.espresso.matcher.RootMatchers.isDialog;
89
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
910
import static androidx.test.espresso.matcher.ViewMatchers.isEnabled;
1011
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
@@ -21,6 +22,7 @@
2122
import static java.net.HttpURLConnection.HTTP_BAD_REQUEST;
2223
import static java.net.HttpURLConnection.HTTP_CREATED;
2324
import static java.net.HttpURLConnection.HTTP_OK;
25+
import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED;
2426
import static java.util.concurrent.TimeUnit.SECONDS;
2527

2628
import static com.hyperwallet.android.model.transfermethod.BankAccount.Purpose.SAVINGS;
@@ -429,6 +431,25 @@ public void testAddTransferMethod_displaysErrorOnInvalidRoutingNumber() {
429431
+ "branch of your bank.")));
430432
}
431433

434+
@Test
435+
public void testAddTransferMethod_displaysErrorOnUnauthorizedOnRestRequest() {
436+
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_UNAUTHORIZED).withBody(sResourceManager
437+
.getResourceContent("error_jwt_token_revoked.json")).mock();
438+
439+
mActivityTestRule.launchActivity(null);
440+
441+
onView(withId(R.id.branchId)).perform(nestedScrollTo(), replaceText(INVALID_ROUTING_NUMBER));
442+
onView(withId(R.id.bankAccountId)).perform(nestedScrollTo(), replaceText(ACCOUNT_NUMBER));
443+
onView(withId(R.id.bankAccountPurpose)).perform(nestedScrollTo(), click());
444+
onView(allOf(withId(R.id.select_name), withText("Checking"))).perform(click());
445+
446+
onView(withId(R.id.add_transfer_method_button)).perform(nestedScrollTo(), click());
447+
448+
onView(withText(R.string.authentication_error_header))
449+
.inRoot(isDialog())
450+
.check(matches(isDisplayed()));
451+
}
452+
432453
@Test
433454
public void testAddTransferMethod_verifyFieldFormatting() throws Exception {
434455
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_CREATED).withBody(sResourceManager

transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/ListTransferMethodTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import static androidx.test.espresso.Espresso.onView;
44
import static androidx.test.espresso.action.ViewActions.click;
5+
import static androidx.test.espresso.action.ViewActions.replaceText;
56
import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist;
67
import static androidx.test.espresso.assertion.ViewAssertions.matches;
8+
import static androidx.test.espresso.matcher.RootMatchers.isDialog;
79
import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant;
810
import static androidx.test.espresso.matcher.ViewMatchers.hasSibling;
911
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
@@ -17,10 +19,12 @@
1719

1820
import static java.net.HttpURLConnection.HTTP_NO_CONTENT;
1921
import static java.net.HttpURLConnection.HTTP_OK;
22+
import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED;
2023
import static java.util.concurrent.TimeUnit.SECONDS;
2124

2225
import static com.hyperwallet.android.model.StatusTransition.StatusDefinition.DE_ACTIVATED;
2326
import static com.hyperwallet.android.ui.testutils.util.EspressoUtils.atPosition;
27+
import static com.hyperwallet.android.ui.testutils.util.EspressoUtils.nestedScrollTo;
2428
import static com.hyperwallet.android.ui.testutils.util.EspressoUtils.withDrawable;
2529

2630
import android.content.BroadcastReceiver;
@@ -195,6 +199,20 @@ public void testListTransferMethod_userHasSingleTransferMethod() {
195199

196200
}
197201

202+
@Test
203+
public void testListTransferMethod_displaysErrorOnUnauthorizedOnGraphQLRequest() {
204+
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_UNAUTHORIZED).withBody(sResourceManager
205+
.getResourceContent("error_jwt_token_revoked.json")).mock();
206+
207+
// run test
208+
mActivityTestRule.launchActivity(null);
209+
210+
// assert
211+
onView(withText(R.string.authentication_error_header))
212+
.inRoot(isDialog())
213+
.check(matches(isDisplayed()));
214+
}
215+
198216
@Test
199217
public void testListTransferMethod_userHasNoTransferMethods() {
200218
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_NO_CONTENT).withBody("").mock();
@@ -213,6 +231,7 @@ public void testListTransferMethod_userHasNoTransferMethods() {
213231

214232
}
215233

234+
216235
@Test
217236
public void testListTransferMethod_removeBankAccount() throws InterruptedException {
218237
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"errors":[
3+
{
4+
"message":"JWT expired",
5+
"code":"JWT_EXPIRED"
6+
}
7+
]
8+
}

0 commit comments

Comments
 (0)