Skip to content

[Backend] — Test: EventsGateway unauthenticated connections do not join user-specific rooms #1153

Description

@Olowodarey

Background

EventsGateway.handleConnection joins authenticated clients to user:<sub>
rooms. Unauthenticated connections (no token or invalid token) should not be
added to any user room. There are no tests confirming this behavior.

Goal

Add tests in src/websocket/events.gateway.spec.ts.

Requirements

  1. No token: connect a socket without auth.token; assert socket.join
    is NOT called with any user:* room.

  2. Invalid token: connect with auth.token = "invalid.jwt.token"; assert
    socket.join not called with user room (JWT verify throws and is caught).

  3. Valid token: connect with a valid JWT; assert socket.join is called

Acceptance criteria

  • User rooms only joined by authenticated sockets.
  • Invalid/missing tokens handled gracefully without crashing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions