Skip to content

Commit

Permalink
Add tests on keys action for v0.29.1 (#1325)
Browse files Browse the repository at this point in the history
* Update search params for v0.29.0

* Add tests on keys action for v0.29.1

* Remove skipped test
  • Loading branch information
bidoubiwa authored Sep 8, 2022
1 parent aaec2d9 commit 7ad3946
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/keys.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import MeiliSearch from '../src/browser'
import { ErrorStatusCode } from '../src/types'
import {
clearAllIndexes,
config,
getClient,
getKey,
HOST,
} from './utils/meilisearch-test-utils'

beforeEach(async () => {
Expand Down Expand Up @@ -116,6 +118,32 @@ describe.each([{ permission: 'Master' }, { permission: 'Private' }])(
expect(key).toHaveProperty('expiresAt', null)
})

test(`${permission} key: create key with actions using wildcards to provide rights`, async () => {
const client = await getClient(permission)
const uid = '3db051e0-423d-4b5c-a63a-f82a7043dce6'

const key = await client.createKey({
uid,
description: 'Indexing Products API key',
actions: ['indexes.*', 'tasks.*', 'documents.*'],
indexes: ['wildcard_keys_permission'],
expiresAt: null,
})

const newClient = new MeiliSearch({ host: HOST, apiKey: key.key })
await newClient.createIndex('wildcard_keys_permission') // test index creation
const taskInfo = await newClient
.index('wildcard_keys_permission')
.addDocuments([{ id: 1 }]) // test document addition
const task = await newClient.waitForTask(taskInfo.taskUid) // test fetching of tasks

expect(key).toBeDefined()
expect(task.status).toBe('succeeded')
expect(key).toHaveProperty('description', 'Indexing Products API key')
expect(key).toHaveProperty('uid', uid)
expect(key).toHaveProperty('expiresAt', null)
})

test(`${permission} key: create key with an expiresAt`, async () => {
const client = await getClient(permission)

Expand Down

0 comments on commit 7ad3946

Please sign in to comment.