### Question:
KerberosAuthenticationProvider implements AuthenticationProvider { public Authentication authenticate(Authentication authentication) throws AuthenticationException { UsernamePasswordAuthenticationToken auth = (UsernamePasswordAuthenticationToken) authentication; String validatedUsername = kerberosClient.login(auth.getName(), auth.getCredentials().toString()); UserDetails userDetails = this.userDetailsService.loadUserByUsername(validatedUsername); UsernamePasswordAuthenticationToken output = new UsernamePasswordAuthenticationToken(userDetails, auth.getCredentials(), userDetails.getAuthorities()); return output; }  Authentication authenticate(Authentication authentication); boolean supports(Class<? extends Object> authentication); void setKerberosClient(KerberosClient kerberosClient); void setUserDetailsService(UserDetailsService detailsService);  }### Answer:
@Test public void testLoginOk() throws Exception { when(userDetailsService.loadUserByUsername(TEST_USER)).thenReturn(USER_DETAILS); when(kerberosClient.login(TEST_USER, TEST_PASSWORD)).thenReturn(TEST_USER); Authentication authenticate = provider.authenticate(INPUT_TOKEN); verify(kerberosClient).login(TEST_USER, TEST_PASSWORD); assertNotNull(authenticate); assertEquals(TEST_USER, authenticate.getName()); assertEquals(USER_DETAILS, authenticate.getPrincipal()); assertEquals(TEST_PASSWORD, authenticate.getCredentials()); assertEquals(AUTHORITY_LIST, authenticate.getAuthorities()); }