@Test
public void testGetNameWithUserDetailsPrincipalWithLoginAlias() throws Exception {

  // Given
  UserDetails userDetails = new User("loginAlias", "password", Collections.<GrantedAuthority>emptyList());
  Authentication authentication = new TestingAuthenticationToken(userDetails, userDetails.getPassword());
  expect(servletRequestAttributes.getAttribute(eq("loginAlias"), eq(RequestAttributes.SCOPE_SESSION)))
    .andReturn("user").atLeastOnce();
  replayAll();
  Authentication ambariAuthentication = new AmbariAuthentication(authentication, DEFAULT_USER_ID);
  // When
  String name = ambariAuthentication.getName();
  // Then
  verifyAll();
  assertEquals("user", name);
}