diff --git a/java/client/src/test/java/org/signal/libsignal/net/ChatServiceConnectTests.java b/java/client/src/test/java/org/signal/libsignal/net/ChatServiceConnectTests.java index 6a50832a6..30bf6bdd1 100644 --- a/java/client/src/test/java/org/signal/libsignal/net/ChatServiceConnectTests.java +++ b/java/client/src/test/java/org/signal/libsignal/net/ChatServiceConnectTests.java @@ -23,6 +23,9 @@ import org.signal.libsignal.util.TestLogger; public class ChatServiceConnectTests { private static final String USER_AGENT = "test"; + // A syntactically valid but non-existent ACI username for testing server rejection. + private static final String FAKE_USERNAME = "90c979fd-eab4-4a08-b6da-69dedeab9b29.1"; + private static final String FAKE_PASSWORD = "password"; private static class Listener implements ChatConnectionListener { CompletableFuture disconnectReason = new CompletableFuture<>(); @@ -116,7 +119,8 @@ public class ChatServiceConnectTests { final var e = assertThrows( - ExecutionException.class, () -> net.connectAuthChat("", "", false, listener).get()); + ExecutionException.class, + () -> net.connectAuthChat(FAKE_USERNAME, FAKE_PASSWORD, false, listener).get()); assertTrue(e.getCause() instanceof DeviceDeregisteredException); } @@ -137,7 +141,8 @@ public class ChatServiceConnectTests { // use preconnects. final var e = assertThrows( - ExecutionException.class, () -> net.connectAuthChat("", "", false, listener).get()); + ExecutionException.class, + () -> net.connectAuthChat(FAKE_USERNAME, FAKE_PASSWORD, false, listener).get()); assertTrue(e.getCause() instanceof DeviceDeregisteredException); } diff --git a/node/ts/test/NetTest.ts b/node/ts/test/NetTest.ts index aeb4e8e18..1137bc5f3 100644 --- a/node/ts/test/NetTest.ts +++ b/node/ts/test/NetTest.ts @@ -371,11 +371,17 @@ describe('chat service api', () => { // you can check the log lines for: "[authenticated] using preconnection". // We have to use an authenticated connection because that's the only one that's allowed to // use preconnects. - await net.connectAuthenticatedChat('', '', true, { - onIncomingMessage: sinon.stub(), - onConnectionInterrupted: sinon.stub(), - onQueueEmpty: sinon.stub(), - }); + // Use a syntactically valid but non-existent ACI so the server rejects the credentials. + await net.connectAuthenticatedChat( + '90c979fd-eab4-4a08-b6da-69dedeab9b29.1', + 'password', + true, + { + onIncomingMessage: sinon.stub(), + onConnectionInterrupted: sinon.stub(), + onQueueEmpty: sinon.stub(), + } + ); assert.fail('should not have managed to authenticate'); } catch (e) { assert.instanceOf(e, LibSignalErrorBase); diff --git a/swift/Tests/LibSignalClientTests/ChatServiceTests.swift b/swift/Tests/LibSignalClientTests/ChatServiceTests.swift index 9fad3c2a7..bae9beec4 100644 --- a/swift/Tests/LibSignalClientTests/ChatServiceTests.swift +++ b/swift/Tests/LibSignalClientTests/ChatServiceTests.swift @@ -603,7 +603,12 @@ final class ChatConnectionTests: TestCaseBase { // you can check the log lines for: "[authenticated] using preconnection". // We have to use an authenticated connection because that's the only one that's allowed to // use preconnects. - _ = try await net.connectAuthenticatedChat(username: "", password: "", receiveStories: false) + // Use a syntactically valid but non-existent ACI so the server rejects the credentials. + _ = try await net.connectAuthenticatedChat( + username: "90c979fd-eab4-4a08-b6da-69dedeab9b29.1", + password: "password", + receiveStories: false + ) XCTFail("should not have managed to authenticate") } catch SignalError.deviceDeregistered(_:) { // expected error, okay