use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class AuthorityGranterTest method shouldGrantGroupSupervisorRoleToPipelineGroupAdmins.
@Test
public void shouldGrantGroupSupervisorRoleToPipelineGroupAdmins() {
when(securityService.isUserGroupAdmin(new Username(new CaseInsensitiveString("group-admin")))).thenReturn(true);
GrantedAuthority[] authorities = authorityGranter.authorities("group-admin");
assertThat("Should not have " + GoAuthority.ROLE_SUPERVISOR + " authority", authorities, not(hasItemInArray(GoAuthority.ROLE_SUPERVISOR.asAuthority())));
assertThat("Should have " + GoAuthority.ROLE_GROUP_SUPERVISOR + " authority", authorities, hasItemInArray(GoAuthority.ROLE_GROUP_SUPERVISOR.asAuthority()));
assertThat("Should have " + GoAuthority.ROLE_USER + " authority", authorities, hasItemInArray(GoAuthority.ROLE_USER.asAuthority()));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class AuthorityGranterTest method shouldGrantRoleUserToUsersWhoAreNotSpecial.
@Test
public void shouldGrantRoleUserToUsersWhoAreNotSpecial() {
when(securityService.isUserAdmin(new Username(new CaseInsensitiveString("admin")))).thenReturn(false);
when(securityService.isUserGroupAdmin(new Username(new CaseInsensitiveString("admin")))).thenReturn(false);
GrantedAuthority[] authorities = authorityGranter.authorities("admin");
assertThat("Should not have " + GoAuthority.ROLE_SUPERVISOR + " authority", authorities, not(hasItemInArray(GoAuthority.ROLE_SUPERVISOR.asAuthority())));
assertThat("Should not have " + GoAuthority.ROLE_GROUP_SUPERVISOR + " authority", authorities, not(hasItemInArray(GoAuthority.ROLE_GROUP_SUPERVISOR.asAuthority())));
assertThat("Should have " + GoAuthority.ROLE_USER + " authority", authorities, hasItemInArray(GoAuthority.ROLE_USER.asAuthority()));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class AuthorityGranterTest method shouldGrantSupervisorRoleToUsersWhoAreAdminsAndGroupAdmins.
@Test
public void shouldGrantSupervisorRoleToUsersWhoAreAdminsAndGroupAdmins() {
when(securityService.isUserAdmin(new Username(new CaseInsensitiveString("admin")))).thenReturn(true);
when(securityService.isUserGroupAdmin(new Username(new CaseInsensitiveString("admin")))).thenReturn(true);
GrantedAuthority[] authorities = authorityGranter.authorities("admin");
assertThat("Should have " + GoAuthority.ROLE_SUPERVISOR + " authority", authorities, hasItemInArray(GoAuthority.ROLE_SUPERVISOR.asAuthority()));
assertThat("Should have " + GoAuthority.ROLE_GROUP_SUPERVISOR + " authority", authorities, hasItemInArray(GoAuthority.ROLE_GROUP_SUPERVISOR.asAuthority()));
assertThat("Should have " + GoAuthority.ROLE_USER + " authority", authorities, hasItemInArray(GoAuthority.ROLE_USER.asAuthority()));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class GoAclTest method userNameShouldNotBeCaseSensitive.
@Test
public void userNameShouldNotBeCaseSensitive() throws Exception {
GoAcl acl = new GoAcl(new ArrayList<CaseInsensitiveString>() {
{
add(new CaseInsensitiveString("admin"));
}
});
boolean granted = acl.isGranted(new CaseInsensitiveString("ADMIN"));
assertThat("ADMIN should be granted", granted, is(true));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class UsernameTest method shouldReturnUsernameAsDisplayNameIfDisplayNameIsNotSet.
@Test
public void shouldReturnUsernameAsDisplayNameIfDisplayNameIsNotSet() {
Username username1 = new Username(new CaseInsensitiveString("dyang"));
assertThat("dyang should be Username.", username1.getUsername(), is(new CaseInsensitiveString("dyang")));
assertThat("dyang should be display name.", username1.getDisplayName(), is("dyang"));
}
Aggregations