Repository navigation
Expand file tree
/
Copy pathadmin.fixtures.ts
More file actions
114 lines (104 loc) · 2.65 KB
/
Copy pathadmin.fixtures.ts
File metadata and controls
114 lines (104 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import type { OidcApplication, OidcResource } from "@seamless-auth/types";
import type {
AdminCredential,
AdminMembership,
AdminOrganization,
AdminUser,
} from "./admin.js";
// Admin payloads as the auth API sends them, with every field the shared schemas
// require, so a test only spells out the ones it is about.
const CREATED = "2026-07-13T10:00:00.000Z";
export function apiUser(overrides: Partial<AdminUser> = {}): AdminUser {
return {
id: "u1",
email: "ada@example.com",
phone: null,
roles: [],
...overrides,
};
}
export function apiCredential(
overrides: Partial<AdminCredential> = {},
): AdminCredential {
return {
id: "cred-1",
counter: 0,
backedup: false,
backedUp: false,
createdAt: CREATED,
...overrides,
};
}
export function apiOrg(overrides: Partial<AdminOrganization> = {}): AdminOrganization {
return {
id: "o1",
name: "Acme",
slug: "acme",
createdByUserId: null,
metadata: null,
createdAt: CREATED,
updatedAt: CREATED,
...overrides,
};
}
export function apiMembership(
overrides: Partial<AdminMembership> = {},
): AdminMembership {
return {
id: "m1",
organizationId: "o1",
userId: "u1",
roles: [],
scopes: [],
createdAt: CREATED,
updatedAt: CREATED,
...overrides,
};
}
export function apiUserDetail(credentials: AdminCredential[] = []) {
return { user: apiUser(), sessions: [], credentials, events: [] };
}
export function apiApplication(
overrides: Partial<OidcApplication> = {},
): OidcApplication {
return {
id: "client_docs",
name: "Docs",
clientType: "confidential",
applicationType: "web",
firstParty: false,
tokenEndpointAuthMethod: "private_key_jwt",
redirectUris: ["https://docs.example.com/callback"],
postLogoutRedirectUris: [],
grantTypes: ["authorization_code", "refresh_token"],
deviceFlowEnabled: false,
noticesEnabled: false,
sessionExchangeEnabled: false,
pkceRequired: true,
nonceRequired: true,
jwks: null,
jwksUri: null,
hasSecret: false,
backchannelLogoutUri: null,
accessTokenTtlSeconds: null,
idTokenTtlSeconds: null,
refreshTokenTtlSeconds: null,
disabled: false,
createdAt: CREATED,
updatedAt: CREATED,
...overrides,
};
}
export const RESOURCE_ID = "00000000-0000-4000-8000-000000000001";
export function apiResource(overrides: Partial<OidcResource> = {}): OidcResource {
return {
id: RESOURCE_ID,
identifier: "https://orders.example.com",
name: "Orders",
scopes: ["orders:read", "orders:write"],
accessTokenTtlSeconds: null,
createdAt: CREATED,
updatedAt: CREATED,
...overrides,
};
}