@Test @WithMockUser(value = USERNAME, roles = ROLE_SU) void isConfiguredForUserTest() { User molgenisUser = mock(User.class); UserSecret userSecret = mock(UserSecret.class); when(molgenisUser.getId()).thenReturn("1324"); when(userService.getUser(USERNAME)).thenReturn(molgenisUser); Query<UserSecret> userSecretQuery = mock(Query.class, RETURNS_SELF); when(dataService.query(UserSecretMetadata.USER_SECRET, UserSecret.class)) .thenReturn(userSecretQuery); when(userSecretQuery.eq(UserSecretMetadata.USER_ID, molgenisUser.getId()).findOne()) .thenReturn(userSecret); when(userSecret.getSecret()).thenReturn("secretKey"); boolean isConfigured = twoFactorAuthenticationServiceImpl.isConfiguredForUser(); assertTrue(isConfigured); }
@Override public boolean isConfiguredForUser() { boolean isConfigured = false; try { UserSecret secret = getSecret(); if (StringUtils.hasText(secret.getSecret())) { isConfigured = true; } } catch (InternalAuthenticationServiceException err) { LOG.warn(err.getMessage()); } return isConfigured; }
TwoFactorAuthenticationServiceImpl implements TwoFactorAuthenticationService { @Override public boolean isConfiguredForUser() { boolean isConfigured = false; try { UserSecret secret = getSecret(); if (StringUtils.hasText(secret.getSecret())) { isConfigured = true; } } catch (InternalAuthenticationServiceException err) { LOG.warn(err.getMessage()); } return isConfigured; } }
TwoFactorAuthenticationServiceImpl implements TwoFactorAuthenticationService { @Override public boolean isConfiguredForUser() { boolean isConfigured = false; try { UserSecret secret = getSecret(); if (StringUtils.hasText(secret.getSecret())) { isConfigured = true; } } catch (InternalAuthenticationServiceException err) { LOG.warn(err.getMessage()); } return isConfigured; } TwoFactorAuthenticationServiceImpl(
      OtpService otpService,
      DataService dataService,
      UserService userService,
      IdGenerator idGenerator,
      UserSecretFactory userSecretFactory); }
TwoFactorAuthenticationServiceImpl implements TwoFactorAuthenticationService { @Override public boolean isConfiguredForUser() { boolean isConfigured = false; try { UserSecret secret = getSecret(); if (StringUtils.hasText(secret.getSecret())) { isConfigured = true; } } catch (InternalAuthenticationServiceException err) { LOG.warn(err.getMessage()); } return isConfigured; } TwoFactorAuthenticationServiceImpl(
      OtpService otpService,
      DataService dataService,
      UserService userService,
      IdGenerator idGenerator,
      UserSecretFactory userSecretFactory); @Override boolean isVerificationCodeValidForUser(String verificationCode); @Override boolean userIsBlocked(); @Override void saveSecretForUser(String secret); @Override void resetSecretForUser(); @Override void enableForUser(); @Override void disableForUser(); @Override String generateSecretKey(); @Override boolean isConfiguredForUser(); }
TwoFactorAuthenticationServiceImpl implements TwoFactorAuthenticationService { @Override public boolean isConfiguredForUser() { boolean isConfigured = false; try { UserSecret secret = getSecret(); if (StringUtils.hasText(secret.getSecret())) { isConfigured = true; } } catch (InternalAuthenticationServiceException err) { LOG.warn(err.getMessage()); } return isConfigured; } TwoFactorAuthenticationServiceImpl(
      OtpService otpService,
      DataService dataService,
      UserService userService,
      IdGenerator idGenerator,
      UserSecretFactory userSecretFactory); @Override boolean isVerificationCodeValidForUser(String verificationCode); @Override boolean userIsBlocked(); @Override void saveSecretForUser(String secret); @Override void resetSecretForUser(); @Override void enableForUser(); @Override void disableForUser(); @Override String generateSecretKey(); @Override boolean isConfiguredForUser();  }