Search in sources :

Example 1 with SafeDepositBoxV1

use of com.nike.cerberus.domain.SafeDepositBoxV1 in project cerberus by Nike-Inc.

the class UniqueOwnerValidatorTest method blank_owner_returns_valid.

@Test
public void blank_owner_returns_valid() {
    SafeDepositBoxV1 safeDepositBox1 = new SafeDepositBoxV1();
    safeDepositBox1.setOwner("   ");
    SafeDepositBoxV2 safeDepositBox2 = new SafeDepositBoxV2();
    safeDepositBox2.setOwner("   ");
    Assert.assertTrue(subject.isValid(safeDepositBox1, mockConstraintValidatorContext));
    Assert.assertTrue(subject.isValid(safeDepositBox2, mockConstraintValidatorContext));
}
Also used : SafeDepositBoxV1(com.nike.cerberus.domain.SafeDepositBoxV1) SafeDepositBoxV2(com.nike.cerberus.domain.SafeDepositBoxV2) Test(org.junit.Test)

Example 2 with SafeDepositBoxV1

use of com.nike.cerberus.domain.SafeDepositBoxV1 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));
}
Also used : SafeDepositBoxV1(com.nike.cerberus.domain.SafeDepositBoxV1) SafeDepositBoxV2(com.nike.cerberus.domain.SafeDepositBoxV2) UserGroupPermission(com.nike.cerberus.domain.UserGroupPermission) Test(org.junit.Test)

Example 3 with SafeDepositBoxV1

use of com.nike.cerberus.domain.SafeDepositBoxV1 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));
}
Also used : SafeDepositBoxV1(com.nike.cerberus.domain.SafeDepositBoxV1) SafeDepositBoxV2(com.nike.cerberus.domain.SafeDepositBoxV2) UserGroupPermission(com.nike.cerberus.domain.UserGroupPermission) Test(org.junit.Test)

Example 4 with SafeDepositBoxV1

use of com.nike.cerberus.domain.SafeDepositBoxV1 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));
}
Also used : SafeDepositBoxV1(com.nike.cerberus.domain.SafeDepositBoxV1) SafeDepositBoxV2(com.nike.cerberus.domain.SafeDepositBoxV2) Test(org.junit.Test)

Example 5 with SafeDepositBoxV1

use of com.nike.cerberus.domain.SafeDepositBoxV1 in project cerberus by Nike-Inc.

the class SafeDepositBoxServiceTest method test_that_convertSafeDepositBoxV1ToV2_creates_expected_safe_deposit_box_v2.

@Test
public void test_that_convertSafeDepositBoxV1ToV2_creates_expected_safe_deposit_box_v2() {
    String id = "id";
    String name = "name";
    String description = "description";
    String path = "path";
    String categoryId = "category id";
    String createdBy = "created by";
    String lastUpdatedBy = "last updated by";
    OffsetDateTime createdTs = OffsetDateTime.now();
    OffsetDateTime lastUpdatedTs = OffsetDateTime.now();
    String owner = "owner";
    String accountId = "123";
    String roleName = "abc";
    String arn = "arn:aws:iam::123:role/abc";
    String roleId = "role id";
    Set<UserGroupPermission> userGroupPermissions = Sets.newHashSet();
    UserGroupPermission userGroupPermission = new UserGroupPermission();
    userGroupPermissions.add(userGroupPermission);
    Set<IamPrincipalPermission> iamRolePermissions = Sets.newHashSet();
    IamPrincipalPermission iamRolePermission = new IamPrincipalPermission().withIamPrincipalArn(arn).withRoleId(roleId);
    iamRolePermissions.add(iamRolePermission);
    SafeDepositBoxV2 safeDepositBoxV2 = new SafeDepositBoxV2();
    safeDepositBoxV2.setId(id);
    safeDepositBoxV2.setName(name);
    safeDepositBoxV2.setDescription(description);
    safeDepositBoxV2.setPath(path);
    safeDepositBoxV2.setCategoryId(categoryId);
    safeDepositBoxV2.setCreatedBy(createdBy);
    safeDepositBoxV2.setLastUpdatedBy(lastUpdatedBy);
    safeDepositBoxV2.setCreatedTs(createdTs);
    safeDepositBoxV2.setLastUpdatedTs(lastUpdatedTs);
    safeDepositBoxV2.setOwner(owner);
    safeDepositBoxV2.setUserGroupPermissions(userGroupPermissions);
    safeDepositBoxV2.setIamPrincipalPermissions(iamRolePermissions);
    when(awsIamRoleArnParser.getAccountId(arn)).thenReturn(accountId);
    when(awsIamRoleArnParser.getRoleName(arn)).thenReturn(roleName);
    SafeDepositBoxV1 resultantSDBV1 = safeDepositBoxService.convertSafeDepositBoxV2ToV1(safeDepositBoxV2);
    SafeDepositBoxV1 expectedSdbV1 = new SafeDepositBoxV1();
    expectedSdbV1.setId(id);
    expectedSdbV1.setName(name);
    expectedSdbV1.setDescription(description);
    expectedSdbV1.setPath(path);
    expectedSdbV1.setCategoryId(categoryId);
    expectedSdbV1.setCreatedBy(createdBy);
    expectedSdbV1.setLastUpdatedBy(lastUpdatedBy);
    expectedSdbV1.setCreatedTs(createdTs);
    expectedSdbV1.setLastUpdatedTs(lastUpdatedTs);
    expectedSdbV1.setOwner(owner);
    expectedSdbV1.setUserGroupPermissions(userGroupPermissions);
    Set<IamRolePermission> expectedIamRolePermissionsV1 = Sets.newHashSet();
    IamRolePermission expectedIamRolePermission = new IamRolePermission().withAccountId(accountId).withIamRoleName(roleName).withRoleId(roleId);
    expectedIamRolePermissionsV1.add(expectedIamRolePermission);
    expectedSdbV1.setIamRolePermissions(expectedIamRolePermissionsV1);
    assertEquals(expectedSdbV1, resultantSDBV1);
}
Also used : SafeDepositBoxV1(com.nike.cerberus.domain.SafeDepositBoxV1) SafeDepositBoxV2(com.nike.cerberus.domain.SafeDepositBoxV2) OffsetDateTime(java.time.OffsetDateTime) IamRolePermission(com.nike.cerberus.domain.IamRolePermission) UserGroupPermission(com.nike.cerberus.domain.UserGroupPermission) IamPrincipalPermission(com.nike.cerberus.domain.IamPrincipalPermission) Test(org.junit.Test)

Aggregations

SafeDepositBoxV1 (com.nike.cerberus.domain.SafeDepositBoxV1)6 SafeDepositBoxV2 (com.nike.cerberus.domain.SafeDepositBoxV2)6 Test (org.junit.Test)6 UserGroupPermission (com.nike.cerberus.domain.UserGroupPermission)4 IamPrincipalPermission (com.nike.cerberus.domain.IamPrincipalPermission)2 IamRolePermission (com.nike.cerberus.domain.IamRolePermission)2 OffsetDateTime (java.time.OffsetDateTime)2