@Test public void test_changePassword_success() throws IOException { OutputStream out = new ByteArrayOutputStream(); Mockito.when(customPropsResource.getOutputStream()).thenReturn(out); adminDetailsServiceToTest.changePassword(USERNAME, PW); Mockito.verify(persister).store(users, out, "");; }
@Override public boolean changePassword(String username, String password) { String hashedPW = BCrypt.hashpw(password, BCrypt.gensalt()); users.put(username, hashedPW + "," + GilesGrantedAuthority.ROLE_ADMIN + ",enabled"); try { persister.store(users, customPropsResource.getOutputStream(), ""); } catch (IOException e) { messageHandler.handleMessage("Could not store properties.", e, MessageType.ERROR); return false; } return true; }
AdminUserDetailsService implements IAdminUserDetailsService { @Override public boolean changePassword(String username, String password) { String hashedPW = BCrypt.hashpw(password, BCrypt.gensalt()); users.put(username, hashedPW + "," + GilesGrantedAuthority.ROLE_ADMIN + ",enabled"); try { persister.store(users, customPropsResource.getOutputStream(), ""); } catch (IOException e) { messageHandler.handleMessage("Could not store properties.", e, MessageType.ERROR); return false; } return true; } }
AdminUserDetailsService implements IAdminUserDetailsService { @Override public boolean changePassword(String username, String password) { String hashedPW = BCrypt.hashpw(password, BCrypt.gensalt()); users.put(username, hashedPW + "," + GilesGrantedAuthority.ROLE_ADMIN + ",enabled"); try { persister.store(users, customPropsResource.getOutputStream(), ""); } catch (IOException e) { messageHandler.handleMessage("Could not store properties.", e, MessageType.ERROR); return false; } return true; }  }
AdminUserDetailsService implements IAdminUserDetailsService { @Override public boolean changePassword(String username, String password) { String hashedPW = BCrypt.hashpw(password, BCrypt.gensalt()); users.put(username, hashedPW + "," + GilesGrantedAuthority.ROLE_ADMIN + ",enabled"); try { persister.store(users, customPropsResource.getOutputStream(), ""); } catch (IOException e) { messageHandler.handleMessage("Could not store properties.", e, MessageType.ERROR); return false; } return true; }  @PostConstruct void init(); @Override UserDetails loadUserByUsername(String arg0); @Override List<UserDetails> getAllAdmins(); @Override boolean changePassword(String username, String password); @Override boolean isPasswordValid(String username, String password); }
AdminUserDetailsService implements IAdminUserDetailsService { @Override public boolean changePassword(String username, String password) { String hashedPW = BCrypt.hashpw(password, BCrypt.gensalt()); users.put(username, hashedPW + "," + GilesGrantedAuthority.ROLE_ADMIN + ",enabled"); try { persister.store(users, customPropsResource.getOutputStream(), ""); } catch (IOException e) { messageHandler.handleMessage("Could not store properties.", e, MessageType.ERROR); return false; } return true; }  @PostConstruct void init(); @Override UserDetails loadUserByUsername(String arg0); @Override List<UserDetails> getAllAdmins(); @Override boolean changePassword(String username, String password); @Override boolean isPasswordValid(String username, String password);  }