enforce dedicated Wi-Fi for direct QR pairing
This commit is contained in:
@@ -10,6 +10,49 @@ import java.util.concurrent.Executors
|
||||
import java.util.zip.CRC32
|
||||
|
||||
class ProtocolTest {
|
||||
@Test
|
||||
fun dedicatedWifiNeverProbesQrOrComputerLanAddresses() {
|
||||
assertEquals(
|
||||
listOf("http://192.168.137.1:39393"),
|
||||
EndpointRouting.afterConnection(
|
||||
dedicatedWifi = true,
|
||||
gatewayEndpoints = listOf("http://192.168.137.1:39393"),
|
||||
routedAdvertisedEndpoints = listOf(
|
||||
"http://192.168.8.162:39393",
|
||||
"http://192.168.49.1:39393",
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun dedicatedWifiRecoveryStillRejectsAdvertisedAndGuessedAddresses() {
|
||||
assertEquals(
|
||||
listOf("http://192.168.137.1:39393"),
|
||||
EndpointRouting.forRecovery(
|
||||
dedicatedWifi = true,
|
||||
discoveredEndpoint = null,
|
||||
gatewayEndpoints = listOf("http://192.168.137.1:39393"),
|
||||
advertisedEndpoints = listOf(
|
||||
"http://192.168.8.162:39393",
|
||||
"http://192.168.49.1:39393",
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun currentLanModeCanUseSameSubnetAdvertisedAddresses() {
|
||||
assertEquals(
|
||||
listOf("http://192.168.8.1:39393", "http://192.168.8.162:39393"),
|
||||
EndpointRouting.afterConnection(
|
||||
dedicatedWifi = false,
|
||||
gatewayEndpoints = listOf("http://192.168.8.1:39393"),
|
||||
routedAdvertisedEndpoints = listOf("http://192.168.8.162:39393"),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun probeCompletionWaitsForARealResultInsteadOfConsumingAnEmptyPoll() {
|
||||
val pool = Executors.newSingleThreadExecutor()
|
||||
@@ -91,6 +134,18 @@ class ProtocolTest {
|
||||
assertEquals(42L, payload.fileSize)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parsesDedicatedWifiPairingWithoutAdvertisedComputerAddresses() {
|
||||
val json = """{"v":2,"s":"abcdefghijklmnopqrstuvwxyz012345","n":"DESKTOP-QFT","p":39393,"e":[],"w":["QFT-DESKTOP-abc123","0123456789abcdef"]}"""
|
||||
val payload = PairingProtocol.parse(
|
||||
PairingProtocol.PREFIX_V2 + Base64Url.encode(json.toByteArray()),
|
||||
)!!
|
||||
|
||||
assertNotNull(payload.wifi)
|
||||
assertEquals("QFT-DESKTOP-abc123", payload.wifi?.ssid)
|
||||
assertTrue(payload.endpoints.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun base45KnownVectors() {
|
||||
assertArrayEquals("AB".toByteArray(), Base45.decode("BB8"))
|
||||
|
||||
Reference in New Issue
Block a user