-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1594: Changes related to the next Meilisearch release (v1.5.0) r=brunoocasali a=meili-bot Related to this issue: meilisearch/integration-guides#290 This PR: - gathers the changes related to the next Meilisearch release (v1.5.0) so that this package is ready when the official release is out. - should pass the tests against the [latest pre-release of Meilisearch](https://github.com/meilisearch/meilisearch/releases). - might eventually contain test failures until the Meilisearch v1.5.0 is out.⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.5.0) is out. _This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/main/resources/pre-release-week.md) purpose._ Co-authored-by: meili-bot <74670311+meili-bot@users.noreply.github.com> Co-authored-by: Bruno Casali <brunoocasali@gmail.com> Co-authored-by: meili-bors[bot] <89034592+meili-bors[bot]@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { ErrorStatusCode } from '../src/types' | ||
import { | ||
clearAllIndexes, | ||
config, | ||
MeiliSearch, | ||
BAD_HOST, | ||
getClient, | ||
} from './utils/meilisearch-test-utils' | ||
|
||
beforeEach(async () => { | ||
await clearAllIndexes(config) | ||
}) | ||
|
||
describe.each([{ permission: 'Master' }, { permission: 'Admin' }])( | ||
'Test on snapshot', | ||
({ permission }) => { | ||
test(`${permission} key: create a new snapshot`, async () => { | ||
const client = await getClient(permission) | ||
const { taskUid } = await client.createSnapshot() | ||
|
||
await client.waitForTask(taskUid) | ||
}) | ||
} | ||
) | ||
|
||
describe.each([{ permission: 'Search' }])( | ||
'Test on snapshot with search api key should not have access', | ||
({ permission }) => { | ||
test(`${permission} key: try to create snapshot with search key and be denied`, async () => { | ||
const client = await getClient(permission) | ||
await expect(client.createSnapshot()).rejects.toHaveProperty( | ||
'code', | ||
ErrorStatusCode.INVALID_API_KEY | ||
) | ||
}) | ||
} | ||
) | ||
|
||
describe.each([{ permission: 'No' }])( | ||
'Test on snapshot without api key should not have access', | ||
({ permission }) => { | ||
test(`${permission} key: try to create snapshot with no key and be denied`, async () => { | ||
const client = await getClient(permission) | ||
await expect(client.createSnapshot()).rejects.toHaveProperty( | ||
'code', | ||
ErrorStatusCode.MISSING_AUTHORIZATION_HEADER | ||
) | ||
}) | ||
} | ||
) | ||
|
||
describe.each([ | ||
{ host: BAD_HOST, trailing: false }, | ||
{ host: `${BAD_HOST}/api`, trailing: false }, | ||
{ host: `${BAD_HOST}/trailing/`, trailing: true }, | ||
])('Tests on url construction', ({ host, trailing }) => { | ||
test(`Test createSnapshot route`, async () => { | ||
const route = `snapshots` | ||
const client = new MeiliSearch({ host }) | ||
const strippedHost = trailing ? host.slice(0, -1) : host | ||
|
||
await expect(client.createSnapshot()).rejects.toHaveProperty( | ||
'message', | ||
`request to ${strippedHost}/${route} failed, reason: connect ECONNREFUSED ${BAD_HOST.replace( | ||
'http://', | ||
'' | ||
)}` | ||
) | ||
}) | ||
}) |