MCPcopy
hub / github.com/directus/directus / createFilesUser

Function createFilesUser

tests/e2e/tests/endpoints/files/files.sb.test.ts:56–80  ·  view source on GitHub ↗

* Create a non-admin user whose policy grants the given directus_files * permissions, returning a static token to authenticate as them. Only the * fields that matter per test need to be passed; the rest are defaulted.

(permissions: Partial<Permission>[])

Source from the content-addressed store, hash-verified

54 * fields that matter per test need to be passed; the rest are defaulted.
55 */
56async function createFilesUser(permissions: Partial<Permission>[]) {
57 const token = randomUUID();
58
59 const user = await api.request<{ id: string }>(
60 createUser({ first_name: 'Test', last_name: 'Files', email: `${token}@files.com`, password: 'password', token }),
61 );
62
63 const policy = await api.request<{ id: string }>(
64 createPolicy({
65 name: `files-${randomUUID()}`,
66 admin_access: false,
67 app_access: false,
68 users: [{ user: user.id }],
69 permissions: [],
70 }),
71 );
72
73 await api.request(
74 updatePolicy(policy.id, {
75 permissions: permissions.map((perm) => ({ collection: 'directus_files', fields: ['*'], ...perm })) as any,
76 }),
77 );
78
79 return token;
80}
81
82async function findFileByDownloadName(filenameDownload: string) {
83 const [file] = await api.request<{ id: string }[]>(

Callers 1

files.sb.test.tsFile · 0.85

Calls 4

createUserFunction · 0.90
createPolicyFunction · 0.90
updatePolicyFunction · 0.90
requestMethod · 0.65

Tested by

no test coverage detected