jayapalu commented on a change in pull request #1996: CLOUDSTACK-9099:
SecretKey is returned from the APIs
URL: https://github.com/apache/cloudstack/pull/1996#discussion_r116926110
##########
File path: server/test/com/cloud/user/AccountManagerImplTest.java
##########
@@ -170,5 +175,40 @@ public void testAuthenticateUser() throws
UnknownHostException {
Mockito.verify(userAuthenticator,
Mockito.never()).authenticate("test", "", 1L, null);
}
+ @Mock
+ AccountVO callingAccount;
+ @Mock
+ DomainChecker domainChecker;
+ @Mock
+ AccountService accountService;
+ @Mock
+ private GetUserKeysCmd _listkeyscmd;
+ @Mock
+ private Account _account;
+ @Mock
+ private User _user;
+ @Mock
+ private UserAccountVO userAccountVO;
+
+
+ @Test (expected = PermissionDeniedException.class)
+ public void testgetUserCmd(){
+ CallContext.register(callingUser, callingAccount); // Calling account
is user account i.e normal account
+ Mockito.when(_listkeyscmd.getID()).thenReturn(1L);
+ Mockito.when(accountManager.getActiveUser(1L)).thenReturn(_user);
+
Mockito.when(accountManager.getUserAccountById(1L)).thenReturn(userAccountVO);
+ Mockito.when(userAccountVO.getAccountId()).thenReturn(1L);
+
Mockito.when(accountManager.getAccount(Mockito.anyLong())).thenReturn(_account);
// Queried account - admin account
+
+ Mockito.when(callingUser.getAccountId()).thenReturn(1L);
+ Mockito.when(_accountDao.findById(1L)).thenReturn(callingAccount);
+
+
Mockito.when(accountService.isNormalUser(Mockito.anyLong())).thenReturn(Boolean.TRUE);
+ Mockito.when(_account.getAccountId()).thenReturn(2L);
+
+ accountManager.getKeys(_listkeyscmd);
+
+ }
Review comment:
done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services