Выпуск WDTT Plus v17
This commit is contained in:
1 parent
4be5f36c88
commit
abf0a0f130
33 files changed
+763
-262
No files matched your search
@@ -16,6 +16,18 @@ class LogSeverityTest {
|
||||
assertFalse(WRAP_HANDSHAKE_RETRY_MESSAGE.contains("парол", ignoreCase = true))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun wrapHandshakeTerminalMessage_doesNotPresentTimeoutAsBadPassword() {
|
||||
val message = wrapHandshakeTerminalMessage(rtNetwork = false)
|
||||
|
||||
assertEquals(
|
||||
"\uD83D\uDD0C Сервер не ответил на WRAP. Возможны проблемы с сервером или маршрутом, блокировка UDP/TURN, " +
|
||||
"неверный пароль либо несовместимость WRAP. Воркеры остановлены.",
|
||||
message,
|
||||
)
|
||||
assertFalse(message.startsWith("🔒 Неверный пароль"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun repeatedTurnWorkerFailures_useOneRecoverableWarningKey() {
|
||||
val first = classifyRecoverableWorkerRetry(
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.wdtt.plus
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class RemoteProfileUpdatePresentationTest {
|
||||
@Test
|
||||
fun newlyAppliedUpdateHasExplicitConfirmation() {
|
||||
val confirmation = boundProfileUpdateConfirmation(
|
||||
profileLabel = "Чехия",
|
||||
alreadyApplied = false,
|
||||
)
|
||||
|
||||
assertEquals("Профиль обновлён", confirmation.title)
|
||||
assertEquals(
|
||||
"Новые настройки профиля Чехия сохранены. Можно подключаться.",
|
||||
confirmation.message,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun repeatedLinkConfirmsThatCurrentRevisionIsAlreadyStored() {
|
||||
val confirmation = boundProfileUpdateConfirmation(
|
||||
profileLabel = "Чехия",
|
||||
alreadyApplied = true,
|
||||
)
|
||||
|
||||
assertEquals("Профиль уже обновлён", confirmation.title)
|
||||
assertEquals(
|
||||
"Актуальные настройки профиля Чехия уже сохранены на этом устройстве.",
|
||||
confirmation.message,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -156,6 +156,22 @@ class ServerMigrationTest {
|
||||
assertEquals(16, latestServerMigrationLevel(16))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updateFrom16To17RequiresServerMigration() {
|
||||
val result = resolveServerMigrationInitialization(
|
||||
currentVersionCode = 17,
|
||||
isUpdatedInstall = true,
|
||||
storedLastSeenAppVersionCode = 16,
|
||||
storedPendingLevel = 16,
|
||||
storedAcknowledgedLevel = 16,
|
||||
legacyAcknowledgedLevel = 5
|
||||
)
|
||||
|
||||
assertEquals(17, result.pendingLevel)
|
||||
assertEquals(16, result.acknowledgedLevel)
|
||||
assertEquals(17, latestServerMigrationLevel(17))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun reinstallSameVersionDoesNotCreateServerMigrationNotice() {
|
||||
val result = resolveServerMigrationInitialization(
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
package com.wdtt.plus
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class TunnelStartConfigTest {
|
||||
|
||||
@Test
|
||||
fun managedProfileUsesSpareHashesAtMoreThanOneWorkerGroup() {
|
||||
assertTrue(shouldUseManagedHashFallback(profileMaxWorkers = 18, hashCount = 4))
|
||||
assertTrue(shouldUseManagedHashFallback(profileMaxWorkers = 9, hashCount = 2))
|
||||
assertFalse(shouldUseManagedHashFallback(profileMaxWorkers = 0, hashCount = 4))
|
||||
assertFalse(shouldUseManagedHashFallback(profileMaxWorkers = 18, hashCount = 1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `wireguard config is required before workers for every profile`() {
|
||||
assertEquals(true, shouldUseConfigFirstStart())
|
||||
|
||||
@@ -18,6 +18,8 @@ class DeployDataSafetyTest {
|
||||
assertTrue("legacy free-form process arguments remain", "WDTT_ARGS" !in script)
|
||||
assertTrue("preserve mode must keep the whole config tree", "всё содержимое /etc/wdtt сохранено" in script)
|
||||
assertTrue("existing database reset guard is missing", "Найдена существующая база WDTT" in script)
|
||||
assertTrue("deploy mode must be explicit", "WDTT_INSTALL_MODE" in script)
|
||||
assertTrue("fresh install must reject new traces", "после проверки появились следы WDTT" in script)
|
||||
assertTrue("staged server version is not checked before replacement", "staged_version" in script)
|
||||
assertTrue("failed service start does not fail deployment", "Сервис wdtt не прошёл проверку запуска" in script)
|
||||
}
|
||||
@@ -34,10 +36,36 @@ class DeployDataSafetyTest {
|
||||
assertFalse("legacy reset phrase must not clutter the main dialog", "Для сброса введите СБРОСИТЬ" in source)
|
||||
assertTrue(
|
||||
"managed Android reset must prepare rollback",
|
||||
"mode == DeployMode.ResetAll && ownership == DeploymentOwnership.AndroidDeploy" in source
|
||||
"DeploymentOwnership.IncompleteAndroidDeploy" in source &&
|
||||
"prepareServerUpdateRollback(ssh)" in source
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `fresh and preserving deploy modes cannot be confused`() {
|
||||
assertDeploymentMayBeUpdated(DeploymentOwnership.NoInstall, DeployMode.FreshInstall)
|
||||
assertDeploymentMayBeUpdated(DeploymentOwnership.AndroidDeploy, DeployMode.PreserveData)
|
||||
assertDeploymentMayBeUpdated(DeploymentOwnership.LegacyAndroidDeploy, DeployMode.PreserveData)
|
||||
assertDeploymentMayBeUpdated(DeploymentOwnership.IncompleteAndroidDeploy, DeployMode.ResetAll)
|
||||
|
||||
assertFails { assertDeploymentMayBeUpdated(DeploymentOwnership.NoInstall, DeployMode.PreserveData) }
|
||||
assertFails { assertDeploymentMayBeUpdated(DeploymentOwnership.AndroidDeploy, DeployMode.FreshInstall) }
|
||||
assertFails { assertDeploymentMayBeUpdated(DeploymentOwnership.UnknownExisting, DeployMode.FreshInstall) }
|
||||
assertFails { assertDeploymentMayBeUpdated(DeploymentOwnership.StandaloneInstaller, DeployMode.PreserveData) }
|
||||
assertFails { assertDeploymentMayBeUpdated(DeploymentOwnership.LegacyAndroidDeploy, DeployMode.ResetAll) }
|
||||
assertFails { assertDeploymentMayBeUpdated(DeploymentOwnership.IncompleteAndroidDeploy, DeployMode.PreserveData) }
|
||||
}
|
||||
|
||||
private fun assertFails(block: () -> Unit) {
|
||||
var failed = false
|
||||
try {
|
||||
block()
|
||||
} catch (_: IllegalStateException) {
|
||||
failed = true
|
||||
}
|
||||
assertTrue("unsafe deployment mode was accepted", failed)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `dangerous server hold confirms once only after three uninterrupted seconds`() {
|
||||
val start = advanceDangerousServerHold(
|
||||
|
||||
@@ -322,6 +322,7 @@ class OutboundWireGuardTest {
|
||||
assertTrue("WDTT_ANDROID_DEPLOY_MANAGED=1" in script)
|
||||
assertTrue("Managed by WDTT Plus Android deploy" in script)
|
||||
assertTrue("WDTT_LEGACY_ANDROID_DEPLOY_CANDIDATE=1" in script)
|
||||
assertTrue("WDTT_INCOMPLETE_ANDROID_DEPLOY_CANDIDATE=1" in script)
|
||||
assertTrue("WDTT_INSTALL_TRACE=1" in script)
|
||||
assertTrue("-config-dir[[:space:]]+/etc/wdtt" in script)
|
||||
assertTrue("grep -Fq 'wdtt0'" in script)
|
||||
@@ -337,6 +338,7 @@ class OutboundWireGuardTest {
|
||||
assertEquals(1, Regex("(?m)^WDTT_STANDALONE_MANAGED=[01]$").findAll(output).count())
|
||||
assertEquals(1, Regex("(?m)^WDTT_ANDROID_DEPLOY_MANAGED=[01]$").findAll(output).count())
|
||||
assertEquals(1, Regex("(?m)^WDTT_LEGACY_ANDROID_DEPLOY_CANDIDATE=[01]$").findAll(output).count())
|
||||
assertEquals(1, Regex("(?m)^WDTT_INCOMPLETE_ANDROID_DEPLOY_CANDIDATE=[01]$").findAll(output).count())
|
||||
assertEquals(1, Regex("(?m)^WDTT_INSTALL_TRACE=[01]$").findAll(output).count())
|
||||
deploymentOwnershipFromProbe(output)
|
||||
}
|
||||
@@ -382,6 +384,21 @@ class OutboundWireGuardTest {
|
||||
)
|
||||
assertFalse(existingInstallAllowsReset(ownership = legacy, checkSucceeded = true))
|
||||
|
||||
val incomplete = existingInstallOwnershipFromFlags(
|
||||
standaloneManaged = false,
|
||||
androidDeployManaged = false,
|
||||
legacyAndroidDeployCandidate = false,
|
||||
incompleteAndroidDeployCandidate = true
|
||||
)
|
||||
assertFalse(
|
||||
existingInstallAllowsPreservingUpdate(
|
||||
ownership = incomplete,
|
||||
checkSucceeded = true
|
||||
)
|
||||
)
|
||||
assertTrue(existingInstallAllowsReset(ownership = incomplete, checkSucceeded = true))
|
||||
assertFalse(existingInstallAllowsReset(ownership = incomplete, checkSucceeded = false))
|
||||
|
||||
val android = existingInstallOwnershipFromFlags(
|
||||
standaloneManaged = false,
|
||||
androidDeployManaged = true,
|
||||
@@ -430,6 +447,49 @@ class OutboundWireGuardTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun ownershipProbe_allowsOnlyExactInterruptedAndroidFootprintToBeReset() {
|
||||
val root = Files.createTempDirectory("wdtt-incomplete-owner-probe").toFile()
|
||||
try {
|
||||
val config = File(root, "etc/wdtt")
|
||||
config.mkdirs()
|
||||
assertTrue(config.setReadable(false, false))
|
||||
assertTrue(config.setWritable(false, false))
|
||||
assertTrue(config.setExecutable(false, false))
|
||||
assertTrue(config.setReadable(true, true))
|
||||
assertTrue(config.setWritable(true, true))
|
||||
assertTrue(config.setExecutable(true, true))
|
||||
val database = File(config, "passwords.json")
|
||||
database.writeText("{\"passwords\":{},\"devices\":{}}\n")
|
||||
assertTrue(database.setReadable(false, false))
|
||||
assertTrue(database.setWritable(false, false))
|
||||
assertTrue(database.setExecutable(false, false))
|
||||
assertTrue(database.setReadable(true, true))
|
||||
assertTrue(database.setWritable(true, true))
|
||||
|
||||
fun probe(): DeploymentOwnership {
|
||||
val process = ProcessBuilder(
|
||||
"bash",
|
||||
"-c",
|
||||
standaloneInstallerOwnershipProbeScript(root.absolutePath)
|
||||
).redirectErrorStream(true).start()
|
||||
val output = process.inputStream.bufferedReader().use { it.readText() }
|
||||
assertEquals(0, process.waitFor())
|
||||
return deploymentOwnershipFromProbe(output)
|
||||
}
|
||||
|
||||
val incomplete = probe()
|
||||
assertEquals(DeploymentOwnership.IncompleteAndroidDeploy, incomplete)
|
||||
assertFalse(existingInstallAllowsPreservingUpdate(incomplete, checkSucceeded = true))
|
||||
assertTrue(existingInstallAllowsReset(incomplete, checkSucceeded = true))
|
||||
|
||||
File(config, "foreign.conf").writeText("do-not-touch\n")
|
||||
assertEquals(DeploymentOwnership.UnknownExisting, probe())
|
||||
} finally {
|
||||
root.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun deploymentOwnership_allowsOnlyStrictLegacyAndroidShapeForPreserveMigration() {
|
||||
assertEquals(
|
||||
@@ -439,6 +499,7 @@ class OutboundWireGuardTest {
|
||||
WDTT_STANDALONE_MANAGED=0
|
||||
WDTT_ANDROID_DEPLOY_MANAGED=0
|
||||
WDTT_LEGACY_ANDROID_DEPLOY_CANDIDATE=1
|
||||
WDTT_INCOMPLETE_ANDROID_DEPLOY_CANDIDATE=0
|
||||
WDTT_INSTALL_TRACE=1
|
||||
""".trimIndent()
|
||||
)
|
||||
@@ -450,6 +511,7 @@ class OutboundWireGuardTest {
|
||||
WDTT_STANDALONE_MANAGED=0
|
||||
WDTT_ANDROID_DEPLOY_MANAGED=0
|
||||
WDTT_LEGACY_ANDROID_DEPLOY_CANDIDATE=0
|
||||
WDTT_INCOMPLETE_ANDROID_DEPLOY_CANDIDATE=0
|
||||
WDTT_INSTALL_TRACE=1
|
||||
""".trimIndent()
|
||||
)
|
||||
@@ -461,6 +523,7 @@ class OutboundWireGuardTest {
|
||||
WDTT_STANDALONE_MANAGED=0
|
||||
WDTT_ANDROID_DEPLOY_MANAGED=0
|
||||
WDTT_LEGACY_ANDROID_DEPLOY_CANDIDATE=0
|
||||
WDTT_INCOMPLETE_ANDROID_DEPLOY_CANDIDATE=0
|
||||
WDTT_INSTALL_TRACE=0
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user