mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 13:19:52 +01:00
Add a password strength meter to SetupActivity. Dev task #42.
This commit is contained in:
@@ -97,6 +97,7 @@
|
||||
<test name='org.briarproject.crypto.KeyDerivationTest'/>
|
||||
<test name='org.briarproject.crypto.KeyEncodingAndParsingTest'/>
|
||||
<test name="org.briarproject.crypto.PasswordBasedKdfTest"/>
|
||||
<test name="org.briarproject.crypto.PasswordStrengthEstimatorTest"/>
|
||||
<test name='org.briarproject.crypto.SecretKeyImplTest'/>
|
||||
<test name='org.briarproject.db.BasicH2Test'/>
|
||||
<test name='org.briarproject.db.DatabaseCleanerImplTest'/>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user