Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brunotot committed Oct 1, 2024
1 parent 1bc8277 commit 55cb293
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string[]> = {
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<string[]> {
return await Promise.resolve(AuthorizationRepositoryMock.roles[userId] ?? []);
}

async findUserByUsername(username: string): Promise<ApiKeycloakUser | null> {
return await Promise.resolve(
AuthorizationRepositoryMock.users.find(user => user.username === username) ?? null,
Expand Down

0 comments on commit 55cb293

Please sign in to comment.