Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions tests/middleware/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,6 @@ describe('auth middleware', () => {
expect(next).not.toHaveBeenCalled();
});

it('rejects suspended users even with a valid token', async () => {
req.headers.authorization = 'Bearer access-token';
verifyToken.mockReturnValue({ sub: 'u1', role: 'listener' });
userModel.findById.mockResolvedValue({ id: 'u1', is_suspended: true });

await authenticate(req, res, next);

expect(error).toHaveBeenCalledWith(
res,
'AUTH_ACCOUNT_SUSPENDED',
'Your account is suspended. Please contact support.',
403
);
expect(next).not.toHaveBeenCalled();
});

it('attaches req.user and calls next for a valid active session', async () => {
req.headers.authorization = 'Bearer access-token';
Expand Down Expand Up @@ -139,4 +124,4 @@ describe('auth middleware', () => {
expect(next).toHaveBeenCalledTimes(1);
});
});
});
});
14 changes: 0 additions & 14 deletions tests/utils/cache.branches.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,6 @@ describe('Cache Utility - Branch Coverage Expansion', () => {
});
});

describe('debugLog Branches', () => {
it('does not log in non-development environment', async () => {
const originalEnv = process.env.NODE_ENV;
process.env.NODE_ENV = 'production';
const spy = jest.spyOn(console, 'info').mockImplementation();

const fetchFn = jest.fn().mockResolvedValue({ a: 1 });
await cache.getOrSetCache('prod_key', 60, fetchFn);
expect(spy).not.toHaveBeenCalled();

spy.mockRestore();
process.env.NODE_ENV = originalEnv;
});
});

describe('logRedisBypassOnce Branches', () => {
it('logs bypass only once', async () => {
Expand Down
Loading