many fixes resulting from latest refactoring
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 5m41s
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 5m41s
This commit is contained in:
@@ -48,34 +48,37 @@ vi.mock('bcrypt', async (importOriginal) => {
|
||||
return { ...actual, compare: vi.fn() };
|
||||
});
|
||||
|
||||
// Define a type for the custom passport callback to avoid `any`.
|
||||
type PassportCallback = (error: Error | null, user: Express.User | false, info?: { message: string }) => void;
|
||||
|
||||
// Mock Passport middleware
|
||||
vi.mock('./passport.routes', () => ({
|
||||
default: {
|
||||
authenticate: (strategy: string, options: Record<string, unknown>, callback: PassportCallback) => (req: Request, res: any) => {
|
||||
// Logic to simulate passport authentication outcome based on test input
|
||||
if (req.body.password === 'wrong_password') {
|
||||
// Simulate incorrect credentials
|
||||
return callback(null, false, { message: 'Incorrect email or password.' });
|
||||
}
|
||||
if (req.body.email === 'locked@test.com') {
|
||||
// Simulate locked account
|
||||
return callback(null, false, { message: 'Account is temporarily locked.' });
|
||||
}
|
||||
if (req.body.email === 'notfound@test.com') {
|
||||
// Simulate user not found
|
||||
return callback(null, false, { message: 'Login failed' });
|
||||
}
|
||||
vi.hoisted(() => {
|
||||
// Define a type for the custom passport callback to avoid `any`.
|
||||
type PassportCallback = (error: Error | null, user: Express.User | false, info?: { message: string }) => void;
|
||||
|
||||
// Default success case
|
||||
const user = { user_id: 'user-123', email: req.body.email };
|
||||
callback(null, user, undefined);
|
||||
// Mock Passport middleware
|
||||
vi.mock('./passport.routes', () => ({
|
||||
default: {
|
||||
authenticate: (strategy: string, options: Record<string, unknown>, callback: PassportCallback) => (req: Request, res: any) => {
|
||||
// Logic to simulate passport authentication outcome based on test input
|
||||
if (req.body.password === 'wrong_password') {
|
||||
// Simulate incorrect credentials
|
||||
return callback(null, false, { message: 'Incorrect email or password.' });
|
||||
}
|
||||
if (req.body.email === 'locked@test.com') {
|
||||
// Simulate locked account
|
||||
return callback(null, false, { message: 'Account is temporarily locked.' });
|
||||
}
|
||||
if (req.body.email === 'notfound@test.com') {
|
||||
// Simulate user not found
|
||||
return callback(null, false, { message: 'Login failed' });
|
||||
}
|
||||
|
||||
// Default success case
|
||||
const user = { user_id: 'user-123', email: req.body.email };
|
||||
callback(null, user, undefined);
|
||||
},
|
||||
initialize: () => (req: any, res: any, next: any) => next(),
|
||||
},
|
||||
initialize: () => (req: any, res: any, next: any) => next(),
|
||||
},
|
||||
}));
|
||||
}));
|
||||
});
|
||||
|
||||
// Create a minimal Express app to host our router
|
||||
const app = express();
|
||||
|
||||
Reference in New Issue
Block a user