Add a password strength meter to SetupActivity. Dev task #42.

This commit is contained in:
akwizgran
2014-01-09 01:29:00 +00:00
parent 1a53e9e908
commit ea47420e99
8 changed files with 168 additions and 14 deletions

View File

@@ -0,0 +1,29 @@
package org.briarproject.crypto;
import static org.briarproject.api.crypto.PasswordStrengthEstimator.QUITE_STRONG;
import org.briarproject.BriarTestCase;
import org.briarproject.api.crypto.PasswordStrengthEstimator;
import org.junit.Test;
public class PasswordStrengthEstimatorTest extends BriarTestCase {
@Test
public void testWeakPasswords() {
PasswordStrengthEstimator e = new PasswordStrengthEstimatorImpl();
assertTrue(e.estimateStrength("".toCharArray()) < QUITE_STRONG);
assertTrue(e.estimateStrength("password".toCharArray()) < QUITE_STRONG);
assertTrue(e.estimateStrength("letmein".toCharArray()) < QUITE_STRONG);
assertTrue(e.estimateStrength("123456".toCharArray()) < QUITE_STRONG);
}
@Test
public void testStrongPasswords() {
PasswordStrengthEstimator e = new PasswordStrengthEstimatorImpl();
// Industry standard
assertTrue(e.estimateStrength("Tr0ub4dor&3".toCharArray())
> QUITE_STRONG);
assertTrue(e.estimateStrength("correcthorsebatterystaple".toCharArray())
> QUITE_STRONG);
}
}