@Test public void testChangePasswordReturnsFalseIfPasswordIsWrong() throws Exception { context.checking(new Expectations() {{ oneOf(crypto).decryptWithPassword(encryptedKey, password); will(returnValue(null)); }}); storeDatabaseKey(keyFile, encryptedKeyHex); storeDatabaseKey(keyBackupFile, encryptedKeyHex); assertFalse(accountManager.changePassword(password, newPassword)); assertEquals(encryptedKeyHex, loadDatabaseKey(keyFile)); assertEquals(encryptedKeyHex, loadDatabaseKey(keyBackupFile)); }
@Override public boolean changePassword(String oldPassword, String newPassword) { synchronized (stateChangeLock) { SecretKey key = loadAndDecryptDatabaseKey(oldPassword); return key != null && encryptAndStoreDatabaseKey(key, newPassword); } }
AccountManagerImpl implements AccountManager { @Override public boolean changePassword(String oldPassword, String newPassword) { synchronized (stateChangeLock) { SecretKey key = loadAndDecryptDatabaseKey(oldPassword); return key != null && encryptAndStoreDatabaseKey(key, newPassword); } } }
AccountManagerImpl implements AccountManager { @Override public boolean changePassword(String oldPassword, String newPassword) { synchronized (stateChangeLock) { SecretKey key = loadAndDecryptDatabaseKey(oldPassword); return key != null && encryptAndStoreDatabaseKey(key, newPassword); } } @Inject  AccountManagerImpl(DatabaseConfig databaseConfig, CryptoComponent crypto,
			IdentityManager identityManager); }
AccountManagerImpl implements AccountManager { @Override public boolean changePassword(String oldPassword, String newPassword) { synchronized (stateChangeLock) { SecretKey key = loadAndDecryptDatabaseKey(oldPassword); return key != null && encryptAndStoreDatabaseKey(key, newPassword); } } @Inject  AccountManagerImpl(DatabaseConfig databaseConfig, CryptoComponent crypto,
			IdentityManager identityManager); @Override boolean hasDatabaseKey(); @Override @Nullable SecretKey getDatabaseKey(); @Override boolean accountExists(); @Override boolean createAccount(String name, String password); @Override void deleteAccount(); @Override boolean signIn(String password); @Override boolean changePassword(String oldPassword, String newPassword); }
AccountManagerImpl implements AccountManager { @Override public boolean changePassword(String oldPassword, String newPassword) { synchronized (stateChangeLock) { SecretKey key = loadAndDecryptDatabaseKey(oldPassword); return key != null && encryptAndStoreDatabaseKey(key, newPassword); } } @Inject  AccountManagerImpl(DatabaseConfig databaseConfig, CryptoComponent crypto,
			IdentityManager identityManager); @Override boolean hasDatabaseKey(); @Override @Nullable SecretKey getDatabaseKey(); @Override boolean accountExists(); @Override boolean createAccount(String name, String password); @Override void deleteAccount(); @Override boolean signIn(String password); @Override boolean changePassword(String oldPassword, String newPassword);  }