App 2.4.2: pairing dialog shows errors instead of closing
- On a failure the pairing dialog stays open and shows the reason in red (Cancel becomes Close); before, it closed at once and the reason was only in the Server tab's status line. - "Pairing is not enabled" only when the server says so. Any other 404 (a server older than 2.1.0, or a proxy's page) is reported as a server without pairing. - Pairing and Test connection name the problem: a server name that does not resolve (Test connection used to say "No internet connection"), a server that does not answer, or the HTTP status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLJfZQZeAKAwSqViTmLzki
This commit is contained in:
@@ -27,6 +27,7 @@ public class PairingClientTest {
|
||||
private String url;
|
||||
private final Deque<Integer> pollStatuses = new ArrayDeque<>();
|
||||
private volatile int startStatus = 201;
|
||||
private volatile String startErrorBody = "{\"error\":\"pairing is not enabled\"}";
|
||||
private volatile String lastStartBody;
|
||||
|
||||
@Before
|
||||
@@ -73,7 +74,7 @@ public class PairingClientTest {
|
||||
response = status == 201
|
||||
? "{\"deviceCode\":\"dev-code\",\"userCode\":\"K7F-3QX\",\"verificationUri\":\"https://car.example.com/pair\","
|
||||
+ "\"verificationUriComplete\":\"https://car.example.com/pair?code=K7F-3QX\",\"expiresIn\":600,\"interval\":5}"
|
||||
: "{\"error\":\"pairing is not enabled\"}";
|
||||
: startErrorBody;
|
||||
} else {
|
||||
Integer next;
|
||||
synchronized (pollStatuses) { next = pollStatuses.poll(); }
|
||||
@@ -119,6 +120,19 @@ public class PairingClientTest {
|
||||
assertEquals(PairingClient.Outcome.EXPIRED, PairingClient.poll(url, "dev-code").outcome);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aServerWithoutPairingIsNotMistakenForPairingSwitchedOff() throws Exception {
|
||||
// e.g. server 2.0.0, or a proxy's own 404 page
|
||||
startStatus = 404;
|
||||
startErrorBody = "404 page not found";
|
||||
try {
|
||||
PairingClient.start(url, "6f1a2b3c-4d5e-4f60-8a9b-0c1d2e3f4a5b");
|
||||
fail("expected HttpStatusException");
|
||||
} catch (PairingClient.HttpStatusException expected) {
|
||||
assertEquals(404, expected.status);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pairingSwitchedOffOnTheServerIsReportedAsSuch() throws Exception {
|
||||
startStatus = 404;
|
||||
|
||||
Reference in New Issue
Block a user