Criar somente a automação backend em Node.js para integrar Hotmart → Webhook → Banco → Fluxos de e-mail e status, para uso dentro da minha plataforma já existente Zeyra (não criar frontend, sistema, telas nem painel).
848f927 verified Download tests/auth.test.js from fernandosliborioo/hotmartflow-integrator: direct link, hf CLI and curl.
- Browser
- Download file 2.46 kB
-
https://huggingface.co/spaces/fernandosliborioo/hotmartflow-integrator/resolve/main/tests/auth.test.js
- Command line
-
hf download hf://spaces/fernandosliborioo/hotmartflow-integrator/tests/auth.test.js
-
curl -L -o auth.test.js https://huggingface.co/spaces/fernandosliborioo/hotmartflow-integrator/resolve/main/tests/auth.test.js
2.46 kB
| const request = require('supertest'); | |
| const bcrypt = require('bcryptjs'); | |
| const { PrismaClient } = require('@prisma/client'); | |
| const app = require('../src/server'); | |
| const prisma = new PrismaClient(); | |
| describe('Authentication System', () => { | |
| beforeEach(async () => { | |
| await prisma.user.deleteMany(); | |
| }); | |
| afterAll(async () => { | |
| await prisma.$disconnect(); | |
| }); | |
| describe('POST /api/auth/login', () => { | |
| it('should login with valid credentials', async () => { | |
| const hashedPassword = await bcrypt.hash('password123', 12); | |
| await prisma.user.create({ | |
| data: { | |
| email: 'test@example.com', | |
| name: 'Test User', | |
| password: hashedPassword, | |
| status: 'active' | |
| } | |
| }); | |
| const response = await request(app) | |
| .post('/api/auth/login') | |
| .send({ | |
| email: 'test@example.com', | |
| password: 'password123' | |
| }); | |
| expect(response.status).toBe(200); | |
| expect(response.body.token).toBeTruthy(); | |
| expect(response.body.user.email).toBe('test@example.com'); | |
| }); | |
| it('should reject login with invalid credentials', async () => { | |
| const response = await request(app) | |
| .post('/api/auth/login') | |
| .send({ | |
| email: 'wrong@example.com', | |
| password: 'wrongpassword' | |
| }); | |
| expect(response.status).toBe(401); | |
| }); | |
| it('should reject login for blocked user', async () => { | |
| const hashedPassword = await bcrypt.hash('password123', 12); | |
| await prisma.user.create({ | |
| data: { | |
| email: 'blocked@example.com', | |
| name: 'Blocked User', | |
| password: hashedPassword, | |
| status: 'blocked' | |
| } | |
| }); | |
| const response = await request(app) | |
| .post('/api/auth/login') | |
| .send({ | |
| email: 'blocked@example.com', | |
| password: 'password123' | |
| }); | |
| expect(response.status).toBe(403); | |
| }); | |
| }); | |
| describe('POST /api/auth/forgot', () => { | |
| it('should accept forgot password request', async () => { | |
| await prisma.user.create({ | |
| data: { | |
| email: 'forgot@example.com', | |
| name: 'Forgot User', | |
| password: 'hashedpassword', | |
| status: 'active' | |
| } | |
| }); | |
| const response = await request(app) | |
| .post('/api/auth/forgot') | |
| .send({ email: 'forgot@example.com' }); | |
| expect(response.status).toBe(200); | |
| }); | |
| }); | |
| }); |