From 71bb6f02cdf993072172eefe138127e66943ca03 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 16 May 2023 15:04:13 +0200 Subject: [PATCH] Fix Plain authentication test checks We should have constants local for the test function when doing comparisons or we might have false positives because we compare with buggy values in the code under test. --- tests/test.rfb.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test.rfb.js b/tests/test.rfb.js index 5bb4001d..f5410eb0 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -1639,10 +1639,10 @@ describe('Remote Frame Buffer Protocol Client', function () { clock.tick(); const expectedResponse = []; - push32(expectedResponse, client._rfbCredentials.username.length); - push32(expectedResponse, client._rfbCredentials.password.length); - pushString(expectedResponse, client._rfbCredentials.username); - pushString(expectedResponse, client._rfbCredentials.password); + push32(expectedResponse, 8); + push32(expectedResponse, 8); + pushString(expectedResponse, 'username'); + pushString(expectedResponse, 'password'); expect(client._sock).to.have.sent(new Uint8Array(expectedResponse)); sinon.spy(client, "_initMsg"); @@ -1660,10 +1660,10 @@ describe('Remote Frame Buffer Protocol Client', function () { clock.tick(); const expectedResponse = []; - push32(expectedResponse, client._rfbCredentials.username.length); - push32(expectedResponse, client._rfbCredentials.password.length); - pushString(expectedResponse, client._rfbCredentials.username); - pushString(expectedResponse, client._rfbCredentials.password); + push32(expectedResponse, 8); + push32(expectedResponse, 0); + pushString(expectedResponse, 'username'); + pushString(expectedResponse, ''); expect(client._sock).to.have.sent(new Uint8Array(expectedResponse)); sinon.spy(client, "_initMsg"); @@ -1681,10 +1681,10 @@ describe('Remote Frame Buffer Protocol Client', function () { clock.tick(); const expectedResponse = []; - push32(expectedResponse, client._rfbCredentials.username.length); - push32(expectedResponse, client._rfbCredentials.password.length); - pushString(expectedResponse, client._rfbCredentials.username); - pushString(expectedResponse, client._rfbCredentials.password); + push32(expectedResponse, 300); + push32(expectedResponse, 300); + pushString(expectedResponse, 'a'.repeat(300)); + pushString(expectedResponse, 'b'.repeat(300)); expect(client._sock).to.have.sent(new Uint8Array(expectedResponse)); sinon.spy(client, "_initMsg");