MCPcopy
hub / github.com/chartbrew/chartbrew / generateTestToken

Function generateTestToken

server/tests/helpers/authHelpers.js:10–26  ·  view source on GitHub ↗
(payload = {}, options = {})

Source from the content-addressed store, hash-verified

8 * Generate a JWT token for testing
9 */
10export function generateTestToken(payload = {}, options = {}) {
11 const defaultPayload = {
12 id: 1,
13 email: "test@example.com",
14 name: "Test User",
15 ...payload
16 };
17
18 const defaultOptions = {
19 expiresIn: "1h",
20 ...options
21 };
22
23 // Use the same secret as the server for JWT verification
24 const secret = process.env.CB_ENCRYPTION_KEY_DEV || process.env.CB_ENCRYPTION_KEY || "0123456789abcdef0123456789abcdef";
25 return jwt.sign(defaultPayload, secret, defaultOptions);
26}
27
28/**
29 * Generate auth headers for testing

Calls

no outgoing calls

Tested by 5

seedStripeTemplateSetupFunction · 0.72
seedDatasetScopedAccessFunction · 0.72
seedProjectScopedAccessFunction · 0.72