From 0ee0e96f34a3fa383e855b1f0b0e0b4b630e9311 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 16 May 2023 19:23:25 +0200 Subject: [PATCH] Fix ARD authentication test to send real data Stop bypassing the data handling steps in the test as that means those parts don't get tested. --- tests/test.rfb.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/test.rfb.js b/tests/test.rfb.js index f5410eb0..c76ebf19 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -1306,9 +1306,27 @@ describe('Remote Frame Buffer Protocol Client', function () { const serverPublicKey = legacyCrypto.exportKey("raw", serverKey.publicKey); const clientPublicKey = legacyCrypto.exportKey("raw", clientKey.publicKey); - await client._negotiateARDAuthAsync(128, serverPublicKey, clientKey); + let data = []; - client._negotiateARDAuth(); + data = data.concat(Array.from(generator)); + push16(data, prime.length); + data = data.concat(Array.from(prime)); + data = data.concat(Array.from(serverPublicKey)); + + client._sock._websocket._receiveData(new Uint8Array(data)); + + // FIXME: We don't have a good way to know when the + // async stuff is done, so we hook in to this + // internal function that is called at the + // end + await new Promise((resolve, reject) => { + sinon.stub(client, "_resumeAuthentication") + .callsFake(() => { + RFB.prototype._resumeAuthentication.call(client); + resolve(); + }); + }); + clock.tick(); expect(client._rfbInitState).to.equal('SecurityResult');