package com.cottondb.sitesimport kotlinx.serialization.json.Jsonimport kotlinx.serialization.json.jsonObjectimport org.junit.Assert.assertFalseimport org.junit.Assert.assertTrueimport org.junit.Testimport java.io.File/** ANDROID READY 1: Sites' Privacy page is its own line alone; the move from Comms trusts by certificate, not permission, and waits for a cold Comms' core. */classSitesReadyTest {privateval repo = generateSequence(File("").absoluteFile) { it.parentFile }.first { File(it, "apps/registry.json").isFile }privatefun src(path: String) = File(repo, "apps/android/app/src/$path").readText()privateval words by lazy { Json.parseToJsonElement(File(repo, "crates/cotton-core/kits/shell/lines/sites.json").readText()).jsonObject }/** DECISIONS question 14: no Your Claude in Sites. Privacy says the core's line and nothing of the shell's page. */ @Testfun privacy_is_the_cores_line_alone() { assertTrue(words["you"]!!.jsonObject.containsKey("privacy") && words["you"]!!.jsonObject.containsKey("privacy_line"))val you = src("sites/kotlin/com/cottondb/sites/You.kt")val page = you.substring(you.indexOf("fun SharedPage("), you.indexOf("class RoseSkin("))val own = page.indexOf("if (at == \"privacy\")") assertTrue("Privacy is drawn by Sites before the shell's pages", own in0 until page.indexOf("SettingsHome(")) assertTrue(page.contains("skin.Block(privacy, \"sites-privacy-line\")")) assertTrue(page.substring(own, page.indexOf("SettingsHome(")).contains("return@Box")) }/** * Play signs each app with its own key: a signature permission Comms and Sites both declared refused the second * install (android-permissions.test.ts) and reached no sibling. Each side checks the other by CottonSigners. */ @Testfun the_move_from_comms_trusts_by_certificate() { assertFalse(src("sites/AndroidManifest.xml").replace(Regex("<!--[\\s\\S]*?-->"), "").contains("SITES_MOVE")) assertFalse(src("messages/AndroidManifest.xml").replace(Regex("<!--[\\s\\S]*?-->"), "").contains("SITES_MOVE"))val moving = src("sites/kotlin/com/cottondb/sites/Moving.kt") assertTrue(moving.contains("CottonSigners.of(context).trusts(context, comms.packageName)"))val provider = src("messages/kotlin/com/cottondb/messages/sites/SitesMoveProvider.kt") assertTrue(provider.contains("CottonSigners.of(context).trusts(context, caller)")) assertFalse(provider.contains("checkSignatures")) assertFalse(provider.contains("checkCallingPermission"))// A cold Comms is asked before its onCreate: the provider waits for the core rather than read a lateinit. assertTrue(provider.contains("app.openingCore()")) assertFalse(provider.contains("app.core.await()"))val flavour = File(repo, "apps/android/shell/src/main/kotlin/com/cottondb/shell/Flavour.kt").readText() assertTrue(flavour.contains("while (!::core.isInitialized) delay(20)")) }}