@Test public void testLegacyAuthDelegation() { Map<String, String> expectedCredentials = new HashMap<>(); expectedCredentials.put("user", "password"); AuthenticatedUser expectedUser = mock(AuthenticatedUser.class); when(mockPasswordAuthenticator.legacyAuthenticate(eq(expectedCredentials))).thenReturn(expectedUser); AuthenticatedUser actualUser = authenticator.legacyAuthenticate(expectedCredentials); ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class); verify(mockPasswordAuthenticator, times(1)).legacyAuthenticate(captor.capture()); Map<String, String> actualCredentials = captor.getValue(); assertThat(actualCredentials).isEqualTo(expectedCredentials); assertThat(expectedUser).isEqualTo(actualUser); }
@Override public AuthenticatedUser legacyAuthenticate(Map<String, String> credentials) throws AuthenticationException { return wrappedAuthenticator.legacyAuthenticate(credentials); }
DecoratedPasswordAuthenticator implements IDecoratedAuthenticator { @Override public AuthenticatedUser legacyAuthenticate(Map<String, String> credentials) throws AuthenticationException { return wrappedAuthenticator.legacyAuthenticate(credentials); } }
DecoratedPasswordAuthenticator implements IDecoratedAuthenticator { @Override public AuthenticatedUser legacyAuthenticate(Map<String, String> credentials) throws AuthenticationException { return wrappedAuthenticator.legacyAuthenticate(credentials); } DecoratedPasswordAuthenticator(); @VisibleForTesting  DecoratedPasswordAuthenticator(PasswordAuthenticator authenticator); }
DecoratedPasswordAuthenticator implements IDecoratedAuthenticator { @Override public AuthenticatedUser legacyAuthenticate(Map<String, String> credentials) throws AuthenticationException { return wrappedAuthenticator.legacyAuthenticate(credentials); } DecoratedPasswordAuthenticator(); @VisibleForTesting  DecoratedPasswordAuthenticator(PasswordAuthenticator authenticator); @Override boolean requireAuthentication(); @Override Set<? extends IResource> protectedResources(); @Override void validateConfiguration(); @Override void setup(); @Override Set<IRoleManager.Option> supportedOptions(); @Override Set<IRoleManager.Option> alterableOptions(); @Override SaslNegotiator newSaslNegotiator(); @Override DecoratedSaslNegotiator newDecoratedSaslNegotiator(); @Override AuthenticatedUser legacyAuthenticate(Map<String, String> credentials); }
DecoratedPasswordAuthenticator implements IDecoratedAuthenticator { @Override public AuthenticatedUser legacyAuthenticate(Map<String, String> credentials) throws AuthenticationException { return wrappedAuthenticator.legacyAuthenticate(credentials); } DecoratedPasswordAuthenticator(); @VisibleForTesting  DecoratedPasswordAuthenticator(PasswordAuthenticator authenticator); @Override boolean requireAuthentication(); @Override Set<? extends IResource> protectedResources(); @Override void validateConfiguration(); @Override void setup(); @Override Set<IRoleManager.Option> supportedOptions(); @Override Set<IRoleManager.Option> alterableOptions(); @Override SaslNegotiator newSaslNegotiator(); @Override DecoratedSaslNegotiator newDecoratedSaslNegotiator(); @Override AuthenticatedUser legacyAuthenticate(Map<String, String> credentials);  }