use of com.nike.cerberus.domain.SafeDepositBoxSummary in project cerberus by Nike-Inc.
the class SafeDepositBoxControllerV2Test method testGetSafeDepositBoxes.
@Test
public void testGetSafeDepositBoxes() {
CerberusPrincipal cerberusPrincipal = Mockito.mock(CerberusPrincipal.class);
SafeDepositBoxSummary safeDepositBoxSummary = Mockito.mock(SafeDepositBoxSummary.class);
List<SafeDepositBoxSummary> safeDepositBoxSummaries = new ArrayList<>();
safeDepositBoxSummaries.add(safeDepositBoxSummary);
Mockito.when(safeDepositBoxService.getAssociatedSafeDepositBoxes(cerberusPrincipal)).thenReturn(safeDepositBoxSummaries);
List<SafeDepositBoxSummary> actualSafeDepositBoSummaries = safeDepositBoxControllerV2.getSafeDepositBoxes(cerberusPrincipal);
Assert.assertSame(safeDepositBoxSummaries, actualSafeDepositBoSummaries);
Assert.assertEquals(safeDepositBoxSummaries, actualSafeDepositBoSummaries);
}
use of com.nike.cerberus.domain.SafeDepositBoxSummary in project cerberus by Nike-Inc.
the class SafeDepositBoxServiceTest method test_that_getAssociatedSafeDepositBoxes_checks_assumed_role_and_its_base_iam_role.
@Test
@SuppressFBWarnings
public void test_that_getAssociatedSafeDepositBoxes_checks_assumed_role_and_its_base_iam_role() {
String assumedRoleArn = "arn:aws:sts::123456789012:assumed-role/Accounting-Role/Mary";
String iamRoleArn = "arn:aws:iam::123456789012:role/Accounting-Role";
String rootArn = "arn:aws:iam::123456789012:root";
CerberusPrincipal AssumedRoleArnPrincipal = mock(CerberusPrincipal.class);
doReturn(PrincipalType.IAM).when(AssumedRoleArnPrincipal).getPrincipalType();
doReturn(assumedRoleArn).when(AssumedRoleArnPrincipal).getName();
when(awsIamRoleArnParser.isAssumedRoleArn(assumedRoleArn)).thenReturn(true);
when(awsIamRoleArnParser.convertPrincipalArnToRoleArn(assumedRoleArn)).thenReturn(iamRoleArn);
when(awsIamRoleArnParser.convertPrincipalArnToRootArn(assumedRoleArn)).thenReturn(rootArn);
SafeDepositBoxRecord safeDepositBoxRecord1 = new SafeDepositBoxRecord();
SafeDepositBoxRecord safeDepositBoxRecord2 = new SafeDepositBoxRecord();
List<SafeDepositBoxRecord> assumedRoleArnRecords = Lists.newArrayList(safeDepositBoxRecord1, safeDepositBoxRecord2);
when(safeDepositBoxDao.getAssumedRoleAssociatedSafeDepositBoxes(assumedRoleArn, iamRoleArn, rootArn)).thenReturn(assumedRoleArnRecords);
List<SafeDepositBoxSummary> sdbSummaries = safeDepositBoxServiceSpy.getAssociatedSafeDepositBoxes(AssumedRoleArnPrincipal);
assertEquals(assumedRoleArnRecords.size(), sdbSummaries.size());
}
use of com.nike.cerberus.domain.SafeDepositBoxSummary in project cerberus by Nike-Inc.
the class SafeDepositBoxServiceTest method test_that_getAssociatedSafeDepositBoxes_checks_iam_role.
@Test
@SuppressFBWarnings
public void test_that_getAssociatedSafeDepositBoxes_checks_iam_role() {
String iamRoleArn = "arn:aws:iam::123456789012:role/Accounting-Role";
String rootArn = "arn:aws:iam::123456789012:root";
SafeDepositBoxRecord safeDepositBoxRecord1 = new SafeDepositBoxRecord();
List<SafeDepositBoxRecord> roleArnRecords = Lists.newArrayList(safeDepositBoxRecord1);
when(safeDepositBoxDao.getIamPrincipalAssociatedSafeDepositBoxes(iamRoleArn, rootArn)).thenReturn(roleArnRecords);
when(awsIamRoleArnParser.isAssumedRoleArn(iamRoleArn)).thenReturn(false);
when(awsIamRoleArnParser.convertPrincipalArnToRootArn(iamRoleArn)).thenReturn(rootArn);
CerberusPrincipal roleArnPrincipal = mock(CerberusPrincipal.class);
doReturn(PrincipalType.IAM).when(roleArnPrincipal).getPrincipalType();
doReturn(iamRoleArn).when(roleArnPrincipal).getName();
List<SafeDepositBoxSummary> roleArnSdbSummaries = safeDepositBoxServiceSpy.getAssociatedSafeDepositBoxes(roleArnPrincipal);
assertEquals(roleArnRecords.size(), roleArnSdbSummaries.size());
}
Aggregations