forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Search] Session server side functional tests (elastic#86152) (elasti…
…c#87210) * OSS search functional tests * x-pack tests * Session tests * Update search.ts * Update session.ts * Update test/api_integration/apis/search/search.ts Co-authored-by: Lukas Olson <[email protected]> * reportServerError * Improve response error codes Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Lukas Olson <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Lukas Olson <[email protected]>
- Loading branch information
1 parent
19e9696
commit 4856675
Showing
16 changed files
with
656 additions
and
121 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
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,39 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { KibanaResponseFactory } from 'kibana/server'; | ||
import { KbnError } from '../common'; | ||
|
||
export class KbnServerError extends KbnError { | ||
constructor(message: string, public readonly statusCode: number) { | ||
super(message); | ||
} | ||
} | ||
|
||
export function reportServerError(res: KibanaResponseFactory, err: any) { | ||
return res.customError({ | ||
statusCode: err.statusCode ?? 500, | ||
body: { | ||
message: err.message, | ||
attributes: { | ||
error: err.body?.error || err.message, | ||
}, | ||
}, | ||
}); | ||
} |
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,88 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ getService }: FtrProviderContext) { | ||
const supertest = getService('supertest'); | ||
|
||
describe('msearch', () => { | ||
describe('post', () => { | ||
it('should return 200 when correctly formatted searches are provided', async () => | ||
await supertest | ||
.post(`/internal/_msearch`) | ||
.send({ | ||
searches: [ | ||
{ | ||
header: { index: 'foo' }, | ||
body: { | ||
query: { | ||
match_all: {}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}) | ||
.expect(200)); | ||
|
||
it('should return 400 if you provide malformed content', async () => | ||
await supertest | ||
.post(`/internal/_msearch`) | ||
.send({ | ||
foo: false, | ||
}) | ||
.expect(400)); | ||
|
||
it('should require you to provide an index for each request', async () => | ||
await supertest | ||
.post(`/internal/_msearch`) | ||
.send({ | ||
searches: [ | ||
{ header: { index: 'foo' }, body: {} }, | ||
{ header: {}, body: {} }, | ||
], | ||
}) | ||
.expect(400)); | ||
|
||
it('should not require optional params', async () => | ||
await supertest | ||
.post(`/internal/_msearch`) | ||
.send({ | ||
searches: [{ header: { index: 'foo' }, body: {} }], | ||
}) | ||
.expect(200)); | ||
|
||
it('should allow passing preference as a string', async () => | ||
await supertest | ||
.post(`/internal/_msearch`) | ||
.send({ | ||
searches: [{ header: { index: 'foo', preference: '_custom' }, body: {} }], | ||
}) | ||
.expect(200)); | ||
|
||
it('should allow passing preference as a number', async () => | ||
await supertest | ||
.post(`/internal/_msearch`) | ||
.send({ | ||
searches: [{ header: { index: 'foo', preference: 123 }, body: {} }], | ||
}) | ||
.expect(200)); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.