Compare commits

..

No commits in common. "ad8441f72f21c22670a2cabd5dfe49c45d3ee53b" and "f6e7fb3a41fa568ac95867f8bb3f77c64840fb51" have entirely different histories.

3 changed files with 5 additions and 20 deletions

3
.gitignore vendored
View File

@ -134,6 +134,3 @@ dist
*.env
test-results.xml
DS_STORE
**/DS_Store

View File

@ -1,7 +1,5 @@
# FarmControl WebSocket Service
[![Build Status](https://ci.tombutcher.work/buildStatus/icon?job=farmcontrol%2Ffarmcontrol-ws%2Fmain&style=flat-square)](https://ci.tombutcher.work/job/farmcontrol/job/farmcontrol-ws/job/main/)
A WebSocket microservice for FarmControl that handles real-time communication and distributed locking.
## Features

View File

@ -100,15 +100,9 @@ describe('SocketUser', () => {
it('should initialize correctly and setup event handlers', () => {
expect(mockSocket.use).toHaveBeenCalled();
expect(mockSocket.on).toHaveBeenCalledWith(
'authenticate',
expect.any(Function)
);
expect(mockSocket.on).toHaveBeenCalledWith('authenticate', expect.any(Function));
expect(mockSocket.on).toHaveBeenCalledWith('lock', expect.any(Function));
expect(mockSocket.on).toHaveBeenCalledWith(
'disconnect',
expect.any(Function)
);
expect(mockSocket.on).toHaveBeenCalledWith('disconnect', expect.any(Function));
});
describe('handleAuthenticateEvent', () => {
@ -117,16 +111,11 @@ describe('SocketUser', () => {
const callback = jest.fn();
const mockUser = { _id: 'user-id-obj', username: 'testuser' };
socketUser.keycloakAuth.verifyToken.mockResolvedValue({
valid: true,
user: mockUser
});
socketUser.keycloakAuth.verifyToken.mockResolvedValue({ valid: true, user: mockUser });
await socketUser.handleAuthenticateEvent(data, callback);
expect(socketUser.keycloakAuth.verifyToken).toHaveBeenCalledWith(
'valid-token'
);
expect(socketUser.keycloakAuth.verifyToken).toHaveBeenCalledWith('valid-token');
expect(socketUser.authenticated).toBe(true);
expect(socketUser.user).toEqual(mockUser);
expect(socketUser.id).toBe('user-id-obj');
@ -195,3 +184,4 @@ describe('SocketUser', () => {
});
});
});