Split Plain authentication tests to own section

VeNCrypt is a multiplexer for many authentication methods, not just
Plain. So let's split it to its own section, just like other types.
This commit is contained in:
Pierre Ossman 2023-05-16 12:34:26 +02:00
parent 0679c8a801
commit 79f099108f
1 changed files with 14 additions and 20 deletions

View File

@ -1616,23 +1616,29 @@ describe('Remote Frame Buffer Protocol Client', function () {
expect(client._sock).to.have.sent(new Uint8Array(expectedResponse)); expect(client._sock).to.have.sent(new Uint8Array(expectedResponse));
}); });
});
it('should support Plain authentication', function () { describe('Plain Authentication (type 256) Handler', function () {
client.addEventListener("credentialsrequired", () => { beforeEach(function () {
client.sendCredentials({ username: 'username', password: 'password' }); sendSecurity(19, client);
}); expect(client._sock).to.have.sent(new Uint8Array([19]));
// VeNCrypt version // VeNCrypt version
client._sock._websocket._receiveData(new Uint8Array([0, 2])); client._sock._websocket._receiveData(new Uint8Array([0, 2]));
expect(client._sock).to.have.sent(new Uint8Array([0, 2])); expect(client._sock).to.have.sent(new Uint8Array([0, 2]));
// Server ACK. // Server ACK.
client._sock._websocket._receiveData(new Uint8Array([0])); client._sock._websocket._receiveData(new Uint8Array([0]));
// Subtype list. });
it('should support Plain authentication', function () {
client.addEventListener("credentialsrequired", () => {
client.sendCredentials({ username: 'username', password: 'password' });
});
client._sock._websocket._receiveData(new Uint8Array([1, 0, 0, 1, 0])); client._sock._websocket._receiveData(new Uint8Array([1, 0, 0, 1, 0]));
expect(client._sock).to.have.sent(new Uint8Array([0, 0, 1, 0]));
clock.tick(); clock.tick();
const expectedResponse = []; const expectedResponse = [];
push32(expectedResponse, 256); // Chosen subtype.
push32(expectedResponse, client._rfbCredentials.username.length); push32(expectedResponse, client._rfbCredentials.username.length);
push32(expectedResponse, client._rfbCredentials.password.length); push32(expectedResponse, client._rfbCredentials.password.length);
pushString(expectedResponse, client._rfbCredentials.username); pushString(expectedResponse, client._rfbCredentials.username);
@ -1648,18 +1654,12 @@ describe('Remote Frame Buffer Protocol Client', function () {
client.addEventListener("credentialsrequired", () => { client.addEventListener("credentialsrequired", () => {
client.sendCredentials({ username: 'username', password: '' }); client.sendCredentials({ username: 'username', password: '' });
}); });
// VeNCrypt version
client._sock._websocket._receiveData(new Uint8Array([0, 2]));
expect(client._sock).to.have.sent(new Uint8Array([0, 2]));
// Server ACK.
client._sock._websocket._receiveData(new Uint8Array([0]));
// Subtype list.
client._sock._websocket._receiveData(new Uint8Array([1, 0, 0, 1, 0])); client._sock._websocket._receiveData(new Uint8Array([1, 0, 0, 1, 0]));
expect(client._sock).to.have.sent(new Uint8Array([0, 0, 1, 0]));
clock.tick(); clock.tick();
const expectedResponse = []; const expectedResponse = [];
push32(expectedResponse, 256); // Chosen subtype.
push32(expectedResponse, client._rfbCredentials.username.length); push32(expectedResponse, client._rfbCredentials.username.length);
push32(expectedResponse, client._rfbCredentials.password.length); push32(expectedResponse, client._rfbCredentials.password.length);
pushString(expectedResponse, client._rfbCredentials.username); pushString(expectedResponse, client._rfbCredentials.username);
@ -1675,18 +1675,12 @@ describe('Remote Frame Buffer Protocol Client', function () {
client.addEventListener("credentialsrequired", () => { client.addEventListener("credentialsrequired", () => {
client.sendCredentials({ username: 'a'.repeat(300), password: 'b'.repeat(300) }); client.sendCredentials({ username: 'a'.repeat(300), password: 'b'.repeat(300) });
}); });
// VeNCrypt version
client._sock._websocket._receiveData(new Uint8Array([0, 2]));
expect(client._sock).to.have.sent(new Uint8Array([0, 2]));
// Server ACK.
client._sock._websocket._receiveData(new Uint8Array([0]));
// Subtype list.
client._sock._websocket._receiveData(new Uint8Array([1, 0, 0, 1, 0])); client._sock._websocket._receiveData(new Uint8Array([1, 0, 0, 1, 0]));
expect(client._sock).to.have.sent(new Uint8Array([0, 0, 1, 0]));
clock.tick(); clock.tick();
const expectedResponse = []; const expectedResponse = [];
push32(expectedResponse, 256); // Chosen subtype.
push32(expectedResponse, client._rfbCredentials.username.length); push32(expectedResponse, client._rfbCredentials.username.length);
push32(expectedResponse, client._rfbCredentials.password.length); push32(expectedResponse, client._rfbCredentials.password.length);
pushString(expectedResponse, client._rfbCredentials.username); pushString(expectedResponse, client._rfbCredentials.username);