From 55cb29300c466a02b15fe140550c30c483d71e78 Mon Sep 17 00:00:00 2001 From: Bruno Tot Date: Tue, 1 Oct 2024 22:35:26 +0200 Subject: [PATCH] chore: fix tests --- .../test/__mocks__/AuthorizationRepositoryMock.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/mern-sample-app/app-node-express/test/__mocks__/AuthorizationRepositoryMock.ts b/packages/mern-sample-app/app-node-express/test/__mocks__/AuthorizationRepositoryMock.ts index 02d12b93..9e78307b 100644 --- a/packages/mern-sample-app/app-node-express/test/__mocks__/AuthorizationRepositoryMock.ts +++ b/packages/mern-sample-app/app-node-express/test/__mocks__/AuthorizationRepositoryMock.ts @@ -2,19 +2,26 @@ import type { AuthorizationRepository } from "../../dist/infrastructure/reposito import type { ApiKeycloakUser } from "@org/lib-api-client"; export class AuthorizationRepositoryMock implements AuthorizationRepository { + static roles: Record = { + admin: ["admin", "user"], + user: ["user"], + }; + static users: ApiKeycloakUser[] = [ { id: "1", username: "admin", - realmRoles: ["admin"], }, { id: "2", username: "user", - realmRoles: ["user"], }, ]; + async findRolesByUserId(userId: string): Promise { + return await Promise.resolve(AuthorizationRepositoryMock.roles[userId] ?? []); + } + async findUserByUsername(username: string): Promise { return await Promise.resolve( AuthorizationRepositoryMock.users.find(user => user.username === username) ?? null,