@Test public void testRevokeRefreshToken() throws Exception { LineApiResponse<?> expectedResponse = LineApiResponse.createAsSuccess(new Object()); doReturn(expectedResponse).when(httpClient).post( any(Uri.class), anyMapOf(String.class, String.class), anyMapOf(String.class, String.class), any(ResponseDataParser.class)); LineApiResponse<?> actualResponse = target.revokeRefreshToken(CHANNEL_ID, ACCESS_TOKEN); assertSame(expectedResponse, actualResponse); Map<String, String> expectedPostData = new HashMap<>(2); expectedPostData.put("refresh_token", ACCESS_TOKEN.getRefreshToken()); expectedPostData.put("client_id", CHANNEL_ID); verify(httpClient, times(1)).post( eq(Uri.parse(API_BASE_URL + "/oauth2/v2.1/revoke")), eq(Collections.<String, String>emptyMap()), eq(expectedPostData), any(ResponseDataParser.class)); }
@NonNull public LineApiResponse<?> revokeRefreshToken(@NonNull String channelId, @NonNull InternalAccessToken accessToken) { final Uri uri = buildUri(apiBaseUrl, BASE_PATH_OAUTH_V21_API, "revoke"); final Map<String, String> postData = buildParams( "refresh_token", accessToken.getRefreshToken(), "client_id", channelId ); return httpClient.post( uri, emptyMap() , postData, NO_RESULT_RESPONSE_PARSER); }
LineAuthenticationApiClient { @NonNull public LineApiResponse<?> revokeRefreshToken(@NonNull String channelId, @NonNull InternalAccessToken accessToken) { final Uri uri = buildUri(apiBaseUrl, BASE_PATH_OAUTH_V21_API, "revoke"); final Map<String, String> postData = buildParams( "refresh_token", accessToken.getRefreshToken(), "client_id", channelId ); return httpClient.post( uri, emptyMap() , postData, NO_RESULT_RESPONSE_PARSER); } }
LineAuthenticationApiClient { @NonNull public LineApiResponse<?> revokeRefreshToken(@NonNull String channelId, @NonNull InternalAccessToken accessToken) { final Uri uri = buildUri(apiBaseUrl, BASE_PATH_OAUTH_V21_API, "revoke"); final Map<String, String> postData = buildParams( "refresh_token", accessToken.getRefreshToken(), "client_id", channelId ); return httpClient.post( uri, emptyMap() , postData, NO_RESULT_RESPONSE_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<?> revokeRefreshToken(@NonNull String channelId, @NonNull InternalAccessToken accessToken) { final Uri uri = buildUri(apiBaseUrl, BASE_PATH_OAUTH_V21_API, "revoke"); final Map<String, String> postData = buildParams( "refresh_token", accessToken.getRefreshToken(), "client_id", channelId ); return httpClient.post( uri, emptyMap() , postData, NO_RESULT_RESPONSE_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<?> revokeRefreshToken(@NonNull String channelId, @NonNull InternalAccessToken accessToken) { final Uri uri = buildUri(apiBaseUrl, BASE_PATH_OAUTH_V21_API, "revoke"); final Map<String, String> postData = buildParams( "refresh_token", accessToken.getRefreshToken(), "client_id", channelId ); return httpClient.post( uri, emptyMap() , postData, NO_RESULT_RESPONSE_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();  }