use of org.jasig.cas.client.validation.Assertion in project uhgroupings by uhawaii-system-its-ti-iam.
the class UserDetailsServiceTest method testAdminUsers.
// Rebase. Test admin users for code coverage purposes.
// Related to ticket-500, used hardcoded values that were deleted.
@Ignore
@Test
public void testAdminUsers() {
Map<String, Object> map = new HashMap<>();
map.put("uid", "duckart");
map.put("uhUuid", "89999999");
AttributePrincipal principal = new AttributePrincipalImpl("duckart", map);
Assertion assertion = new AssertionImpl(principal);
CasUserDetailsServiceImplj userDetailsService = new CasUserDetailsServiceImplj(userBuilder);
User user = (User) userDetailsService.loadUserDetails(assertion);
// Basics.
assertThat(user.getUsername(), is("duckart"));
assertThat(user.getUid(), is("duckart"));
assertThat(user.getUhUuid(), is("89999999"));
// Granted Authorities.
assertTrue(user.getAuthorities().size() > 0);
assertTrue(user.hasRole(Role.ANONYMOUS));
assertTrue(user.hasRole(Role.UH));
assertTrue(user.hasRole(Role.EMPLOYEE));
assertTrue(user.hasRole(Role.ADMIN));
// Check a made-up junky role name.
map = new HashMap<>();
map.put("uid", "someuser");
map.put("uhUuid", "10000001");
principal = new AttributePrincipalImpl("someuser", map);
assertion = new AssertionImpl(principal);
user = (User) userDetailsService.loadUserDetails(assertion);
assertThat(user.getUsername(), is("someuser"));
assertThat(user.getUid(), is("someuser"));
assertThat(user.getUhUuid(), is("10000001"));
assertTrue(user.getAuthorities().size() > 0);
assertTrue(user.hasRole(Role.ANONYMOUS));
assertTrue(user.hasRole(Role.UH));
assertTrue(user.hasRole(Role.EMPLOYEE));
assertTrue(user.hasRole(Role.ADMIN));
}
Aggregations