Skip to content

Commit

Permalink
prevent NPE when browser re-triggers authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
lbalmaceda committed Feb 1, 2018
1 parent 69a5809 commit fd4baed
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
@Override
protected void onResume() {
super.onResume();
if (!intentLaunched) {
if (!intentLaunched && getIntent().getExtras() == null) {
//Activity was launched in an unexpected way
finish();
return;
} else if (!intentLaunched) {
intentLaunched = true;
launchAuthenticationIntent();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ private void createActivity(Intent configurationIntent) {
activityShadow = shadowOf(activity);
}

@SuppressWarnings("deprecation")
@Test
public void shouldFinishGracefullyWhenCalledByError() throws Exception {
Intent intent = new Intent(callerActivity, AuthenticationActivity.class);
//An invalid call will not pass any expected extras
createActivity(intent);

activityController.create().newIntent(intent).start().resume();

verifyNoMoreInteractions(customTabsController);
assertThat(activity.getDeliveredIntent(), is(nullValue()));
assertThat(activity.isFinishing(), is(true));

activityController.destroy();
}

@SuppressWarnings("deprecation")
@Test
public void shouldAuthenticateUsingBrowser() throws Exception {
Expand Down

0 comments on commit fd4baed

Please sign in to comment.