2
0

first commit

This commit is contained in:
2024-08-09 00:39:27 +02:00
commit 79688abe2e
5698 changed files with 497838 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import { BaseStrategy } from "@/lib/passport/strategies/types";
import { UsersRepository } from "@/modules/users/users.repository";
import { Injectable } from "@nestjs/common";
import { PassportStrategy } from "@nestjs/passport";
@Injectable()
export class ApiAuthMockStrategy extends PassportStrategy(BaseStrategy, "api-auth") {
constructor(private readonly email: string, private readonly usersRepository: UsersRepository) {
super();
}
async authenticate() {
try {
const user = await this.usersRepository.findByEmailWithProfile(this.email);
if (!user) {
throw new Error("User with the provided ID not found");
}
return this.success(user);
} catch (error) {
console.error(error);
if (error instanceof Error) return this.error(error);
}
}
}

View File

@@ -0,0 +1,58 @@
import { CalendarsService } from "@/ee/calendars/services/calendars.service";
export class CalendarsServiceMock {
async getCalendars() {
return {
connectedCalendars: [
{
integration: {
installed: false,
type: "google_calendar",
title: "",
name: "",
description: "",
variant: "calendar",
slug: "",
locationOption: null,
categories: ["calendar"],
logo: "",
publisher: "",
url: "",
email: "",
},
credentialId: 1,
error: { message: "" },
},
{
integration: {
installed: false,
type: "office365_calendar",
title: "",
name: "",
description: "",
variant: "calendar",
slug: "",
locationOption: null,
categories: ["calendar"],
logo: "",
publisher: "",
url: "",
email: "",
},
credentialId: 2,
error: { message: "" },
},
],
destinationCalendar: {
name: "destinationCalendar",
eventTypeId: 1,
credentialId: 1,
primaryEmail: "primaryEmail",
integration: "google_calendar",
externalId: "externalId",
userId: null,
id: 0,
},
} satisfies Awaited<ReturnType<typeof CalendarsService.prototype.getCalendars>>;
}
}

View File

@@ -0,0 +1,15 @@
import { RedisService } from "@/modules/redis/redis.service";
import { Provider } from "@nestjs/common";
export const MockedRedisService = {
provide: RedisService,
useValue: {
redis: {
get: jest.fn(),
hgetall: jest.fn(),
set: jest.fn(),
hmset: jest.fn(),
expireat: jest.fn(),
},
},
} as Provider;

View File

@@ -0,0 +1,24 @@
import { NextAuthPassportStrategy } from "@/lib/passport/strategies/types";
import { UsersRepository } from "@/modules/users/users.repository";
import { Injectable } from "@nestjs/common";
import { PassportStrategy } from "@nestjs/passport";
@Injectable()
export class NextAuthMockStrategy extends PassportStrategy(NextAuthPassportStrategy, "next-auth") {
constructor(private readonly email: string, private readonly userRepository: UsersRepository) {
super();
}
async authenticate() {
try {
const user = await this.userRepository.findByEmailWithProfile(this.email);
if (!user) {
throw new Error("User with the provided email not found");
}
return this.success(user);
} catch (error) {
console.error(error);
if (error instanceof Error) return this.error(error);
}
}
}