use of com.nike.cerberus.domain.SafeDepositBoxV2 in project cerberus by Nike-Inc.
the class SafeDepositBoxServiceTest method test_that_validates_owner_AD_group_name.
@Test
public void test_that_validates_owner_AD_group_name() {
String id = "111";
String categoryId = "222";
String readId = "333";
String sdbName = "HEALTH CHECK BUCKET";
SafeDepositBoxV2 sdbObject = new SafeDepositBoxV2();
sdbObject.setId(id);
sdbObject.setPath("app/health-check-bucket/");
sdbObject.setCategoryId(categoryId);
sdbObject.setName(sdbName);
sdbObject.setOwner("app.mock.test");
sdbObject.setDescription("This SDB is read by the Health Check Lambda...");
sdbObject.setCreatedTs(OffsetDateTime.parse("2016-09-08T15:39:31Z"));
sdbObject.setLastUpdatedTs(OffsetDateTime.parse("2016-12-13T17:28:00Z"));
sdbObject.setCreatedBy("foobar@nike.com");
sdbObject.setLastUpdatedBy("foobar@nike.com");
safeDepositBoxService.adGroupNamePrefix = "app.mock";
safeDepositBoxService.validateSDBOwnerName(sdbObject);
}
use of com.nike.cerberus.domain.SafeDepositBoxV2 in project cerberus by Nike-Inc.
the class SafeDepositBoxServiceTest method test_that_validates_user_group_sanitization.
@Test
public void test_that_validates_user_group_sanitization() {
String id = "111";
String categoryId = "222";
String readId = "333";
String sdbName = "HEALTH CHECK BUCKET";
SafeDepositBoxV2 sdbObject = new SafeDepositBoxV2();
sdbObject.setId(id);
sdbObject.setPath("app/health-check-bucket/");
sdbObject.setCategoryId(categoryId);
sdbObject.setName(sdbName);
sdbObject.setOwner("app.mock.test");
sdbObject.setDescription("This SDB is read by the Health Check Lambda...");
sdbObject.setCreatedTs(OffsetDateTime.parse("2016-09-08T15:39:31Z"));
sdbObject.setLastUpdatedTs(OffsetDateTime.parse("2016-12-13T17:28:00Z"));
sdbObject.setCreatedBy("foobar@nike.com");
sdbObject.setLastUpdatedBy("foobar@nike.com");
Set<UserGroupPermission> userPerms = new HashSet<>();
userPerms.add(new UserGroupPermission().withName("app.Mock.blah").withRoleId(readId));
userPerms.add(new UserGroupPermission().withName("app.mock.blah").withRoleId(readId));
sdbObject.setUserGroupPermissions(userPerms);
safeDepositBoxService.sanitizeUserGroupPermissions(sdbObject);
assertEquals(sdbObject.getUserGroupPermissions().size(), 1);
}
use of com.nike.cerberus.domain.SafeDepositBoxV2 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.SafeDepositBoxV2 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.SafeDepositBoxV2 in project cerberus by Nike-Inc.
the class UniqueOwnerValidatorTest method empty_user_group_set_is_valid.
@Test
public void empty_user_group_set_is_valid() {
SafeDepositBoxV1 safeDepositBox1 = new SafeDepositBoxV1();
safeDepositBox1.setOwner("owner");
SafeDepositBoxV2 safeDepositBox2 = new SafeDepositBoxV2();
safeDepositBox2.setOwner("owner");
Assert.assertTrue(subject.isValid(safeDepositBox1, mockConstraintValidatorContext));
Assert.assertTrue(subject.isValid(safeDepositBox2, mockConstraintValidatorContext));
}
Aggregations