use of net.nemerosa.ontrack.model.security.AccountUserDetails in project ontrack by nemerosa.
the class PasswordAuthenticationProviderIT method admin.
@Test
public void admin() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("admin", "admin");
// Retrieval
UserDetails userDetails = provider.retrieveUser("admin", token);
// Password check
provider.additionalAuthenticationChecks(userDetails, token);
// Checks
assertNotNull(userDetails);
assertNull(userDetails.getPassword());
assertEquals("admin", userDetails.getUsername());
assertTrue(userDetails instanceof AccountUserDetails);
AccountUserDetails accountUserDetails = (AccountUserDetails) userDetails;
Account account = accountUserDetails.getAccount();
Entity.isEntityDefined(account, "Account must be defined");
assertEquals("admin", account.getName());
assertEquals(SecurityRole.ADMINISTRATOR, account.getRole());
}
Aggregations