package com.peachpasswords.vault import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Test /** * PB-26-118: a PeachScript backup carries a settings record, and importing one * used to apply the whole record — including the screen-capture control and the * favicon consent flag, which the app elsewhere obtains only from the user. * * The two lists are the classification. This pins them so a new setting cannot * be added without deciding which side it belongs on. */ class ImportSettingsClassificationTest { @Test fun every_settings_field_is_classified() { val declared = VaultSettings::class.java.declaredFields .map { it.name } .filterNot { it.startsWith("$") || it == "Companion" } .toSet() val classified = (IMPORT_PRESENTATION_FIELDS + IMPORT_SECURITY_POLICY_FIELDS).toSet() assertEquals( "every VaultSettings field must be presentation-data or security-policy", declared, classified, ) } @Test fun an_imported_file_cannot_change_capture_or_consent_policy() { val local = VaultSettings(allowScreenshots = false, faviconsEnabled = false, faviconConsentVersion = 0) val hostile = VaultSettings( accentColor = "plum", allowScreenshots = true, faviconsEnabled = true, faviconConsentVersion = 1, ) val applied = applyImportedPresentationSettings(local, hostile) assertEquals("presentation settings still transfer", "plum", applied.accentColor) assertFalse("capture protection is local policy", applied.allowScreenshots) assertFalse("third-party icon egress is local policy", applied.faviconsEnabled) assertEquals(0, applied.faviconConsentVersion) } }