mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
Refactored tests for account setup and changing password.
This commit is contained in:
@@ -33,9 +33,8 @@ public class AuthorNameFragment extends SetupFragment {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
getActivity().setTitle(getString(R.string.setup_title));
|
getActivity().setTitle(getString(R.string.setup_title));
|
||||||
View v =
|
View v = inflater.inflate(R.layout.fragment_setup_author_name,
|
||||||
inflater.inflate(R.layout.fragment_setup_author_name, container,
|
container, false);
|
||||||
false);
|
|
||||||
authorNameWrapper =
|
authorNameWrapper =
|
||||||
(TextInputLayout) v.findViewById(R.id.nickname_entry_wrapper);
|
(TextInputLayout) v.findViewById(R.id.nickname_entry_wrapper);
|
||||||
authorNameInput =
|
authorNameInput =
|
||||||
@@ -43,7 +42,6 @@ public class AuthorNameFragment extends SetupFragment {
|
|||||||
nextButton = (Button) v.findViewById(R.id.next);
|
nextButton = (Button) v.findViewById(R.id.next);
|
||||||
|
|
||||||
authorNameInput.addTextChangedListener(this);
|
authorNameInput.addTextChangedListener(this);
|
||||||
|
|
||||||
nextButton.setOnClickListener(this);
|
nextButton.setOnClickListener(this);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ public class DozeFragment extends SetupFragment {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
getActivity().setTitle(getString(R.string.setup_doze_title));
|
getActivity().setTitle(getString(R.string.setup_doze_title));
|
||||||
View v =
|
View v = inflater.inflate(R.layout.fragment_setup_doze, container,
|
||||||
inflater.inflate(R.layout.fragment_setup_doze, container,
|
|
||||||
false);
|
false);
|
||||||
dozeButton = (Button) v.findViewById(R.id.dozeButton);
|
dozeButton = (Button) v.findViewById(R.id.dozeButton);
|
||||||
progressBar = (ProgressBar) v.findViewById(R.id.progress);
|
progressBar = (ProgressBar) v.findViewById(R.id.progress);
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class PasswordControllerImpl extends ConfigControllerImpl
|
|||||||
return StringUtils.fromHexString(hex);
|
return StringUtils.fromHexString(hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call inside cryptoExecutor
|
@CryptoExecutor
|
||||||
String encryptDatabaseKey(SecretKey key, String password) {
|
String encryptDatabaseKey(SecretKey key, String password) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
byte[] encrypted = crypto.encryptWithPassword(key.getBytes(), password);
|
byte[] encrypted = crypto.encryptWithPassword(key.getBytes(), password);
|
||||||
|
|||||||
@@ -37,8 +37,7 @@ public class PasswordFragment extends SetupFragment {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
getActivity().setTitle(getString(R.string.setup_password_intro));
|
getActivity().setTitle(getString(R.string.setup_password_intro));
|
||||||
View v =
|
View v = inflater.inflate(R.layout.fragment_setup_password, container,
|
||||||
inflater.inflate(R.layout.fragment_setup_password, container,
|
|
||||||
false);
|
false);
|
||||||
|
|
||||||
strengthMeter = (StrengthMeter) v.findViewById(R.id.strength_meter);
|
strengthMeter = (StrengthMeter) v.findViewById(R.id.strength_meter);
|
||||||
|
|||||||
@@ -42,18 +42,20 @@ abstract class SetupFragment extends BaseFragment implements TextWatcher,
|
|||||||
protected abstract String getHelpText();
|
protected abstract String getHelpText();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1,
|
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||||
int i2) {
|
int after) {
|
||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence authorName, int i, int i1, int i2) {
|
public void onTextChanged(CharSequence s, int start, int before,
|
||||||
|
int count) {
|
||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
|
public boolean onEditorAction(TextView textView, int actionId,
|
||||||
|
KeyEvent keyEvent) {
|
||||||
onClick(textView);
|
onClick(textView);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,11 +192,8 @@ public class NavDrawerActivity extends BriarActivity implements
|
|||||||
drawerLayout.closeDrawer(START);
|
drawerLayout.closeDrawer(START);
|
||||||
clearBackStack();
|
clearBackStack();
|
||||||
loadFragment(item.getItemId());
|
loadFragment(item.getItemId());
|
||||||
//Don't display the Settings Item as checked
|
// Don't display the Settings item as checked
|
||||||
if (item.getItemId() == R.id.nav_btn_settings) {
|
return item.getItemId() != R.id.nav_btn_settings;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -214,7 +211,7 @@ public class NavDrawerActivity extends BriarActivity implements
|
|||||||
getSupportFragmentManager()
|
getSupportFragmentManager()
|
||||||
.findFragmentByTag(ContactListFragment.TAG) == null) {
|
.findFragmentByTag(ContactListFragment.TAG) == null) {
|
||||||
/*
|
/*
|
||||||
* This Makes sure that the first fragment (ContactListFragment) the
|
* This makes sure that the first fragment (ContactListFragment) the
|
||||||
* user sees is the same as the last fragment the user sees before
|
* user sees is the same as the last fragment the user sees before
|
||||||
* exiting. This models the typical Google navigation behaviour such
|
* exiting. This models the typical Google navigation behaviour such
|
||||||
* as in Gmail/Inbox.
|
* as in Gmail/Inbox.
|
||||||
|
|||||||
@@ -172,8 +172,7 @@ public class UiUtils {
|
|||||||
|
|
||||||
public static boolean needsDozeWhitelisting(Context ctx) {
|
public static boolean needsDozeWhitelisting(Context ctx) {
|
||||||
if (Build.VERSION.SDK_INT < 23) return false;
|
if (Build.VERSION.SDK_INT < 23) return false;
|
||||||
PowerManager pm =
|
PowerManager pm = (PowerManager) ctx.getSystemService(POWER_SERVICE);
|
||||||
(PowerManager) ctx.getSystemService(POWER_SERVICE);
|
|
||||||
String packageName = ctx.getPackageName();
|
String packageName = ctx.getPackageName();
|
||||||
if (pm == null) throw new AssertionError();
|
if (pm == null) throw new AssertionError();
|
||||||
return !pm.isIgnoringBatteryOptimizations(packageName);
|
return !pm.isIgnoringBatteryOptimizations(packageName);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<!-- Setup -->
|
<!-- Setup -->
|
||||||
<string name="setup_title">Welcome to Briar</string>
|
<string name="setup_title">Welcome to Briar</string>
|
||||||
<string name="setup_name_explanation">Choose your user name wisely. You can not change it later and it will be shown next to content you post.\n\nWhen this content is shared, strangers might see your name.</string>
|
<string name="setup_name_explanation">Your nickname will be shown next to any content you post. You can\'t change it after creating your account.</string>
|
||||||
<string name="setup_next">Next</string>
|
<string name="setup_next">Next</string>
|
||||||
<string name="setup_password_intro">Choose a Password</string>
|
<string name="setup_password_intro">Choose a Password</string>
|
||||||
<string name="setup_password_explanation">Your Briar account is stored encrypted on your device, not in the cloud. If you forget your password or uninstall Briar, there\'s no way to recover your account.\n\nChoose a long password that\'s hard to guess, such as four random words, or ten random letters, numbers and symbols.</string>
|
<string name="setup_password_explanation">Your Briar account is stored encrypted on your device, not in the cloud. If you forget your password or uninstall Briar, there\'s no way to recover your account.\n\nChoose a long password that\'s hard to guess, such as four random words, or ten random letters, numbers and symbols.</string>
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package org.briarproject.briar.android.login;
|
package org.briarproject.briar.android.login;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.support.design.widget.TextInputLayout;
|
import android.support.design.widget.TextInputLayout;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@@ -29,12 +27,8 @@ import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUIT
|
|||||||
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_WEAK;
|
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_WEAK;
|
||||||
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.STRONG;
|
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.STRONG;
|
||||||
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.WEAK;
|
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.WEAK;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.mockito.Matchers.anyString;
|
import static org.mockito.Matchers.anyString;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.timeout;
|
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -45,8 +39,6 @@ import static org.mockito.Mockito.when;
|
|||||||
packageName = "org.briarproject.briar")
|
packageName = "org.briarproject.briar")
|
||||||
public class ChangePasswordActivityTest {
|
public class ChangePasswordActivityTest {
|
||||||
|
|
||||||
private static final int TIMEOUT_MS = 10 * 1000;
|
|
||||||
|
|
||||||
private TestChangePasswordActivity changePasswordActivity;
|
private TestChangePasswordActivity changePasswordActivity;
|
||||||
private TextInputLayout passwordConfirmationWrapper;
|
private TextInputLayout passwordConfirmationWrapper;
|
||||||
private EditText currentPassword;
|
private EditText currentPassword;
|
||||||
@@ -69,18 +61,14 @@ public class ChangePasswordActivityTest {
|
|||||||
.findViewById(R.id.new_password_confirm_wrapper);
|
.findViewById(R.id.new_password_confirm_wrapper);
|
||||||
currentPassword = (EditText) changePasswordActivity
|
currentPassword = (EditText) changePasswordActivity
|
||||||
.findViewById(R.id.current_password_entry);
|
.findViewById(R.id.current_password_entry);
|
||||||
newPassword =
|
newPassword = (EditText) changePasswordActivity
|
||||||
(EditText) changePasswordActivity
|
.findViewById(R.id.new_password_entry);
|
||||||
.findViewById(R.id.new_password_entry);
|
newPasswordConfirmation = (EditText) changePasswordActivity
|
||||||
newPasswordConfirmation =
|
.findViewById(R.id.new_password_confirm);
|
||||||
(EditText) changePasswordActivity
|
strengthMeter = (StrengthMeter) changePasswordActivity
|
||||||
.findViewById(R.id.new_password_confirm);
|
.findViewById(R.id.strength_meter);
|
||||||
strengthMeter =
|
changePasswordButton = (Button) changePasswordActivity
|
||||||
(StrengthMeter) changePasswordActivity
|
.findViewById(R.id.change_password);
|
||||||
.findViewById(R.id.strength_meter);
|
|
||||||
changePasswordButton =
|
|
||||||
(Button) changePasswordActivity
|
|
||||||
.findViewById(R.id.change_password);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testStrengthMeter(String pass, float strength, int color) {
|
private void testStrengthMeter(String pass, float strength, int color) {
|
||||||
@@ -134,90 +122,38 @@ public class ChangePasswordActivityTest {
|
|||||||
assertEquals(changePasswordActivity.isFinishing(), true);
|
assertEquals(changePasswordActivity.isFinishing(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPasswordChange() {
|
|
||||||
PasswordController passwordController =
|
|
||||||
changePasswordActivity.getPasswordController();
|
|
||||||
|
|
||||||
TestSetupActivity setupActivity =
|
|
||||||
Robolectric.setupActivity(TestSetupActivity.class);
|
|
||||||
SetupController setupController = setupActivity.getController();
|
|
||||||
setupController.setAuthorName("nick");
|
|
||||||
setupController.setPassword("some.old.pass");
|
|
||||||
// mock a resulthandler
|
|
||||||
ResultHandler<Void> resultHandler = mock(ResultHandler.class);
|
|
||||||
setupController.createAccount(resultHandler);
|
|
||||||
verify(resultHandler, timeout(TIMEOUT_MS).times(1)).onResult(null);
|
|
||||||
|
|
||||||
SharedPreferences prefs = changePasswordActivity
|
|
||||||
.getSharedPreferences("db", Context.MODE_PRIVATE);
|
|
||||||
// Confirm database key
|
|
||||||
assertTrue(prefs.contains("key"));
|
|
||||||
String oldKey = prefs.getString("key", null);
|
|
||||||
// mock a resulthandler
|
|
||||||
ResultHandler<Boolean> resultHandler2 = mock(ResultHandler.class);
|
|
||||||
passwordController.changePassword("some.old.pass", "some.strong.pass",
|
|
||||||
resultHandler2);
|
|
||||||
// blocking verification call with timeout that waits until the mocked
|
|
||||||
// result gets called with handle 0L, the expected value
|
|
||||||
verify(resultHandler2, timeout(TIMEOUT_MS).times(1)).onResult(true);
|
|
||||||
// Confirm database key
|
|
||||||
assertTrue(prefs.contains("key"));
|
|
||||||
assertNotEquals(oldKey, prefs.getString("key", null));
|
|
||||||
// Note that Robolectric uses its own persistent storage that it
|
|
||||||
// wipes clean after each test run, no need to clean up manually.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStrengthMeter() {
|
|
||||||
PasswordController controller =
|
|
||||||
changePasswordActivity.getPasswordController();
|
|
||||||
|
|
||||||
String strongPass = "very.strong.password.123";
|
|
||||||
String weakPass = "we";
|
|
||||||
String quiteStrongPass = "quite.strong";
|
|
||||||
|
|
||||||
float val = controller.estimatePasswordStrength(strongPass);
|
|
||||||
assertTrue(val == STRONG);
|
|
||||||
val = controller.estimatePasswordStrength(weakPass);
|
|
||||||
assertTrue(val < WEAK && val > NONE);
|
|
||||||
val = controller.estimatePasswordStrength(quiteStrongPass);
|
|
||||||
assertTrue(val < STRONG && val > QUITE_WEAK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStrengthMeterUI() {
|
public void testStrengthMeterUI() {
|
||||||
Assert.assertNotNull(changePasswordActivity);
|
Assert.assertNotNull(changePasswordActivity);
|
||||||
// replace the password controller with our mocked copy
|
// replace the password controller with our mocked copy
|
||||||
PasswordController mockedController = this.passwordController;
|
changePasswordActivity.setPasswordController(passwordController);
|
||||||
changePasswordActivity.setPasswordController(mockedController);
|
|
||||||
// Mock answers for UI testing only
|
// Mock answers for UI testing only
|
||||||
when(mockedController.estimatePasswordStrength("strong")).thenReturn(
|
when(passwordController.estimatePasswordStrength("strong")).thenReturn(
|
||||||
STRONG);
|
STRONG);
|
||||||
when(mockedController.estimatePasswordStrength("qstrong")).thenReturn(
|
when(passwordController.estimatePasswordStrength("qstrong")).thenReturn(
|
||||||
QUITE_STRONG);
|
QUITE_STRONG);
|
||||||
when(mockedController.estimatePasswordStrength("qweak")).thenReturn(
|
when(passwordController.estimatePasswordStrength("qweak")).thenReturn(
|
||||||
QUITE_WEAK);
|
QUITE_WEAK);
|
||||||
when(mockedController.estimatePasswordStrength("weak")).thenReturn(
|
when(passwordController.estimatePasswordStrength("weak")).thenReturn(
|
||||||
WEAK);
|
WEAK);
|
||||||
when(mockedController.estimatePasswordStrength("empty")).thenReturn(
|
when(passwordController.estimatePasswordStrength("empty")).thenReturn(
|
||||||
NONE);
|
NONE);
|
||||||
// Test the meters progress and color for several values
|
// Test the meters progress and color for several values
|
||||||
testStrengthMeter("strong", STRONG, StrengthMeter.GREEN);
|
testStrengthMeter("strong", STRONG, StrengthMeter.GREEN);
|
||||||
Mockito.verify(mockedController, Mockito.times(1))
|
Mockito.verify(passwordController, Mockito.times(1))
|
||||||
.estimatePasswordStrength(eq("strong"));
|
.estimatePasswordStrength(eq("strong"));
|
||||||
testStrengthMeter("qstrong", QUITE_STRONG, StrengthMeter.LIME);
|
testStrengthMeter("qstrong", QUITE_STRONG, StrengthMeter.LIME);
|
||||||
Mockito.verify(mockedController, Mockito.times(1))
|
Mockito.verify(passwordController, Mockito.times(1))
|
||||||
.estimatePasswordStrength(eq("qstrong"));
|
.estimatePasswordStrength(eq("qstrong"));
|
||||||
testStrengthMeter("qweak", QUITE_WEAK, StrengthMeter.YELLOW);
|
testStrengthMeter("qweak", QUITE_WEAK, StrengthMeter.YELLOW);
|
||||||
Mockito.verify(mockedController, Mockito.times(1))
|
Mockito.verify(passwordController, Mockito.times(1))
|
||||||
.estimatePasswordStrength(eq("qweak"));
|
.estimatePasswordStrength(eq("qweak"));
|
||||||
testStrengthMeter("weak", WEAK, StrengthMeter.ORANGE);
|
testStrengthMeter("weak", WEAK, StrengthMeter.ORANGE);
|
||||||
Mockito.verify(mockedController, Mockito.times(1))
|
Mockito.verify(passwordController, Mockito.times(1))
|
||||||
.estimatePasswordStrength(eq("weak"));
|
.estimatePasswordStrength(eq("weak"));
|
||||||
// Not sure this should be the correct behaviour on an empty input ?
|
// Not sure this should be the correct behaviour on an empty input ?
|
||||||
testStrengthMeter("empty", NONE, StrengthMeter.RED);
|
testStrengthMeter("empty", NONE, StrengthMeter.RED);
|
||||||
Mockito.verify(mockedController, Mockito.times(1))
|
Mockito.verify(passwordController, Mockito.times(1))
|
||||||
.estimatePasswordStrength(eq("empty"));
|
.estimatePasswordStrength(eq("empty"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package org.briarproject.briar.android.login;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||||
|
import org.briarproject.bramble.api.crypto.PasswordStrengthEstimator;
|
||||||
|
import org.briarproject.bramble.api.db.DatabaseConfig;
|
||||||
|
import org.briarproject.bramble.test.BrambleMockTestCase;
|
||||||
|
import org.briarproject.bramble.test.ImmediateExecutor;
|
||||||
|
import org.briarproject.briar.android.controller.handler.ResultHandler;
|
||||||
|
import org.jmock.Expectations;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.assertFalse;
|
||||||
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
import static org.briarproject.bramble.test.TestUtils.getSecretKey;
|
||||||
|
|
||||||
|
public class PasswordControllerImplTest extends BrambleMockTestCase {
|
||||||
|
|
||||||
|
private final SharedPreferences briarPrefs =
|
||||||
|
context.mock(SharedPreferences.class);
|
||||||
|
private final DatabaseConfig databaseConfig =
|
||||||
|
context.mock(DatabaseConfig.class);
|
||||||
|
private final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||||
|
private final PasswordStrengthEstimator estimator =
|
||||||
|
context.mock(PasswordStrengthEstimator.class);
|
||||||
|
private final SharedPreferences.Editor editor =
|
||||||
|
context.mock(SharedPreferences.Editor.class);
|
||||||
|
|
||||||
|
private final Executor cryptoExecutor = new ImmediateExecutor();
|
||||||
|
|
||||||
|
private final String oldPassword = "some.old.pass";
|
||||||
|
private final String newPassword = "some.new.pass";
|
||||||
|
private final String oldEncryptedHex = "010203";
|
||||||
|
private final String newEncryptedHex = "020304";
|
||||||
|
private final byte[] oldEncryptedBytes = new byte[] {1, 2, 3};
|
||||||
|
private final byte[] newEncryptedBytes = new byte[] {2, 3, 4};
|
||||||
|
private final byte[] keyBytes = getSecretKey().getBytes();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChangePasswordReturnsTrue() {
|
||||||
|
context.checking(new Expectations() {{
|
||||||
|
// Look up the encrypted DB key
|
||||||
|
oneOf(briarPrefs).getString("key", null);
|
||||||
|
will(returnValue(oldEncryptedHex));
|
||||||
|
// Decrypt and re-encrypt the key
|
||||||
|
oneOf(crypto).decryptWithPassword(oldEncryptedBytes, oldPassword);
|
||||||
|
will(returnValue(keyBytes));
|
||||||
|
oneOf(crypto).encryptWithPassword(keyBytes, newPassword);
|
||||||
|
will(returnValue(newEncryptedBytes));
|
||||||
|
// Store the re-encrypted key
|
||||||
|
oneOf(briarPrefs).edit();
|
||||||
|
will(returnValue(editor));
|
||||||
|
oneOf(editor).putString("key", newEncryptedHex);
|
||||||
|
oneOf(editor).apply();
|
||||||
|
}});
|
||||||
|
|
||||||
|
PasswordControllerImpl p = new PasswordControllerImpl(briarPrefs,
|
||||||
|
databaseConfig, cryptoExecutor, crypto, estimator);
|
||||||
|
|
||||||
|
final AtomicBoolean capturedResult = new AtomicBoolean(false);
|
||||||
|
p.changePassword(oldPassword, newPassword,
|
||||||
|
new ResultHandler<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onResult(Boolean result) {
|
||||||
|
capturedResult.set(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assertTrue(capturedResult.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChangePasswordReturnsFalseIfOldPasswordIsWrong() {
|
||||||
|
context.checking(new Expectations() {{
|
||||||
|
// Look up the encrypted DB key
|
||||||
|
oneOf(briarPrefs).getString("key", null);
|
||||||
|
will(returnValue(oldEncryptedHex));
|
||||||
|
// Try to decrypt the key - the password is wrong
|
||||||
|
oneOf(crypto).decryptWithPassword(oldEncryptedBytes, oldPassword);
|
||||||
|
will(returnValue(null));
|
||||||
|
}});
|
||||||
|
|
||||||
|
PasswordControllerImpl p = new PasswordControllerImpl(briarPrefs,
|
||||||
|
databaseConfig, cryptoExecutor, crypto, estimator);
|
||||||
|
|
||||||
|
final AtomicBoolean capturedResult = new AtomicBoolean(true);
|
||||||
|
p.changePassword(oldPassword, newPassword,
|
||||||
|
new ResultHandler<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onResult(Boolean result) {
|
||||||
|
capturedResult.set(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assertFalse(capturedResult.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.briarproject.briar.android.login;
|
package org.briarproject.briar.android.login;
|
||||||
|
|
||||||
|
import android.support.design.widget.TextInputLayout;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@@ -16,8 +17,12 @@ import org.robolectric.RobolectricGradleTestRunner;
|
|||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
|
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.NONE;
|
||||||
|
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_STRONG;
|
||||||
|
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_WEAK;
|
||||||
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.STRONG;
|
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.STRONG;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.WEAK;
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -32,6 +37,8 @@ public class PasswordFragmentTest {
|
|||||||
private PasswordFragment passwordFragment = new PasswordFragment();
|
private PasswordFragment passwordFragment = new PasswordFragment();
|
||||||
private EditText passwordEntry;
|
private EditText passwordEntry;
|
||||||
private EditText passwordConfirmation;
|
private EditText passwordConfirmation;
|
||||||
|
private TextInputLayout passwordConfirmationWrapper;
|
||||||
|
private StrengthMeter strengthMeter;
|
||||||
private Button createAccountButton;
|
private Button createAccountButton;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@@ -45,17 +52,21 @@ public class PasswordFragmentTest {
|
|||||||
View v = passwordFragment.getView();
|
View v = passwordFragment.getView();
|
||||||
passwordEntry = (EditText) v.findViewById(R.id.password_entry);
|
passwordEntry = (EditText) v.findViewById(R.id.password_entry);
|
||||||
passwordConfirmation = (EditText) v.findViewById(R.id.password_confirm);
|
passwordConfirmation = (EditText) v.findViewById(R.id.password_confirm);
|
||||||
|
passwordConfirmationWrapper =
|
||||||
|
(TextInputLayout) v.findViewById(R.id.password_confirm_wrapper);
|
||||||
|
strengthMeter = (StrengthMeter) v.findViewById(R.id.strength_meter);
|
||||||
createAccountButton = (Button) v.findViewById(R.id.next);
|
createAccountButton = (Button) v.findViewById(R.id.next);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateAccountUI() {
|
public void testCreateAccountUI() {
|
||||||
|
String safePass = "really.safe.password";
|
||||||
|
|
||||||
passwordFragment.setupController = setupController;
|
passwordFragment.setupController = setupController;
|
||||||
when(setupController.needsDozeWhitelisting()).thenReturn(false);
|
when(setupController.needsDozeWhitelisting()).thenReturn(false);
|
||||||
when(setupController.estimatePasswordStrength(anyString()))
|
when(setupController.estimatePasswordStrength(safePass))
|
||||||
.thenReturn(STRONG);
|
.thenReturn(STRONG);
|
||||||
|
|
||||||
String safePass = "really.safe.password";
|
|
||||||
passwordEntry.setText(safePass);
|
passwordEntry.setText(safePass);
|
||||||
passwordConfirmation.setText(safePass);
|
passwordConfirmation.setText(safePass);
|
||||||
// Confirm that the create account button is clickable
|
// Confirm that the create account button is clickable
|
||||||
@@ -63,10 +74,44 @@ public class PasswordFragmentTest {
|
|||||||
createAccountButton.performClick();
|
createAccountButton.performClick();
|
||||||
|
|
||||||
// assert controller has been called properly
|
// assert controller has been called properly
|
||||||
verify(setupController, times(1))
|
verify(setupController, times(1)).setPassword(safePass);
|
||||||
.setPassword(safePass);
|
verify(setupController, times(1)).showDozeOrCreateAccount();
|
||||||
verify(setupController, times(1))
|
}
|
||||||
.showDozeOrCreateAccount();
|
|
||||||
|
@Test
|
||||||
|
public void testStrengthMeterUI() {
|
||||||
|
// Test the meters' progress and color for several values
|
||||||
|
testStrengthMeter("1234567890ab", STRONG, StrengthMeter.GREEN);
|
||||||
|
testStrengthMeter("123456789", QUITE_STRONG, StrengthMeter.LIME);
|
||||||
|
testStrengthMeter("123456", QUITE_WEAK, StrengthMeter.YELLOW);
|
||||||
|
testStrengthMeter("123", WEAK, StrengthMeter.ORANGE);
|
||||||
|
testStrengthMeter("", NONE, StrengthMeter.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testStrengthMeter(String pass, float strength, int color) {
|
||||||
|
passwordEntry.setText(pass);
|
||||||
|
assertEquals(strengthMeter.getProgress(),
|
||||||
|
(int) (strengthMeter.getMax() * strength));
|
||||||
|
assertEquals(color, strengthMeter.getColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPasswordMatchUI() {
|
||||||
|
// Password mismatch
|
||||||
|
passwordEntry.setText("really.safe.password");
|
||||||
|
passwordConfirmation.setText("really.safe.pass");
|
||||||
|
assertEquals(createAccountButton.isEnabled(), false);
|
||||||
|
assertEquals(passwordConfirmationWrapper.getError(),
|
||||||
|
passwordFragment.getString(R.string.passwords_do_not_match));
|
||||||
|
// Button enabled
|
||||||
|
passwordEntry.setText("really.safe.pass");
|
||||||
|
passwordConfirmation.setText("really.safe.pass");
|
||||||
|
// Confirm that the password mismatch error message is not visible
|
||||||
|
assertNotEquals(passwordConfirmationWrapper.getError(),
|
||||||
|
passwordFragment.getString(R.string.passwords_do_not_match));
|
||||||
|
// Passwords match, so button should be enabled
|
||||||
|
assertEquals(createAccountButton.isEnabled(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package org.briarproject.briar.android.login;
|
package org.briarproject.briar.android.login;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.support.design.widget.TextInputLayout;
|
import android.support.design.widget.TextInputLayout;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
@@ -12,7 +9,6 @@ import org.briarproject.bramble.api.identity.AuthorConstants;
|
|||||||
import org.briarproject.briar.BuildConfig;
|
import org.briarproject.briar.BuildConfig;
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
import org.briarproject.briar.android.TestBriarApplication;
|
import org.briarproject.briar.android.TestBriarApplication;
|
||||||
import org.briarproject.briar.android.controller.handler.ResultHandler;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -23,15 +19,6 @@ import org.robolectric.RobolectricGradleTestRunner;
|
|||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.NONE;
|
|
||||||
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_STRONG;
|
|
||||||
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_WEAK;
|
|
||||||
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.STRONG;
|
|
||||||
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.WEAK;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.timeout;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
@RunWith(RobolectricGradleTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@Config(constants = BuildConfig.class, sdk = 21,
|
@Config(constants = BuildConfig.class, sdk = 21,
|
||||||
@@ -39,26 +26,18 @@ import static org.mockito.Mockito.verify;
|
|||||||
packageName = "org.briarproject.briar")
|
packageName = "org.briarproject.briar")
|
||||||
public class SetupActivityTest {
|
public class SetupActivityTest {
|
||||||
|
|
||||||
private static final int TIMEOUT_MS = 10 * 1000;
|
private SetupActivity setupActivity;
|
||||||
|
|
||||||
private TestSetupActivity setupActivity;
|
|
||||||
private TextInputLayout nicknameEntryWrapper;
|
private TextInputLayout nicknameEntryWrapper;
|
||||||
private TextInputLayout passwordConfirmationWrapper;
|
|
||||||
private EditText nicknameEntry;
|
private EditText nicknameEntry;
|
||||||
private EditText passwordEntry;
|
|
||||||
private EditText passwordConfirmation;
|
|
||||||
private StrengthMeter strengthMeter;
|
|
||||||
private Button createAccountButton;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
setupActivity = Robolectric.setupActivity(TestSetupActivity.class);
|
setupActivity = Robolectric.setupActivity(SetupActivity.class);
|
||||||
nicknameEntryWrapper = (TextInputLayout) setupActivity
|
nicknameEntryWrapper = (TextInputLayout) setupActivity
|
||||||
.findViewById(R.id.nickname_entry_wrapper);
|
.findViewById(R.id.nickname_entry_wrapper);
|
||||||
nicknameEntry =
|
nicknameEntry =
|
||||||
(EditText) setupActivity.findViewById(R.id.nickname_entry);
|
(EditText) setupActivity.findViewById(R.id.nickname_entry);
|
||||||
createAccountButton = (Button) setupActivity.findViewById(R.id.next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -72,92 +51,4 @@ public class SetupActivityTest {
|
|||||||
assertEquals(nicknameEntryWrapper.getError(),
|
assertEquals(nicknameEntryWrapper.getError(),
|
||||||
setupActivity.getString(R.string.name_too_long));
|
setupActivity.getString(R.string.name_too_long));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPasswordMatchUI() {
|
|
||||||
proceedToPasswordFragment();
|
|
||||||
// Password mismatch
|
|
||||||
passwordEntry.setText("really.safe.password");
|
|
||||||
passwordConfirmation.setText("really.safe.pass");
|
|
||||||
assertEquals(createAccountButton.isEnabled(), false);
|
|
||||||
assertEquals(passwordConfirmationWrapper.getError(),
|
|
||||||
setupActivity.getString(R.string.passwords_do_not_match));
|
|
||||||
// Button enabled
|
|
||||||
passwordEntry.setText("really.safe.pass");
|
|
||||||
passwordConfirmation.setText("really.safe.pass");
|
|
||||||
// Confirm that the password mismatch error message is not visible
|
|
||||||
Assert.assertNotEquals(passwordConfirmationWrapper.getError(),
|
|
||||||
setupActivity.getString(R.string.passwords_do_not_match));
|
|
||||||
// Passwords match, so button should be enabled
|
|
||||||
assertEquals(createAccountButton.isEnabled(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAccountCreation() {
|
|
||||||
SetupController controller = setupActivity.getController();
|
|
||||||
controller.setAuthorName("nick");
|
|
||||||
controller.setPassword("password");
|
|
||||||
// mock a resulthandler
|
|
||||||
ResultHandler<Void> resultHandler = mock(ResultHandler.class);
|
|
||||||
controller.createAccount(resultHandler);
|
|
||||||
verify(resultHandler, timeout(TIMEOUT_MS).times(1)).onResult(null);
|
|
||||||
SharedPreferences prefs =
|
|
||||||
setupActivity.getSharedPreferences("db", Context.MODE_PRIVATE);
|
|
||||||
// Confirm database key
|
|
||||||
assertTrue(prefs.contains("key"));
|
|
||||||
// Note that Robolectric uses its own persistent storage that it
|
|
||||||
// wipes clean after each test run, no need to clean up manually.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStrengthMeter() {
|
|
||||||
SetupController controller = setupActivity.getController();
|
|
||||||
|
|
||||||
String strongPass = "very.strong.password.123";
|
|
||||||
String weakPass = "we";
|
|
||||||
String quiteStrongPass = "quite.strong";
|
|
||||||
|
|
||||||
float val = controller.estimatePasswordStrength(strongPass);
|
|
||||||
assertTrue(val == STRONG);
|
|
||||||
val = controller.estimatePasswordStrength(weakPass);
|
|
||||||
assertTrue(val < WEAK && val > NONE);
|
|
||||||
val = controller.estimatePasswordStrength(quiteStrongPass);
|
|
||||||
assertTrue(val < STRONG && val > QUITE_WEAK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStrengthMeterUI() {
|
|
||||||
proceedToPasswordFragment();
|
|
||||||
// Test the meters progress and color for several values
|
|
||||||
testStrengthMeter("1234567890ab", STRONG, StrengthMeter.GREEN);
|
|
||||||
testStrengthMeter("123456789", QUITE_STRONG, StrengthMeter.LIME);
|
|
||||||
testStrengthMeter("123456", QUITE_WEAK, StrengthMeter.YELLOW);
|
|
||||||
testStrengthMeter("123", WEAK, StrengthMeter.ORANGE);
|
|
||||||
testStrengthMeter("", NONE, StrengthMeter.RED);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void proceedToPasswordFragment() {
|
|
||||||
// proceed to password fragment
|
|
||||||
nicknameEntry.setText("nick");
|
|
||||||
createAccountButton.performClick();
|
|
||||||
|
|
||||||
// find UI elements in new fragment
|
|
||||||
strengthMeter =
|
|
||||||
(StrengthMeter) setupActivity.findViewById(R.id.strength_meter);
|
|
||||||
passwordConfirmationWrapper = (TextInputLayout) setupActivity
|
|
||||||
.findViewById(R.id.password_confirm_wrapper);
|
|
||||||
passwordEntry =
|
|
||||||
(EditText) setupActivity.findViewById(R.id.password_entry);
|
|
||||||
passwordConfirmation =
|
|
||||||
(EditText) setupActivity.findViewById(R.id.password_confirm);
|
|
||||||
createAccountButton = (Button) setupActivity.findViewById(R.id.next);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void testStrengthMeter(String pass, float strength, int color) {
|
|
||||||
passwordEntry.setText(pass);
|
|
||||||
assertEquals(strengthMeter.getProgress(),
|
|
||||||
(int) (strengthMeter.getMax() * strength));
|
|
||||||
assertEquals(color, strengthMeter.getColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package org.briarproject.briar.android.login;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||||
|
import org.briarproject.bramble.api.crypto.PasswordStrengthEstimator;
|
||||||
|
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||||
|
import org.briarproject.bramble.api.db.DatabaseConfig;
|
||||||
|
import org.briarproject.bramble.test.BrambleMockTestCase;
|
||||||
|
import org.briarproject.bramble.test.ImmediateExecutor;
|
||||||
|
import org.briarproject.briar.android.controller.handler.ResultHandler;
|
||||||
|
import org.jmock.Expectations;
|
||||||
|
import org.jmock.lib.legacy.ClassImposteriser;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||||
|
import static org.briarproject.bramble.test.TestUtils.getSecretKey;
|
||||||
|
import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
||||||
|
|
||||||
|
public class SetupControllerImplTest extends BrambleMockTestCase {
|
||||||
|
|
||||||
|
private final SharedPreferences briarPrefs =
|
||||||
|
context.mock(SharedPreferences.class);
|
||||||
|
private final DatabaseConfig databaseConfig =
|
||||||
|
context.mock(DatabaseConfig.class);
|
||||||
|
private final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||||
|
private final PasswordStrengthEstimator estimator =
|
||||||
|
context.mock(PasswordStrengthEstimator.class);
|
||||||
|
private final SharedPreferences.Editor editor =
|
||||||
|
context.mock(SharedPreferences.Editor.class);
|
||||||
|
private final SetupActivity setupActivity;
|
||||||
|
|
||||||
|
private final Executor cryptoExecutor = new ImmediateExecutor();
|
||||||
|
|
||||||
|
private final String authorName = getRandomString(MAX_AUTHOR_NAME_LENGTH);
|
||||||
|
private final String password = "some.strong.pass";
|
||||||
|
private final String encryptedHex = "010203";
|
||||||
|
private final byte[] encryptedBytes = new byte[] {1, 2, 3};
|
||||||
|
private final SecretKey key = getSecretKey();
|
||||||
|
|
||||||
|
public SetupControllerImplTest() {
|
||||||
|
context.setImposteriser(ClassImposteriser.INSTANCE);
|
||||||
|
setupActivity = context.mock(SetupActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateAccount() {
|
||||||
|
context.checking(new Expectations() {{
|
||||||
|
// Setting the author name shows the password fragment
|
||||||
|
oneOf(setupActivity).showPasswordFragment();
|
||||||
|
// Generate a database key
|
||||||
|
oneOf(crypto).generateSecretKey();
|
||||||
|
will(returnValue(key));
|
||||||
|
// Attach the author name and database key to the database config
|
||||||
|
oneOf(databaseConfig).setLocalAuthorName(authorName);
|
||||||
|
oneOf(databaseConfig).setEncryptionKey(key);
|
||||||
|
// Encrypt the key with the password
|
||||||
|
oneOf(crypto).encryptWithPassword(key.getBytes(), password);
|
||||||
|
will(returnValue(encryptedBytes));
|
||||||
|
// Store the encrypted key
|
||||||
|
oneOf(briarPrefs).edit();
|
||||||
|
will(returnValue(editor));
|
||||||
|
oneOf(editor).putString("key", encryptedHex);
|
||||||
|
oneOf(editor).apply();
|
||||||
|
}});
|
||||||
|
|
||||||
|
SetupControllerImpl s = new SetupControllerImpl(briarPrefs,
|
||||||
|
databaseConfig, cryptoExecutor, crypto, estimator);
|
||||||
|
s.setSetupActivity(setupActivity);
|
||||||
|
|
||||||
|
final AtomicBoolean called = new AtomicBoolean(false);
|
||||||
|
s.setAuthorName(authorName);
|
||||||
|
s.setPassword(password);
|
||||||
|
s.createAccount(new ResultHandler<Void>() {
|
||||||
|
@Override
|
||||||
|
public void onResult(Void result) {
|
||||||
|
called.set(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assertTrue(called.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,11 @@
|
|||||||
package org.briarproject.briar.android.login;
|
package org.briarproject.briar.android.login;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class exposes the PasswordController and SetupController and offers the
|
* This class exposes the PasswordController and offers the possibility to
|
||||||
* possibility to override them.
|
* replace it.
|
||||||
*/
|
*/
|
||||||
public class TestChangePasswordActivity extends ChangePasswordActivity {
|
public class TestChangePasswordActivity extends ChangePasswordActivity {
|
||||||
|
|
||||||
public PasswordController getPasswordController() {
|
|
||||||
return passwordController;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPasswordController(PasswordController passwordController) {
|
public void setPasswordController(PasswordController passwordController) {
|
||||||
this.passwordController = passwordController;
|
this.passwordController = passwordController;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
package org.briarproject.briar.android.login;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class exposes the SetupController and offers the possibility to
|
|
||||||
* override it.
|
|
||||||
*/
|
|
||||||
public class TestSetupActivity extends SetupActivity {
|
|
||||||
|
|
||||||
SetupController getController() {
|
|
||||||
return setupController;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user