diff --git a/packages/hoppscotch-backend/.env.example b/packages/hoppscotch-backend/.env.example index 2423391b0..78700ecaf 100644 --- a/packages/hoppscotch-backend/.env.example +++ b/packages/hoppscotch-backend/.env.example @@ -7,12 +7,13 @@ POSTMARK_SENDER_EMAIL=************************************************" # Auth Tokens Config JWT_SECRET='add some secret here' -REFRESH_TOKEN_VALIDITY="168h" # Default validity is 7 days -ACCESS_TOKEN_VALIDITY="30s" # Default validity is 1 day +REFRESH_TOKEN_VALIDITY="604800000" # Default validity is 7 days +ACCESS_TOKEN_VALIDITY="120000" # Default validity is 1 day # Hoppscotch App Domain Config APP_DOMAIN="************************************************"" REDIRECT_URL="************************************************"" +WHITELISTED_ORIGINS ="************************************************" # Google Auth Config GOOGLE_CLIENT_ID="************************************************" @@ -24,3 +25,9 @@ GOOGLE_SCOPE= ['email', 'profile'], GITHUB_CLIENT_ID="************************************************" GITHUB_CLIENT_SECRET="************************************************" GITHUB_CALLBACK_URL="************************************************" + +# Microsoft Auth Config +MICROSOFT_CLIENT_ID="************************************************" +MICROSOFT_CLIENT_SECRET="************************************************" +MICROSOFT_CALLBACK_URL="************************************************" +MICROSOFT_SCOPE="user.read" diff --git a/packages/hoppscotch-backend/src/auth/auth.service.spec.ts b/packages/hoppscotch-backend/src/auth/auth.service.spec.ts index 800ab6626..3a396b674 100644 --- a/packages/hoppscotch-backend/src/auth/auth.service.spec.ts +++ b/packages/hoppscotch-backend/src/auth/auth.service.spec.ts @@ -1,18 +1,35 @@ -import { Test, TestingModule } from '@nestjs/testing'; +import { JwtService } from '@nestjs/jwt'; +import { mockDeep } from 'jest-mock-extended'; +import { MailerService } from 'src/mailer/mailer.service'; +import { PrismaService } from 'src/prisma/prisma.service'; +import { AuthUser } from 'src/types/AuthUser'; +import { UserService } from 'src/user/user.service'; import { AuthService } from './auth.service'; -describe('AuthService', () => { - let service: AuthService; +const mockPrisma = mockDeep(); +const mockUser = mockDeep(); +const mockJWT = mockDeep(); +const mockMailer = mockDeep(); - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - providers: [AuthService], - }).compile(); +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore +const authService = new AuthService(mockUser, mockPrisma, mockJWT, mockMailer); - service = module.get(AuthService); - }); +const currentTime = new Date(); - it('should be defined', () => { - expect(service).toBeDefined(); - }); +const user: AuthUser = { + uid: '123344', + email: 'dwight@dundermifflin.com', + displayName: 'Dwight Schrute', + photoURL: 'https://en.wikipedia.org/wiki/Dwight_Schrute', + isAdmin: false, + refreshToken: 'hbfvdkhjbvkdvdfjvbnkhjb', + createdOn: currentTime, +}; + +describe('signIn', () => { + // should throw error if email is not in valid format + // should successfully create a new user account and return the passwordless details + // should successfully return the passwordless details for a existing user account + });