Выпуск WDTT Plus v4
This commit is contained in:
1 parent
cba54802d0
commit
87e9892cab
16 files changed
+485
-87
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package com.wdtt.plus
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class LogSeverityTest {
|
||||
@Test
|
||||
fun repeatedTurnWorkerFailures_useOneRecoverableWarningKey() {
|
||||
val first = classifyRecoverableWorkerRetry(
|
||||
"[ВОРКЕР #1] Ошибка (попытка 1): TURN Allocate: all retransmissions failed for first",
|
||||
activeWorkerCount = 3
|
||||
)
|
||||
val second = classifyRecoverableWorkerRetry(
|
||||
"[ВОРКЕР #5] Ошибка (попытка 1): TURN Allocate: all retransmissions failed for second",
|
||||
activeWorkerCount = 3
|
||||
)
|
||||
|
||||
assertEquals("worker_turn_allocate_retry", first?.first)
|
||||
assertEquals(first?.first, second?.first)
|
||||
assertEquals(
|
||||
"[TURN] Отдельные каналы не получили ответ на Allocate; выполняются повторы; активных=3",
|
||||
first?.second
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun fatalWorkerFailure_isNotDowngradedToWarning() {
|
||||
val result = classifyRecoverableWorkerRetry(
|
||||
"[ВОРКЕР #1] Ошибка (попытка 1): FATAL_AUTH неверный пароль"
|
||||
)
|
||||
|
||||
assertNull(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun warningDoesNotCountAsUnreadError() {
|
||||
val warning = LogEntry("warning", "Повторяем", severity = LogSeverity.Warning)
|
||||
|
||||
assertFalse(warning.isError)
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,81 @@ class TransferCodecTest {
|
||||
assertTrue(WdttDeepLink.validate(link).canStartVpn)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun modernConnectionLink_preservesFourVkHashesAndTheirOrder() {
|
||||
val hashes = listOf(
|
||||
"3XariaxnHDP9eTiWVFukTMO6ZjCw7c0QQS_J3gYiiaM",
|
||||
"8b6EGN4gYNV5IoCO8tsnKuj49od-GxNhotdbBqjPlaU",
|
||||
"OnEpu4S_nWEKy9wN_ehrMn-8tCfKaL7iiJEe4N50ggg",
|
||||
"pjCFYpjm_ibjy3YTyVZoEWZv3Oai4-QxAWcD2hWexLE"
|
||||
)
|
||||
val original = WdttLinkParts(
|
||||
host = "vpn.example.org",
|
||||
dtlsPort = 56000,
|
||||
wgPort = 56001,
|
||||
localPort = 9000,
|
||||
password = "ABCDEFGHJKLMNPQR",
|
||||
hashes = hashes.joinToString(",")
|
||||
)
|
||||
|
||||
val link = WdttTransferCodec.buildConnectionLink(original)
|
||||
val parsed = WdttDeepLink.validate(link).parts
|
||||
|
||||
assertEquals(hashes, parsed?.hashes?.split(","))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun modernConnectionLink_acceptsVkJoinLinksAsHashInputs() {
|
||||
val first = "3XariaxnHDP9eTiWVFukTMO6ZjCw7c0QQS_J3gYiiaM"
|
||||
val second = "8b6EGN4gYNV5IoCO8tsnKuj49od-GxNhotdbBqjPlaU"
|
||||
val link = WdttTransferCodec.buildConnectionLink(
|
||||
WdttLinkParts(
|
||||
host = "vpn.example.org",
|
||||
dtlsPort = 56000,
|
||||
wgPort = 56001,
|
||||
localPort = 9000,
|
||||
password = "ABCDEFGHJKLMNPQR",
|
||||
hashes = "https://vk.com/call/join/$first?from=share,https://vk.ru/call/join/$second"
|
||||
)
|
||||
)
|
||||
|
||||
assertEquals("$first,$second", WdttDeepLink.validate(link).parts?.hashes)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun modernConnectionLink_carriesCustomProfileName() {
|
||||
val original = WdttLinkParts(
|
||||
host = "vpn.example.org",
|
||||
dtlsPort = 56000,
|
||||
wgPort = 56001,
|
||||
localPort = 9000,
|
||||
password = "ABCDEFGHJKLMNPQR",
|
||||
hashes = "1234567890abcdef",
|
||||
profileName = "Домашний VPN"
|
||||
)
|
||||
|
||||
val link = WdttTransferCodec.buildConnectionLink(original)
|
||||
|
||||
assertTrue(link.contains("name=%D0%94"))
|
||||
assertEquals(original, WdttDeepLink.parse(link))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun modernConnectionLink_omitsEmptyProfileName() {
|
||||
val link = WdttTransferCodec.buildConnectionLink(
|
||||
WdttLinkParts(
|
||||
host = "vpn.example.org",
|
||||
dtlsPort = 56000,
|
||||
wgPort = 56001,
|
||||
localPort = 9000,
|
||||
password = "ABCDEFGHJKLMNPQR",
|
||||
hashes = "1234567890abcdef"
|
||||
)
|
||||
)
|
||||
|
||||
assertFalse(link.contains("&name="))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun legacyConnectionLink_remainsSupported() {
|
||||
val validation = WdttDeepLink.validate(
|
||||
@@ -34,6 +109,29 @@ class TransferCodecTest {
|
||||
|
||||
assertTrue(validation.canStartVpn)
|
||||
assertEquals("vpn.example.org", validation.parts?.host)
|
||||
assertEquals("", validation.parts?.profileName)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onlyRenamedProfileIsPreparedForTransfer() {
|
||||
assertEquals("", vpnProfileTransferName(0, listOf("", "", "")))
|
||||
assertEquals("", vpnProfileTransferName(1, listOf("", "VPN 2", "")))
|
||||
assertEquals("Работа", vpnProfileTransferName(2, listOf("", "", "Работа")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun serverClientLink_carriesSourceVpnProfileName() {
|
||||
val link = buildServerConnectionLink(
|
||||
password = "ABCDEFGHJKLMNPQR",
|
||||
hashes = "1234567890abcdef",
|
||||
ports = "56000,56001,9000",
|
||||
fallbackHost = "vpn.example.org",
|
||||
publicHost = "",
|
||||
profileName = "Мой сервер"
|
||||
)
|
||||
|
||||
assertNotNull(link)
|
||||
assertEquals("Мой сервер", WdttDeepLink.parse(link.orEmpty())?.profileName)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.wdtt.plus
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Test
|
||||
|
||||
class TunnelStopReasonTest {
|
||||
@Test
|
||||
fun stoppedSession_preservesTrafficAndAddsReason() {
|
||||
val result = buildStoppedSessionStats(
|
||||
"Активных: 4 | ↓12.34 МБ / ↑5.67 МБ",
|
||||
TunnelStopReason.NetworkRecoveryFailed
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
"VPN отключён · Причина: связь не восстановилась после ошибки сети · " +
|
||||
"Активных: 0 · ↓12.34 МБ / ↑5.67 МБ",
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun stoppedSession_withoutReceivedStatsDoesNotInventTraffic() {
|
||||
val result = buildStoppedSessionStats("Ожидание данных...", TunnelStopReason.User)
|
||||
|
||||
assertEquals("VPN отключён · Причина: отключено пользователем · Активных: 0", result)
|
||||
assertFalse(result.contains("↓"))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user