AutofillOriginReleaseTest.kt

1.1 KB · raw

1package com.peachpasswords.autofill23import org.junit.Assert.assertFalse4import org.junit.Assert.assertNull5import org.junit.Assert.assertTrue6import org.junit.Test78class AutofillOriginReleaseTest {910    @Test11    fun unverifiedWebClaimCannotReturnCredentialsOrSaveThem() {12        val denied = applyWebOriginVerification(13            ParsedStructure(14                webDomain = "github.com",15                packageName = "com.attacker.spoof",16                passwordValue = "captured-password",17            ),18            verifiedBrowser = false,19        )2021        assertFalse(denied.credentialReleaseAllowed)22        assertNull(autofillSaveDraft(denied))23    }2425    @Test26    fun verifiedBrowserRetainsWebAutofill() {27        val allowed = applyWebOriginVerification(28            ParsedStructure(webDomain = "login.github.com", packageName = "com.android.chrome"),29            verifiedBrowser = true,30        )3132        assertTrue(allowed.credentialReleaseAllowed)33    }3435    @Test36    fun nativeAppRetainsAutofillWithoutWebClaim() {37        val native = ParsedStructure(packageName = "com.example.app")3839        assertTrue(native.credentialReleaseAllowed)40    }41}