@Test
public void testGetPrincipalWithLoginAlias() throws Exception {

  // Given
  Authentication authentication = new TestingAuthenticationToken("loginAlias", "password");
  expect(servletRequestAttributes.getAttribute(eq("loginAlias"), eq(RequestAttributes.SCOPE_SESSION)))
    .andReturn("user").atLeastOnce();
  replayAll();
  Authentication ambariAuthentication = new AmbariAuthentication(authentication, DEFAULT_USER_ID);
  // When
  verifyAll();
  Object principal = ambariAuthentication.getPrincipal();
  // Then
  assertEquals("user", principal);
}