@Test public void testGetRequest() throws Exception { doReturn(false).when(target).isChromeCustomTabSupported(); Intent intent = new Intent(); Bundle startActivityOption = new Bundle(); BrowserAuthenticationApi.AuthenticationIntentHolder intentHolder = new BrowserAuthenticationApi.AuthenticationIntentHolder( intent, startActivityOption, true ); doReturn(intentHolder).when(target) .getAuthenticationIntentHolder( any(Context.class), any(Uri.class), anyBoolean() ); doReturn(REDIRECT_URI).when(target).createRedirectUri(any(Context.class)); Uri loginUri = Uri.parse("https: doReturn(loginUri).when(target) .createLoginUrl( any(LineAuthenticationConfig.class), any(PKCECode.class), any(LineAuthenticationParams.class) , any(String.class) , any(String.class) , any(String.class) ); BrowserAuthenticationApi.Request request = target.getRequest(context, config, PKCE_CODE, LINE_AUTH_PARAMS); assertSame(intent, request.getIntent()); assertSame(startActivityOption, request.getStartActivityOptions()); assertTrue(request.isLineAppAuthentication()); verify(target, times(1)).getAuthenticationIntentHolder( eq(context), any(Uri.class), eq(true) ); verify(target, times(1)).createLoginUrl( eq(config), eq(PKCE_CODE), eq(LINE_AUTH_PARAMS), anyString(), any(), eq(REDIRECT_URI) ); }
@NonNull Request getRequest( @NonNull Context context, @NonNull LineAuthenticationConfig config, @NonNull PKCECode pkceCode, @NonNull LineAuthenticationParams params) throws ActivityNotFoundException { final String oAuthState = createRandomAlphaNumeric(LENGTH_OAUTH_STATE); authenticationStatus.setOAuthState(oAuthState); final String openIdNonce; if (params.getScopes().contains(Scope.OPENID_CONNECT)) { if (!TextUtils.isEmpty(params.getNonce())) { openIdNonce = params.getNonce(); } else { openIdNonce = createRandomAlphaNumeric(LENGTH_OPENID_NONCE); } } else { openIdNonce = null; } authenticationStatus.setOpenIdNonce(openIdNonce); final String redirectUri = createRedirectUri(context); final Uri loginUri = createLoginUrl(config, pkceCode, params, oAuthState, openIdNonce, redirectUri); AuthenticationIntentHolder intentHolder = getAuthenticationIntentHolder( context, loginUri, config.isLineAppAuthenticationDisabled()); return new Request( intentHolder.getIntent(), intentHolder.getStartActivityOptions(), redirectUri, intentHolder.isLineAppAuthentication); }
BrowserAuthenticationApi { @NonNull Request getRequest( @NonNull Context context, @NonNull LineAuthenticationConfig config, @NonNull PKCECode pkceCode, @NonNull LineAuthenticationParams params) throws ActivityNotFoundException { final String oAuthState = createRandomAlphaNumeric(LENGTH_OAUTH_STATE); authenticationStatus.setOAuthState(oAuthState); final String openIdNonce; if (params.getScopes().contains(Scope.OPENID_CONNECT)) { if (!TextUtils.isEmpty(params.getNonce())) { openIdNonce = params.getNonce(); } else { openIdNonce = createRandomAlphaNumeric(LENGTH_OPENID_NONCE); } } else { openIdNonce = null; } authenticationStatus.setOpenIdNonce(openIdNonce); final String redirectUri = createRedirectUri(context); final Uri loginUri = createLoginUrl(config, pkceCode, params, oAuthState, openIdNonce, redirectUri); AuthenticationIntentHolder intentHolder = getAuthenticationIntentHolder( context, loginUri, config.isLineAppAuthenticationDisabled()); return new Request( intentHolder.getIntent(), intentHolder.getStartActivityOptions(), redirectUri, intentHolder.isLineAppAuthentication); } }
BrowserAuthenticationApi { @NonNull Request getRequest( @NonNull Context context, @NonNull LineAuthenticationConfig config, @NonNull PKCECode pkceCode, @NonNull LineAuthenticationParams params) throws ActivityNotFoundException { final String oAuthState = createRandomAlphaNumeric(LENGTH_OAUTH_STATE); authenticationStatus.setOAuthState(oAuthState); final String openIdNonce; if (params.getScopes().contains(Scope.OPENID_CONNECT)) { if (!TextUtils.isEmpty(params.getNonce())) { openIdNonce = params.getNonce(); } else { openIdNonce = createRandomAlphaNumeric(LENGTH_OPENID_NONCE); } } else { openIdNonce = null; } authenticationStatus.setOpenIdNonce(openIdNonce); final String redirectUri = createRedirectUri(context); final Uri loginUri = createLoginUrl(config, pkceCode, params, oAuthState, openIdNonce, redirectUri); AuthenticationIntentHolder intentHolder = getAuthenticationIntentHolder( context, loginUri, config.isLineAppAuthenticationDisabled()); return new Request( intentHolder.getIntent(), intentHolder.getStartActivityOptions(), redirectUri, intentHolder.isLineAppAuthentication); } BrowserAuthenticationApi(@NonNull LineAuthenticationStatus authenticationStatus); }
BrowserAuthenticationApi { @NonNull Request getRequest( @NonNull Context context, @NonNull LineAuthenticationConfig config, @NonNull PKCECode pkceCode, @NonNull LineAuthenticationParams params) throws ActivityNotFoundException { final String oAuthState = createRandomAlphaNumeric(LENGTH_OAUTH_STATE); authenticationStatus.setOAuthState(oAuthState); final String openIdNonce; if (params.getScopes().contains(Scope.OPENID_CONNECT)) { if (!TextUtils.isEmpty(params.getNonce())) { openIdNonce = params.getNonce(); } else { openIdNonce = createRandomAlphaNumeric(LENGTH_OPENID_NONCE); } } else { openIdNonce = null; } authenticationStatus.setOpenIdNonce(openIdNonce); final String redirectUri = createRedirectUri(context); final Uri loginUri = createLoginUrl(config, pkceCode, params, oAuthState, openIdNonce, redirectUri); AuthenticationIntentHolder intentHolder = getAuthenticationIntentHolder( context, loginUri, config.isLineAppAuthenticationDisabled()); return new Request( intentHolder.getIntent(), intentHolder.getStartActivityOptions(), redirectUri, intentHolder.isLineAppAuthentication); } BrowserAuthenticationApi(@NonNull LineAuthenticationStatus authenticationStatus);  }
BrowserAuthenticationApi { @NonNull Request getRequest( @NonNull Context context, @NonNull LineAuthenticationConfig config, @NonNull PKCECode pkceCode, @NonNull LineAuthenticationParams params) throws ActivityNotFoundException { final String oAuthState = createRandomAlphaNumeric(LENGTH_OAUTH_STATE); authenticationStatus.setOAuthState(oAuthState); final String openIdNonce; if (params.getScopes().contains(Scope.OPENID_CONNECT)) { if (!TextUtils.isEmpty(params.getNonce())) { openIdNonce = params.getNonce(); } else { openIdNonce = createRandomAlphaNumeric(LENGTH_OPENID_NONCE); } } else { openIdNonce = null; } authenticationStatus.setOpenIdNonce(openIdNonce); final String redirectUri = createRedirectUri(context); final Uri loginUri = createLoginUrl(config, pkceCode, params, oAuthState, openIdNonce, redirectUri); AuthenticationIntentHolder intentHolder = getAuthenticationIntentHolder( context, loginUri, config.isLineAppAuthenticationDisabled()); return new Request( intentHolder.getIntent(), intentHolder.getStartActivityOptions(), redirectUri, intentHolder.isLineAppAuthentication); } BrowserAuthenticationApi(@NonNull LineAuthenticationStatus authenticationStatus);   }