1package com.peachpasswords.ui.lock23import com.peachpasswords.ui.security.scorePassword4import org.junit.Assert.assertEquals5import org.junit.Assert.assertNull6import org.junit.Assert.assertTrue7import org.junit.Test8910111213class LockScreenTest {1415 @Test fun min_password_length_is_twelve() = assertEquals(12, MIN_PASSWORD_LENGTH)16 @Test fun min_create_strength_is_two() = assertEquals(2, MIN_CREATE_STRENGTH)1718 @Test fun password_below_minimum_length_is_rejected() {19 val err = createValidationError("short", "short", score = 4)20 assertEquals("password must be at least 12 characters", err)21 }2223 @Test fun weak_password_is_rejected_even_when_long() {24 25 val pw = "aaaaaaaaaaaaaaaa"26 assertTrue("sanity: this password really is weak", scorePassword(pw) < MIN_CREATE_STRENGTH)27 assertEquals("Password too weak — try a longer or more varied password",28 createValidationError(pw, pw, scorePassword(pw)))29 }3031 @Test fun mismatched_confirmation_is_rejected() {32 33 val err = createValidationError("Str0ng-Passphrase!23", "Str0ng-Passphrase!99", score = 4)34 assertEquals("passwords do not match", err)35 }3637 @Test fun create_submit_is_blocked_until_confirmation_matches() {38 assertTrue(!canSubmitCreateVault("Str0ng-Passphrase!23", "", score = 4))39 assertTrue(!canSubmitCreateVault("Str0ng-Passphrase!23", "Str0ng-Passphrase!99", score = 4))40 assertTrue(canSubmitCreateVault("Str0ng-Passphrase!23", "Str0ng-Passphrase!23", score = 4))41 }4243 @Test fun valid_create_returns_no_error() {44 assertNull(createValidationError("Str0ng-Passphrase!23", "Str0ng-Passphrase!23", score = 4))45 }4647 @Test fun length_is_checked_before_strength() {48 49 assertEquals("password must be at least 12 characters",50 createValidationError("ab1", "ab1", score = 0))51 }5253 @Test fun strength_is_checked_before_match() {54 55 assertEquals("Password too weak — try a longer or more varied password",56 createValidationError("aaaaaaaaaaaaaaaa", "different-confirm", score = 1))57 }58}