use of com.nike.cerberus.domain.UserGroupPermission in project cerberus by Nike-Inc.
the class UniqueOwnerValidatorTest method owner_in_group_permissions_is_invalid.
@Test
public void owner_in_group_permissions_is_invalid() {
UserGroupPermission userGroupPermission = new UserGroupPermission();
userGroupPermission.setName("owner");
SafeDepositBoxV1 safeDepositBox1 = new SafeDepositBoxV1();
safeDepositBox1.setOwner("owner");
safeDepositBox1.getUserGroupPermissions().add(userGroupPermission);
SafeDepositBoxV2 safeDepositBox2 = new SafeDepositBoxV2();
safeDepositBox2.setOwner("owner");
safeDepositBox2.getUserGroupPermissions().add(userGroupPermission);
Assert.assertFalse(subject.isValid(safeDepositBox1, mockConstraintValidatorContext));
Assert.assertFalse(subject.isValid(safeDepositBox2, mockConstraintValidatorContext));
}
use of com.nike.cerberus.domain.UserGroupPermission in project cerberus by Nike-Inc.
the class UniqueOwnerValidatorTest method unique_owner_is_valid.
@Test
public void unique_owner_is_valid() {
UserGroupPermission userGroupPermission = new UserGroupPermission();
userGroupPermission.setName("group");
SafeDepositBoxV1 safeDepositBox1 = new SafeDepositBoxV1();
safeDepositBox1.setOwner("owner");
safeDepositBox1.getUserGroupPermissions().add(userGroupPermission);
SafeDepositBoxV2 safeDepositBox2 = new SafeDepositBoxV2();
safeDepositBox2.setOwner("owner");
safeDepositBox2.getUserGroupPermissions().add(userGroupPermission);
Assert.assertTrue(subject.isValid(safeDepositBox1, mockConstraintValidatorContext));
Assert.assertTrue(subject.isValid(safeDepositBox2, mockConstraintValidatorContext));
}
use of com.nike.cerberus.domain.UserGroupPermission in project cerberus by Nike-Inc.
the class UserGroupPermissionsValidatorTest method unique_set_is_valid.
@Test
public void unique_set_is_valid() {
UserGroupPermission a = new UserGroupPermission();
a.setName("abc");
UserGroupPermission b = new UserGroupPermission();
b.setName("def");
Assert.assertTrue(subject.isValid(Sets.newSet(a, b), mockConstraintValidatorContext));
}
use of com.nike.cerberus.domain.UserGroupPermission in project cerberus by Nike-Inc.
the class PermissionValidationServiceTest method mockUserGroupPermissionWithName.
private Set<UserGroupPermission> mockUserGroupPermissionWithName() {
UserGroupPermission userGroupPermission = Mockito.mock(UserGroupPermission.class);
Mockito.when(userGroupPermission.getName()).thenReturn("userGroup1");
Set<UserGroupPermission> userGroupPermissions = new HashSet<>();
userGroupPermissions.add(userGroupPermission);
return userGroupPermissions;
}
use of com.nike.cerberus.domain.UserGroupPermission in project cerberus by Nike-Inc.
the class PermissionValidationServiceTest method testDoesPrincipalHaveReadPermissionWithPrincipalTypeAndGroupsCaseSensitiveHavingUserGroupsInUpperCase.
@Test
public void testDoesPrincipalHaveReadPermissionWithPrincipalTypeAndGroupsCaseSensitiveHavingUserGroupsInUpperCase() {
PermissionValidationService permissionValidationService = createPermissionValidationServiceWithGroupCaseSensitive(true);
Set<String> userGroups = new HashSet<>();
userGroups.add("USERGROUP1");
CerberusPrincipal cerberusPrincipal = mockCerberusPrincipalWithPrincipalTypeAndUserGroups(PrincipalType.USER, userGroups);
Set<UserGroupPermission> userGroupPermissions = mockUserGroupPermissionWithName();
Mockito.when(userGroupPermissionService.getUserGroupPermissions("sdbId")).thenReturn(userGroupPermissions);
boolean hasPermission = permissionValidationService.doesPrincipalHaveReadPermission(cerberusPrincipal, "sdbId");
Assert.assertFalse(hasPermission);
}
Aggregations