Unit tests

This commit is contained in:
Bastian Wagner
2026-03-09 10:54:50 +01:00
parent ac2117b64b
commit b3fd7fbf03
4 changed files with 58 additions and 19 deletions

View File

@@ -2,17 +2,13 @@ import { Controller, Get, Param, Query, Req, Sse, UnauthorizedException, UseGuar
import { AuthenticatedRequest } from 'src/model/interface/authenticated-request.interface';
import { SseTicketService } from './sse-ticket.service';
import { AuthGuard } from 'src/core/guards/auth.guard';
import { Observable, interval, map } from 'rxjs';
import { KeyService } from 'src/modules/key/key.service';
import { AuthService } from 'src/modules/auth/auth.service';
import { User } from 'src/model/entitites';
import { UserService } from 'src/modules/user/user.service';
import { Observable } from 'rxjs';
import { SseService } from './sse.service';
@Controller('sse')
export class SseController {
constructor(private ticketService: SseTicketService, private sseService: SseService, private userService: UserService) {}
constructor(private ticketService: SseTicketService, private sseService: SseService) {}
@UseGuards(AuthGuard)
@Get('ticket')
@@ -24,15 +20,9 @@ export class SseController {
async sse(@Query('ticket') ticket: string): Promise<Observable<any>> {
const userId = this.ticketService.getUserIdToTicket(ticket);
if (!userId) throw new UnauthorizedException('Invalid/expired ticket');
const user = await this.getUserToId(userId);
if (!userId) throw new UnauthorizedException('Invalid/expired ticket');
return this.sseService.register(userId);
}
private async getUserToId(userId: string): Promise<User> {
const user = await this.userService.getUserById(userId);
return Promise.resolve(user);
}
}