|
| 1 | +import MeiliSearch from '../src/browser' |
1 | 2 | import { ErrorStatusCode } from '../src/types' |
2 | 3 | import { |
3 | 4 | clearAllIndexes, |
4 | 5 | config, |
5 | 6 | getClient, |
6 | 7 | getKey, |
| 8 | + HOST, |
7 | 9 | } from './utils/meilisearch-test-utils' |
8 | 10 |
|
9 | 11 | beforeEach(async () => { |
@@ -116,6 +118,32 @@ describe.each([{ permission: 'Master' }, { permission: 'Private' }])( |
116 | 118 | expect(key).toHaveProperty('expiresAt', null) |
117 | 119 | }) |
118 | 120 |
|
| 121 | + test(`${permission} key: create key with actions using wildcards to provide rights`, async () => { |
| 122 | + const client = await getClient(permission) |
| 123 | + const uid = '3db051e0-423d-4b5c-a63a-f82a7043dce6' |
| 124 | + |
| 125 | + const key = await client.createKey({ |
| 126 | + uid, |
| 127 | + description: 'Indexing Products API key', |
| 128 | + actions: ['indexes.*', 'tasks.*', 'documents.*'], |
| 129 | + indexes: ['wildcard_keys_permission'], |
| 130 | + expiresAt: null, |
| 131 | + }) |
| 132 | + |
| 133 | + const newClient = new MeiliSearch({ host: HOST, apiKey: key.key }) |
| 134 | + await newClient.createIndex('wildcard_keys_permission') // test index creation |
| 135 | + const taskInfo = await newClient |
| 136 | + .index('wildcard_keys_permission') |
| 137 | + .addDocuments([{ id: 1 }]) // test document addition |
| 138 | + const task = await newClient.waitForTask(taskInfo.taskUid) // test fetching of tasks |
| 139 | + |
| 140 | + expect(key).toBeDefined() |
| 141 | + expect(task.status).toBe('succeeded') |
| 142 | + expect(key).toHaveProperty('description', 'Indexing Products API key') |
| 143 | + expect(key).toHaveProperty('uid', uid) |
| 144 | + expect(key).toHaveProperty('expiresAt', null) |
| 145 | + }) |
| 146 | + |
119 | 147 | test(`${permission} key: create key with an expiresAt`, async () => { |
120 | 148 | const client = await getClient(permission) |
121 | 149 |
|
|
0 commit comments