mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Create minimal AccountManager interface.
This commit is contained in:
@@ -3,6 +3,7 @@ package org.briarproject.briar.android.controller;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
|
||||
import org.briarproject.bramble.api.account.AccountManager;
|
||||
import org.briarproject.bramble.api.db.DatabaseConfig;
|
||||
import org.briarproject.bramble.test.BrambleMockTestCase;
|
||||
import org.jmock.Expectations;
|
||||
@@ -26,6 +27,8 @@ public class ConfigControllerImplTest extends BrambleMockTestCase {
|
||||
|
||||
private final SharedPreferences prefs =
|
||||
context.mock(SharedPreferences.class);
|
||||
private final AccountManager accountManager =
|
||||
context.mock(AccountManager.class);
|
||||
private final DatabaseConfig databaseConfig =
|
||||
context.mock(DatabaseConfig.class);
|
||||
private final Editor editor = context.mock(Editor.class);
|
||||
@@ -56,7 +59,7 @@ public class ConfigControllerImplTest extends BrambleMockTestCase {
|
||||
assertFalse(keyFile.exists());
|
||||
assertFalse(keyBackupFile.exists());
|
||||
|
||||
ConfigControllerImpl c = new ConfigControllerImpl(prefs,
|
||||
ConfigControllerImpl c = new ConfigControllerImpl(prefs, accountManager,
|
||||
databaseConfig);
|
||||
|
||||
assertEquals(encryptedKeyHex, c.getEncryptedDatabaseKey());
|
||||
@@ -85,7 +88,7 @@ public class ConfigControllerImplTest extends BrambleMockTestCase {
|
||||
assertFalse(keyBackupFile.exists());
|
||||
assertEquals(encryptedKeyHex, loadDatabaseKey(keyFile));
|
||||
|
||||
ConfigControllerImpl c = new ConfigControllerImpl(prefs,
|
||||
ConfigControllerImpl c = new ConfigControllerImpl(prefs, accountManager,
|
||||
databaseConfig);
|
||||
|
||||
assertEquals(encryptedKeyHex, c.getEncryptedDatabaseKey());
|
||||
@@ -113,7 +116,7 @@ public class ConfigControllerImplTest extends BrambleMockTestCase {
|
||||
assertTrue(keyBackupFile.exists());
|
||||
assertEquals(encryptedKeyHex, loadDatabaseKey(keyBackupFile));
|
||||
|
||||
ConfigControllerImpl c = new ConfigControllerImpl(prefs,
|
||||
ConfigControllerImpl c = new ConfigControllerImpl(prefs, accountManager,
|
||||
databaseConfig);
|
||||
|
||||
assertEquals(encryptedKeyHex, c.getEncryptedDatabaseKey());
|
||||
@@ -135,7 +138,7 @@ public class ConfigControllerImplTest extends BrambleMockTestCase {
|
||||
assertFalse(keyFile.exists());
|
||||
assertFalse(keyBackupFile.exists());
|
||||
|
||||
ConfigControllerImpl c = new ConfigControllerImpl(prefs,
|
||||
ConfigControllerImpl c = new ConfigControllerImpl(prefs, accountManager,
|
||||
databaseConfig);
|
||||
|
||||
assertNull(c.getEncryptedDatabaseKey());
|
||||
@@ -160,7 +163,7 @@ public class ConfigControllerImplTest extends BrambleMockTestCase {
|
||||
assertFalse(keyBackupFile.exists());
|
||||
assertEquals(oldEncryptedKeyHex, loadDatabaseKey(keyFile));
|
||||
|
||||
ConfigController c = new ConfigControllerImpl(prefs,
|
||||
ConfigController c = new ConfigControllerImpl(prefs, accountManager,
|
||||
databaseConfig);
|
||||
|
||||
assertTrue(c.storeEncryptedDatabaseKey(encryptedKeyHex));
|
||||
@@ -187,7 +190,7 @@ public class ConfigControllerImplTest extends BrambleMockTestCase {
|
||||
assertTrue(keyBackupFile.exists());
|
||||
assertEquals(oldEncryptedKeyHex, loadDatabaseKey(keyBackupFile));
|
||||
|
||||
ConfigController c = new ConfigControllerImpl(prefs,
|
||||
ConfigController c = new ConfigControllerImpl(prefs, accountManager,
|
||||
databaseConfig);
|
||||
|
||||
assertTrue(c.storeEncryptedDatabaseKey(encryptedKeyHex));
|
||||
|
||||
@@ -45,7 +45,7 @@ public class TestForumActivity extends ForumActivity {
|
||||
protected BriarController provideBriarController(
|
||||
BriarControllerImpl briarController) {
|
||||
BriarController c = Mockito.mock(BriarController.class);
|
||||
Mockito.when(c.hasEncryptionKey()).thenReturn(true);
|
||||
Mockito.when(c.accountSignedIn()).thenReturn(true);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.briarproject.briar.android.login;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import org.briarproject.bramble.api.account.AccountManager;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.crypto.PasswordStrengthEstimator;
|
||||
import org.briarproject.bramble.api.db.DatabaseConfig;
|
||||
@@ -30,6 +31,8 @@ public class PasswordControllerImplTest extends BrambleMockTestCase {
|
||||
|
||||
private final SharedPreferences briarPrefs =
|
||||
context.mock(SharedPreferences.class);
|
||||
private final AccountManager accountManager =
|
||||
context.mock(AccountManager.class);
|
||||
private final DatabaseConfig databaseConfig =
|
||||
context.mock(DatabaseConfig.class);
|
||||
private final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||
@@ -70,7 +73,8 @@ public class PasswordControllerImplTest extends BrambleMockTestCase {
|
||||
storeDatabaseKey(keyBackupFile, toHexString(oldEncryptedKey));
|
||||
|
||||
PasswordControllerImpl p = new PasswordControllerImpl(briarPrefs,
|
||||
databaseConfig, cryptoExecutor, crypto, estimator);
|
||||
accountManager, databaseConfig, cryptoExecutor, crypto,
|
||||
estimator);
|
||||
|
||||
AtomicBoolean capturedResult = new AtomicBoolean(false);
|
||||
p.changePassword(oldPassword, newPassword, capturedResult::set);
|
||||
@@ -104,7 +108,8 @@ public class PasswordControllerImplTest extends BrambleMockTestCase {
|
||||
storeDatabaseKey(keyBackupFile, toHexString(oldEncryptedKey));
|
||||
|
||||
PasswordControllerImpl p = new PasswordControllerImpl(briarPrefs,
|
||||
databaseConfig, cryptoExecutor, crypto, estimator);
|
||||
accountManager, databaseConfig, cryptoExecutor, crypto,
|
||||
estimator);
|
||||
|
||||
AtomicBoolean capturedResult = new AtomicBoolean(true);
|
||||
p.changePassword(oldPassword, newPassword, capturedResult::set);
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.briarproject.briar.android.login;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
|
||||
import org.briarproject.bramble.api.account.AccountManager;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.crypto.PasswordStrengthEstimator;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
@@ -37,6 +38,8 @@ public class SetupControllerImplTest extends BrambleMockTestCase {
|
||||
|
||||
private final SharedPreferences briarPrefs =
|
||||
context.mock(SharedPreferences.class);
|
||||
private final AccountManager accountManager =
|
||||
context.mock(AccountManager.class);
|
||||
private final DatabaseConfig databaseConfig =
|
||||
context.mock(DatabaseConfig.class);
|
||||
private final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||
@@ -101,8 +104,8 @@ public class SetupControllerImplTest extends BrambleMockTestCase {
|
||||
assertFalse(keyBackupFile.exists());
|
||||
|
||||
SetupControllerImpl s = new SetupControllerImpl(briarPrefs,
|
||||
databaseConfig, cryptoExecutor, crypto, estimator,
|
||||
identityManager);
|
||||
accountManager, databaseConfig, cryptoExecutor, crypto,
|
||||
estimator, identityManager);
|
||||
s.setSetupActivity(setupActivity);
|
||||
|
||||
AtomicBoolean called = new AtomicBoolean(false);
|
||||
|
||||
Reference in New Issue
Block a user