Skip to content

Commit 3a3df82

Browse files
committed
Remove unnecessary stubbings
1 parent 5b1aca4 commit 3a3df82

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

server/src/test/java/com/cloud/user/AccountManagerImplTest.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,14 +1612,7 @@ public void testCheckRoleEscalationSamePermissionsShouldPass() throws Exception
16121612
Mockito.when(checker.isEnabled()).thenReturn(true);
16131613

16141614
Account caller = Mockito.mock(Account.class);
1615-
Mockito.when(caller.getAccountName()).thenReturn("caller");
1616-
Mockito.when(caller.getUuid()).thenReturn("caller-uuid");
1617-
Mockito.when(caller.getRoleId()).thenReturn(4L);
1618-
16191615
Account requested = Mockito.mock(Account.class);
1620-
Mockito.when(requested.getAccountName()).thenReturn("requested");
1621-
Mockito.when(requested.getUuid()).thenReturn("requested-uuid");
1622-
Mockito.when(requested.getRoleId()).thenReturn(4L);
16231616

16241617
accountManagerImpl.setApiAccessCheckers(Arrays.asList(checker));
16251618
setPrivateField(accountManagerImpl, "apiNameList", new ArrayList<>(apis));
@@ -1636,14 +1629,7 @@ public void testCheckRoleEscalationCallerHasMorePermissionsShouldPass() throws E
16361629
Mockito.when(checker.isEnabled()).thenReturn(true);
16371630

16381631
Account caller = Mockito.mock(Account.class);
1639-
Mockito.when(caller.getAccountName()).thenReturn("caller");
1640-
Mockito.when(caller.getUuid()).thenReturn("caller-uuid");
1641-
Mockito.when(caller.getRoleId()).thenReturn(4L);
1642-
16431632
Account requested = Mockito.mock(Account.class);
1644-
Mockito.when(requested.getAccountName()).thenReturn("requested");
1645-
Mockito.when(requested.getUuid()).thenReturn("requested-uuid");
1646-
Mockito.when(requested.getRoleId()).thenReturn(5L);
16471633

16481634
Mockito.when(checker.getApisAllowedToAccount(Mockito.eq(requested), Mockito.anyList())).thenReturn(requestedApis);
16491635
Mockito.when(checker.getApisAllowedToAccount(Mockito.eq(caller), Mockito.anyList())).thenReturn(allApis);
@@ -1664,15 +1650,7 @@ public void testCheckRoleEscalationRequestedHasMorePermissionsShouldThrow() thro
16641650
Mockito.when(checker.isEnabled()).thenReturn(true);
16651651

16661652
Account caller = Mockito.mock(Account.class);
1667-
Mockito.when(caller.getAccountName()).thenReturn("caller");
1668-
Mockito.when(caller.getUuid()).thenReturn("caller-uuid");
1669-
Mockito.when(caller.getRoleId()).thenReturn(4L);
1670-
Mockito.when(caller.getDomainId()).thenReturn(1L);
1671-
16721653
Account requested = Mockito.mock(Account.class);
1673-
Mockito.when(requested.getAccountName()).thenReturn("requested");
1674-
Mockito.when(requested.getUuid()).thenReturn("requested-uuid");
1675-
Mockito.when(requested.getRoleId()).thenReturn(5L);
16761654

16771655
Mockito.when(checker.getApisAllowedToAccount(Mockito.eq(requested), Mockito.anyList())).thenReturn(requestedApis);
16781656
Mockito.when(checker.getApisAllowedToAccount(Mockito.eq(caller), Mockito.anyList())).thenReturn(callerApis);
@@ -1690,14 +1668,7 @@ public void testCheckRoleEscalationEmptyApiListShouldPass() throws Exception {
16901668
Mockito.when(checker.getApisAllowedToAccount(Mockito.any(Account.class), Mockito.anyList())).thenReturn(Collections.emptyList());
16911669

16921670
Account caller = Mockito.mock(Account.class);
1693-
Mockito.when(caller.getAccountName()).thenReturn("caller");
1694-
Mockito.when(caller.getUuid()).thenReturn("caller-uuid");
1695-
Mockito.when(caller.getRoleId()).thenReturn(4L);
1696-
16971671
Account requested = Mockito.mock(Account.class);
1698-
Mockito.when(requested.getAccountName()).thenReturn("requested");
1699-
Mockito.when(requested.getUuid()).thenReturn("requested-uuid");
1700-
Mockito.when(requested.getRoleId()).thenReturn(5L);
17011672

17021673
accountManagerImpl.setApiAccessCheckers(Arrays.asList(checker));
17031674
setPrivateField(accountManagerImpl, "apiNameList", new ArrayList<>());
@@ -1717,14 +1688,7 @@ public void testCheckRoleEscalationMultipleCheckersAppliedSequentially() throws
17171688
Mockito.when(checker2.isEnabled()).thenReturn(true);
17181689

17191690
Account caller = Mockito.mock(Account.class);
1720-
Mockito.when(caller.getAccountName()).thenReturn("caller");
1721-
Mockito.when(caller.getUuid()).thenReturn("caller-uuid");
1722-
Mockito.when(caller.getRoleId()).thenReturn(4L);
1723-
17241691
Account requested = Mockito.mock(Account.class);
1725-
Mockito.when(requested.getAccountName()).thenReturn("requested");
1726-
Mockito.when(requested.getUuid()).thenReturn("requested-uuid");
1727-
Mockito.when(requested.getRoleId()).thenReturn(5L);
17281692

17291693
// requested: checker1 filters to [api1, api2], checker2 further filters to [api1]
17301694
Mockito.when(checker1.getApisAllowedToAccount(Mockito.eq(requested), Mockito.eq(allApis))).thenReturn(afterChecker1);

0 commit comments

Comments
 (0)