@Test public void shouldAuthenticate_badCredentials() { Authentication authentication = mock(Authentication.class); AuthenticationContext authenticationContext = mock(AuthenticationContext.class); when(authentication.getContext()).thenReturn(authenticationContext); io.gravitee.gateway.api.Request request = mock(io.gravitee.gateway.api.Request.class); when(authenticationContext.request()).thenReturn(request); MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>(); parameters.set("code", "facebookAuthorizationCode"); when(request.parameters()).thenReturn(parameters); when(configuration.getCodeParameter()).thenReturn("code"); when(configuration.getClientId()).thenReturn("testClientId"); when(configuration.getClientSecret()).thenReturn("testClientSecret"); when(configuration.getAccessTokenUri()).thenReturn("https: when(authentication.getContext().get("redirect_uri")).thenReturn("https: when(httpResponse.statusCode()) .thenReturn(HttpStatusCode.UNAUTHORIZED_401); when(httpResponse.bodyAsString()) .thenReturn("not authorized"); TestObserver<User> obs = cut.loadUserByUsername(authentication).test(); obs.awaitTerminalEvent(); obs.assertError(BadCredentialsException.class); verify(client, times(1)).postAbs("https: }
@Override public Maybe<User> loadUserByUsername(Authentication authentication) { return authenticate(authentication) .flatMap(token -> this.profile(token, authentication)); }
FacebookAuthenticationProvider extends AbstractSocialAuthenticationProvider<FacebookIdentityProviderConfiguration> { @Override public Maybe<User> loadUserByUsername(Authentication authentication) { return authenticate(authentication) .flatMap(token -> this.profile(token, authentication)); } }
FacebookAuthenticationProvider extends AbstractSocialAuthenticationProvider<FacebookIdentityProviderConfiguration> { @Override public Maybe<User> loadUserByUsername(Authentication authentication) { return authenticate(authentication) .flatMap(token -> this.profile(token, authentication)); }  }
FacebookAuthenticationProvider extends AbstractSocialAuthenticationProvider<FacebookIdentityProviderConfiguration> { @Override public Maybe<User> loadUserByUsername(Authentication authentication) { return authenticate(authentication) .flatMap(token -> this.profile(token, authentication)); }  @Override Maybe<User> loadUserByUsername(Authentication authentication); }
FacebookAuthenticationProvider extends AbstractSocialAuthenticationProvider<FacebookIdentityProviderConfiguration> { @Override public Maybe<User> loadUserByUsername(Authentication authentication) { return authenticate(authentication) .flatMap(token -> this.profile(token, authentication)); }  @Override Maybe<User> loadUserByUsername(Authentication authentication);  }