mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:21:09 +02:00
✅ test(auth): update tests for minimal JWT claims architecture
- Update auth.controller.spec.ts to expect accessToken/refreshToken/expiresIn - Refactor jwt-validation.spec.ts to test minimal claims (sub, email, role, sid) - Remove B2B/B2C org and credit_balance claims from tests (fetched via API now) - Add Better Auth CLI config for schema generation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
bc274846f0
commit
746df03591
3 changed files with 277 additions and 709 deletions
26
services/mana-core-auth/auth.ts
Normal file
26
services/mana-core-auth/auth.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
/**
|
||||||
|
* Better Auth CLI configuration file
|
||||||
|
* This file is used by the Better Auth CLI to generate the schema.
|
||||||
|
* Run: npx @better-auth/cli generate --output ./src/db/schema/better-auth-schema.ts
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { betterAuth } from 'better-auth';
|
||||||
|
import { organization } from 'better-auth/plugins/organization';
|
||||||
|
import { jwt } from 'better-auth/plugins/jwt';
|
||||||
|
|
||||||
|
export const auth = betterAuth({
|
||||||
|
// Use simple URL-based connection for CLI
|
||||||
|
database: {
|
||||||
|
type: 'postgres',
|
||||||
|
url: 'postgresql://manacore:devpassword@localhost:5432/manacore',
|
||||||
|
},
|
||||||
|
emailAndPassword: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
organization({
|
||||||
|
allowUserToCreateOrganization: true,
|
||||||
|
}),
|
||||||
|
jwt(),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
@ -167,7 +167,9 @@ describe('AuthController', () => {
|
||||||
name: 'Test User',
|
name: 'Test User',
|
||||||
role: 'user',
|
role: 'user',
|
||||||
},
|
},
|
||||||
token: 'jwt-access-token',
|
accessToken: 'jwt-access-token',
|
||||||
|
refreshToken: 'session-refresh-token',
|
||||||
|
expiresIn: 900,
|
||||||
};
|
};
|
||||||
|
|
||||||
betterAuthService.signIn.mockResolvedValue(expectedResult);
|
betterAuthService.signIn.mockResolvedValue(expectedResult);
|
||||||
|
|
@ -193,7 +195,9 @@ describe('AuthController', () => {
|
||||||
|
|
||||||
betterAuthService.signIn.mockResolvedValue({
|
betterAuthService.signIn.mockResolvedValue({
|
||||||
user: { id: '123', email: 'user@example.com', name: 'Test', role: 'user' },
|
user: { id: '123', email: 'user@example.com', name: 'Test', role: 'user' },
|
||||||
token: 'token',
|
accessToken: 'jwt-token',
|
||||||
|
refreshToken: 'refresh-token',
|
||||||
|
expiresIn: 900,
|
||||||
});
|
});
|
||||||
|
|
||||||
await controller.login(loginDto);
|
await controller.login(loginDto);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue