@Disabled("fails randomly") @Test void testTokenFetchFailure() throws Exception { final Interceptor.Chain chain = Mockito.mock(Interceptor.Chain.class); final OAuth2SecurityInterceptor oAuth2SecurityInterceptor = new OAuth2SecurityInterceptor( URL, CLIENT_ID, CLIENT_SECRET, GRANT_TYPE, SCOPE ); Assertions.assertThatIOException().isThrownBy(() -> oAuth2SecurityInterceptor.intercept(chain)); }
@Override public Response intercept( final Chain chain ) throws IOException { final AccessToken accessToken = this.tokenFetcher.getToken(); final Request newRequest = chain .request() .newBuilder() .addHeader(HttpHeaders.AUTHORIZATION, accessToken.getTokenType() + " " + accessToken.getAccessToken()) .build(); log.debug("Sending request {} on {} {}", newRequest.url(), chain.connection(), newRequest.headers()); return chain.proceed(newRequest); }
OAuth2SecurityInterceptor implements SecurityInterceptor { @Override public Response intercept( final Chain chain ) throws IOException { final AccessToken accessToken = this.tokenFetcher.getToken(); final Request newRequest = chain .request() .newBuilder() .addHeader(HttpHeaders.AUTHORIZATION, accessToken.getTokenType() + " " + accessToken.getAccessToken()) .build(); log.debug("Sending request {} on {} {}", newRequest.url(), chain.connection(), newRequest.headers()); return chain.proceed(newRequest); } }
OAuth2SecurityInterceptor implements SecurityInterceptor { @Override public Response intercept( final Chain chain ) throws IOException { final AccessToken accessToken = this.tokenFetcher.getToken(); final Request newRequest = chain .request() .newBuilder() .addHeader(HttpHeaders.AUTHORIZATION, accessToken.getTokenType() + " " + accessToken.getAccessToken()) .build(); log.debug("Sending request {} on {} {}", newRequest.url(), chain.connection(), newRequest.headers()); return chain.proceed(newRequest); } OAuth2SecurityInterceptor(
        final String url,
        final String clientId,
        final String clientSecret,
        final String grantType,
        final String scope
    ); }
OAuth2SecurityInterceptor implements SecurityInterceptor { @Override public Response intercept( final Chain chain ) throws IOException { final AccessToken accessToken = this.tokenFetcher.getToken(); final Request newRequest = chain .request() .newBuilder() .addHeader(HttpHeaders.AUTHORIZATION, accessToken.getTokenType() + " " + accessToken.getAccessToken()) .build(); log.debug("Sending request {} on {} {}", newRequest.url(), chain.connection(), newRequest.headers()); return chain.proceed(newRequest); } OAuth2SecurityInterceptor(
        final String url,
        final String clientId,
        final String clientSecret,
        final String grantType,
        final String scope
    ); @Override Response intercept(
        final Chain chain
    ); }
OAuth2SecurityInterceptor implements SecurityInterceptor { @Override public Response intercept( final Chain chain ) throws IOException { final AccessToken accessToken = this.tokenFetcher.getToken(); final Request newRequest = chain .request() .newBuilder() .addHeader(HttpHeaders.AUTHORIZATION, accessToken.getTokenType() + " " + accessToken.getAccessToken()) .build(); log.debug("Sending request {} on {} {}", newRequest.url(), chain.connection(), newRequest.headers()); return chain.proceed(newRequest); } OAuth2SecurityInterceptor(
        final String url,
        final String clientId,
        final String clientSecret,
        final String grantType,
        final String scope
    ); @Override Response intercept(
        final Chain chain
    );  }