EntryDetailParityTest.kt

1.7 KB · raw

1package com.peachpasswords.ui.vault23import com.peachpasswords.vault.VaultEntry4import org.junit.Assert.assertEquals5import org.junit.Assert.assertFalse6import org.junit.Assert.assertTrue7import org.junit.Test89class EntryDetailParityTest {10    @Test fun entry_homograph_warning_checks_primary_and_additional_urls() {11        val safe = VaultEntry(12            id = "1",13            title = "Safe",14            url = "https://example.com",15            additionalUrls = listOf("https://accounts.example.com"),16            createdAt = 1,17            modifiedAt = 1,18        )19        val risky = safe.copy(additionalUrls = listOf("https://xn--pple-43d.com"))2021        assertFalse(entryHasHomographWarning(safe))22        assertTrue(entryHasHomographWarning(risky))23    }2425    @Test fun short_credential_preserves_readable_edges() {26        assertEquals("short", shortCredential("short"))27        assertEquals("abcdef...7890", shortCredential("abcdefghijklmnopqrstuvwxyz7890"))28    }2930    @Test fun canary_status_label_handles_count_without_date() {31        assertEquals("0 total alerts", canaryStatusLabel(null, null))32        assertEquals("1 total alert", canaryStatusLabel(null, 1))33    }3435    @Test fun canary_webhook_validation_matches_browser_public_https_rule() {36        assertTrue(isAllowedCanaryWebhookUrl("https://hooks.example.com/peach"))37        assertFalse(isAllowedCanaryWebhookUrl("http://hooks.example.com/peach"))38        assertFalse(isAllowedCanaryWebhookUrl("https://localhost/peach"))39        assertFalse(isAllowedCanaryWebhookUrl("https://127.0.0.1/peach"))40        assertFalse(isAllowedCanaryWebhookUrl("https://192.168.1.50/peach"))41        assertFalse(isAllowedCanaryWebhookUrl("not a url"))42    }43}