@Test public void testVerifyAccessToken() throws Exception { doReturn(EXPECTED_RESULT).when(httpClient).get( any(Uri.class), anyMapOf(String.class, String.class), anyMapOf(String.class, String.class), any(ResponseDataParser.class)); LineApiResponse<AccessTokenVerificationResult> actualResult = target.verifyAccessToken(ACCESS_TOKEN); assertSame(EXPECTED_RESULT, actualResult); Map<String, String> expectedQueryParams = new HashMap<>(1); expectedQueryParams.put("access_token", ACCESS_TOKEN.getAccessToken()); verify(httpClient, times(1)).get( eq(Uri.parse(API_BASE_URL + "/oauth2/v2.1/verify")), eq(Collections.<String, String>emptyMap()), eq(expectedQueryParams), responseParserCaptor.capture()); verifyVerificationResultParser(responseParserCaptor.getValue()); }
@NonNull public LineApiResponse<AccessTokenVerificationResult> verifyAccessToken( @NonNull InternalAccessToken accessToken) { final Uri uri = buildUri(apiBaseUrl, BASE_PATH_OAUTH_V21_API, "verify"); final Map<String, String> queryParams = buildParams( "access_token", accessToken.getAccessToken() ); return httpClient.get( uri, emptyMap() , queryParams, VERIFICATION_RESULT_PARSER); }
LineAuthenticationApiClient { @NonNull public LineApiResponse<AccessTokenVerificationResult> verifyAccessToken( @NonNull InternalAccessToken accessToken) { final Uri uri = buildUri(apiBaseUrl, BASE_PATH_OAUTH_V21_API, "verify"); final Map<String, String> queryParams = buildParams( "access_token", accessToken.getAccessToken() ); return httpClient.get( uri, emptyMap() , queryParams, VERIFICATION_RESULT_PARSER); } }
LineAuthenticationApiClient { @NonNull public LineApiResponse<AccessTokenVerificationResult> verifyAccessToken( @NonNull InternalAccessToken accessToken) { final Uri uri = buildUri(apiBaseUrl, BASE_PATH_OAUTH_V21_API, "verify"); final Map<String, String> queryParams = buildParams( "access_token", accessToken.getAccessToken() ); return httpClient.get( uri, emptyMap() , queryParams, VERIFICATION_RESULT_PARSER); } LineAuthenticationApiClient(@NonNull final Context applicationContext,
                                       @NonNull final Uri openidDiscoveryDocumentUrl,
                                       @NonNull final Uri apiBaseUrl); @VisibleForTesting  LineAuthenticationApiClient(
            @NonNull final Uri openidDiscoveryDocumentUrl,
            @NonNull final Uri apiBaseUrl,
            @NonNull final ChannelServiceHttpClient httpClient); }
LineAuthenticationApiClient { @NonNull public LineApiResponse<AccessTokenVerificationResult> verifyAccessToken( @NonNull InternalAccessToken accessToken) { final Uri uri = buildUri(apiBaseUrl, BASE_PATH_OAUTH_V21_API, "verify"); final Map<String, String> queryParams = buildParams( "access_token", accessToken.getAccessToken() ); return httpClient.get( uri, emptyMap() , queryParams, VERIFICATION_RESULT_PARSER); } LineAuthenticationApiClient(@NonNull final Context applicationContext,
                                       @NonNull final Uri openidDiscoveryDocumentUrl,
                                       @NonNull final Uri apiBaseUrl); @VisibleForTesting  LineAuthenticationApiClient(
            @NonNull final Uri openidDiscoveryDocumentUrl,
            @NonNull final Uri apiBaseUrl,
            @NonNull final ChannelServiceHttpClient httpClient); @NonNull LineApiResponse<IssueAccessTokenResult> issueAccessToken(
            @NonNull String channelId,
            @NonNull String requestToken,
            @NonNull PKCECode pkceCode,
            @NonNull String redirectUri); @NonNull LineApiResponse<AccessTokenVerificationResult> verifyAccessToken(
            @NonNull InternalAccessToken accessToken); @NonNull LineApiResponse<RefreshTokenResult> refreshToken(
            @NonNull String channelId, @NonNull InternalAccessToken accessToken); @NonNull LineApiResponse<?> revokeAccessToken(@NonNull String channelId,
                                                @NonNull InternalAccessToken accessToken); @NonNull LineApiResponse<?> revokeRefreshToken(@NonNull String channelId,
                                                 @NonNull InternalAccessToken accessToken); @NonNull LineApiResponse<OpenIdDiscoveryDocument> getOpenIdDiscoveryDocument(); @NonNull LineApiResponse<JWKSet> getJWKSet(); }
LineAuthenticationApiClient { @NonNull public LineApiResponse<AccessTokenVerificationResult> verifyAccessToken( @NonNull InternalAccessToken accessToken) { final Uri uri = buildUri(apiBaseUrl, BASE_PATH_OAUTH_V21_API, "verify"); final Map<String, String> queryParams = buildParams( "access_token", accessToken.getAccessToken() ); return httpClient.get( uri, emptyMap() , queryParams, VERIFICATION_RESULT_PARSER); } LineAuthenticationApiClient(@NonNull final Context applicationContext,
                                       @NonNull final Uri openidDiscoveryDocumentUrl,
                                       @NonNull final Uri apiBaseUrl); @VisibleForTesting  LineAuthenticationApiClient(
            @NonNull final Uri openidDiscoveryDocumentUrl,
            @NonNull final Uri apiBaseUrl,
            @NonNull final ChannelServiceHttpClient httpClient); @NonNull LineApiResponse<IssueAccessTokenResult> issueAccessToken(
            @NonNull String channelId,
            @NonNull String requestToken,
            @NonNull PKCECode pkceCode,
            @NonNull String redirectUri); @NonNull LineApiResponse<AccessTokenVerificationResult> verifyAccessToken(
            @NonNull InternalAccessToken accessToken); @NonNull LineApiResponse<RefreshTokenResult> refreshToken(
            @NonNull String channelId, @NonNull InternalAccessToken accessToken); @NonNull LineApiResponse<?> revokeAccessToken(@NonNull String channelId,
                                                @NonNull InternalAccessToken accessToken); @NonNull LineApiResponse<?> revokeRefreshToken(@NonNull String channelId,
                                                 @NonNull InternalAccessToken accessToken); @NonNull LineApiResponse<OpenIdDiscoveryDocument> getOpenIdDiscoveryDocument(); @NonNull LineApiResponse<JWKSet> getJWKSet();  }