package com.peachpasswords.passkeys import java.io.File import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test class CredentialProviderContractTest { @Test fun authenticationActionPendingIntentIsMutableForFrameworkRequestAttachment() { val source = source("passkeys/PasskeyUnlockIntent.kt") assertTrue(source.contains("PendingIntent.FLAG_MUTABLE")) assertFalse(source.contains("PendingIntent.FLAG_IMMUTABLE")) } @Test fun selectionPrefersTheFinalFrameworkOrigin() { assertTrue( selectionOrigin("https://github.com", "https://example.com") == "https://github.com", ) } @Test fun selectionRetainsAuthenticatedBeginRequestOriginWhenOemOmitsFinalRequest() { assertTrue( selectionOrigin(null, "https://github.com") == "https://github.com", ) } @Test fun selectionStillFailsClosedWithoutAnyVerifiedOrigin() { assertTrue(selectionOrigin(null, null) == null) assertTrue(selectionOrigin(" ", "") == null) } private fun source(relativePath: String): String = File("src/main/java/com/peachpasswords/$relativePath").readText() }