Fake request interface compatible with Kibana Request (#40363) (#40409)

* make FakeRequest compatible with http request

* FakeRequest compatible with Http Request
This commit is contained in:
Mikhail Shustov 2019-07-05 14:51:58 +02:00 committed by GitHub
parent d70349e642
commit cfad1013db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 8 deletions

View file

@ -4,7 +4,7 @@
## ElasticsearchErrorHelpers class
Helpers provided to simplify future migration away from Boom as internal Error.
Helpers for working with errors returned from the Elasticsearch service.Since the internal data of errors are subject to change, consumers of the Elasticsearch service should always use these helpers to classify errors instead of checking error internals such as `body.error.header[WWW-Authenticate]`
<b>Signature:</b>
@ -25,7 +25,7 @@ Handle errors
```js
try {
await client.callWithRequest(request, '...');
await client.asScoped(request).callAsCurrentUser(...);
} catch (err) {
if (ElasticsearchErrorHelpers.isNotAuthorizedError(err)) {
const authHeader = err.output.headers['WWW-Authenticate'];

View file

@ -9,5 +9,5 @@ Headers used for authentication against Elasticsearch
<b>Signature:</b>
```typescript
headers: Record<string, string>;
headers: Headers;
```

View file

@ -16,5 +16,5 @@ export interface FakeRequest
| Property | Type | Description |
| --- | --- | --- |
| [headers](./kibana-plugin-server.fakerequest.headers.md) | <code>Record&lt;string, string&gt;</code> | Headers used for authentication against Elasticsearch |
| [headers](./kibana-plugin-server.fakerequest.headers.md) | <code>Headers</code> | Headers used for authentication against Elasticsearch |

View file

@ -15,7 +15,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| Class | Description |
| --- | --- |
| [ClusterClient](./kibana-plugin-server.clusterclient.md) | Represents an Elasticsearch cluster API client and allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via <code>asScoped(...)</code>). |
| [ElasticsearchErrorHelpers](./kibana-plugin-server.elasticsearcherrorhelpers.md) | Helpers provided to simplify future migration away from Boom as internal Error. |
| [ElasticsearchErrorHelpers](./kibana-plugin-server.elasticsearcherrorhelpers.md) | Helpers for working with errors returned from the Elasticsearch service.Since the internal data of errors are subject to change, consumers of the Elasticsearch service should always use these helpers to classify errors instead of checking error internals such as <code>body.error.header[WWW-Authenticate]</code> |
| [KibanaRequest](./kibana-plugin-server.kibanarequest.md) | Kibana specific abstraction for an incoming request. |
| [Router](./kibana-plugin-server.router.md) | |
| [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) | |

View file

@ -22,7 +22,7 @@ import { Request } from 'hapi';
import { ElasticsearchErrorHelpers } from './errors';
import { GetAuthHeaders, isRealRequest } from '../http';
import { filterHeaders, KibanaRequest, ensureRawRequest } from '../http/router';
import { filterHeaders, Headers, KibanaRequest, ensureRawRequest } from '../http/router';
import { Logger } from '../logging';
import {
ElasticsearchClientConfig,
@ -106,7 +106,7 @@ async function callAPI(
*/
export interface FakeRequest {
/** Headers used for authentication against Elasticsearch */
headers: Record<string, string>;
headers: Headers;
}
/**

View file

@ -154,7 +154,7 @@ export interface ElasticsearchServiceSetup {
// @public
export interface FakeRequest {
headers: Record<string, string>;
headers: Headers;
}
// @public