@@ -875,28 +875,27 @@ public void testEnableUserTwoFactorAuthentication() {
875875 @ Test
876876 public void testDisableUserTwoFactorAuthentication () {
877877 Long userId = 1L ;
878+ Long accountId = 2L ;
878879
879880 UserVO userVO = Mockito .mock (UserVO .class );
880881 Account caller = Mockito .mock (Account .class );
882+ Account owner = Mockito .mock (Account .class );
881883
882- AccountVO accountMock = Mockito .mock (AccountVO .class );
883884 Mockito .doNothing ().when (accountManagerImpl ).checkAccess (nullable (Account .class ), Mockito .isNull (), nullable (Boolean .class ), nullable (Account .class ));
884885
885- Mockito .when (caller .getDomainId ()).thenReturn (1L );
886886 Mockito .when (userDaoMock .findById (userId )).thenReturn (userVO );
887- Mockito .when (userVO .getAccountId ()).thenReturn (1L );
888- Mockito .when (_accountDao .findById (1L )).thenReturn (accountMock );
889- Mockito .when (accountMock .getDomainId ()).thenReturn (1L );
890- Mockito .when (_accountService .getActiveAccountById (1L )).thenReturn (caller );
887+ Mockito .when (userVO .getAccountId ()).thenReturn (accountId );
888+ Mockito .when (_accountService .getActiveAccountById (accountId )).thenReturn (owner );
891889
892890 userVoMock .setKeyFor2fa ("EUJEAEDVOURFZTE6OGWVTJZMI54QGMIL" );
893891 userVoMock .setUser2faProvider ("totp" );
894892 userVoMock .setUser2faEnabled (true );
895893
896894 Mockito .when (userDaoMock .createForUpdate ()).thenReturn (userVoMock );
897895
898- UserTwoFactorAuthenticationSetupResponse response = accountManagerImpl .disableTwoFactorAuthentication (userId , caller , caller );
896+ UserTwoFactorAuthenticationSetupResponse response = accountManagerImpl .disableTwoFactorAuthentication (userId , caller , owner );
899897
898+ Mockito .verify (accountManagerImpl ).checkAccess (caller , null , true , owner );
900899 Assert .assertNull (response .getSecretCode ());
901900 Assert .assertNull (userVoMock .getKeyFor2fa ());
902901 Assert .assertNull (userVoMock .getUser2faProvider ());
0 commit comments