PasskeyUvFailClosedTest.kt

1.3 KB · raw

1package com.peachpasswords.passkeys23import org.junit.Assert.assertFalse4import org.junit.Assert.assertTrue5import org.junit.Test67/**8 * H-07: WebAuthn user-verification fail-closed decision. If the relying party9 * requires UV and the authenticator cannot verify the user, the assertion must10 * NOT be signed. Tests the pure decision function extracted from the activity.11 */12class PasskeyUvFailClosedTest {1314    @Test fun required_and_verified_signs() {15        assertTrue(16            "UV required + user verified => sign the assertion",17            shouldSignAssertion(uvRequired = true, userVerified = true),18        )19    }2021    @Test fun required_and_unverified_does_not_sign() {22        assertFalse(23            "UV required + user NOT verified => do NOT sign",24            shouldSignAssertion(uvRequired = true, userVerified = false),25        )26    }2728    @Test fun not_required_and_verified_signs() {29        assertTrue(30            "UV not required + user verified => sign (UV=1 reflects ceremony)",31            shouldSignAssertion(uvRequired = false, userVerified = true),32        )33    }3435    @Test fun not_required_and_unverified_signs() {36        assertTrue(37            "UV not required + user NOT verified => sign (UV=0 reflects ceremony)",38            shouldSignAssertion(uvRequired = false, userVerified = false),39        )40    }41}