Avoid touching internals in Tight auth tests

We should test using only external manipulation so we don't assume a
specific implementation.
This commit is contained in:
Pierre Ossman 2023-05-16 12:30:36 +02:00
parent c7c293279b
commit 29a50620ff
1 changed files with 6 additions and 3 deletions

View File

@ -1523,14 +1523,16 @@ describe('Remote Frame Buffer Protocol Client', function () {
}); });
it('should accept the "no auth" auth type and transition to SecurityResult', function () { it('should accept the "no auth" auth type and transition to SecurityResult', function () {
client._rfbTightVNC = true; sendNumStrPairs([[0, 'TGHT', 'NOTUNNEL']], client);
client._sock._websocket._getSentData(); // skip the tunnel choice here
sendNumStrPairs([[1, 'STDV', 'NOAUTH__']], client); sendNumStrPairs([[1, 'STDV', 'NOAUTH__']], client);
expect(client._sock).to.have.sent(new Uint8Array([0, 0, 0, 1])); expect(client._sock).to.have.sent(new Uint8Array([0, 0, 0, 1]));
expect(client._rfbInitState).to.equal('SecurityResult'); expect(client._rfbInitState).to.equal('SecurityResult');
}); });
it('should accept VNC authentication and transition to that', function () { it('should accept VNC authentication and transition to that', function () {
client._rfbTightVNC = true; sendNumStrPairs([[0, 'TGHT', 'NOTUNNEL']], client);
client._sock._websocket._getSentData(); // skip the tunnel choice here
sinon.spy(client, "_negotiateStdVNCAuth"); sinon.spy(client, "_negotiateStdVNCAuth");
sendNumStrPairs([[2, 'STDV', 'VNCAUTH__']], client); sendNumStrPairs([[2, 'STDV', 'VNCAUTH__']], client);
expect(client._sock).to.have.sent(new Uint8Array([0, 0, 0, 2])); expect(client._sock).to.have.sent(new Uint8Array([0, 0, 0, 2]));
@ -1540,7 +1542,8 @@ describe('Remote Frame Buffer Protocol Client', function () {
it('should fail if there are no supported auth types', function () { it('should fail if there are no supported auth types', function () {
sinon.spy(client, "_fail"); sinon.spy(client, "_fail");
client._rfbTightVNC = true; sendNumStrPairs([[0, 'TGHT', 'NOTUNNEL']], client);
client._sock._websocket._getSentData(); // skip the tunnel choice here
sendNumStrPairs([[23, 'stdv', 'badval__']], client); sendNumStrPairs([[23, 'stdv', 'badval__']], client);
expect(client._fail).to.have.been.calledOnce; expect(client._fail).to.have.been.calledOnce;
}); });