-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into alerting/consumer-based-rbac
* master: (28 commits) allow some env settings for ingest manager (#72544) Add inspector for VEGA (#70941) chore(NA): fix grunt task for test:coverage (#72539) Archive e2e test results in ES (#72575) preserve 401 errors from new es client (#71248) [SIEM][Detections] Updates text for severity and risk_score overrides (#72244) fixing error occurences tooltip (#72425) use KibanaClient interface instead of Client for new client interface (#72388) [APM] Handle ML errors (#72316) [Discover] Improve histogram tests (#72235) [ftr/webdriver] retry on all errors, use Rx so that timers are canceled (#72540) [pre-req] Move .storybook to storybook; standardize files (#72384) [Security_Solution][Resolver][Bug]: Restore breadcrumb background (#72538) [ML] Fix annotation detector linking & delayed_data(0) (#72468) [Security Solution][Exceptions] - Make esTypes and subType available to index patterns (#72336) [SIEM] Uses faster wait from testing-library and removes duplicate older wait idiom (#72509) Fix long combo box items breaking out of flex item width (#72512) [pipeline/commitStatus] update commit status in baseline-capture job (#72366) [Security Solution][Resolver] Update the resolver element ref on scroll events if the position of the element has changed within the page (#72461) [Maps] auto-fit to data bounds (#72129) ...
- Loading branch information
Showing
260 changed files
with
3,667 additions
and
2,170 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
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,82 @@ | ||
/* | ||
* 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 { | ||
ResponseError, | ||
ConnectionError, | ||
ConfigurationError, | ||
} from '@elastic/elasticsearch/lib/errors'; | ||
import { ApiResponse } from '@elastic/elasticsearch'; | ||
import { isResponseError, isUnauthorizedError } from './errors'; | ||
|
||
const createApiResponseError = ({ | ||
statusCode = 200, | ||
headers = {}, | ||
body = {}, | ||
}: { | ||
statusCode?: number; | ||
headers?: Record<string, string>; | ||
body?: Record<string, any>; | ||
} = {}): ApiResponse => { | ||
return { | ||
body, | ||
statusCode, | ||
headers, | ||
warnings: [], | ||
meta: {} as any, | ||
}; | ||
}; | ||
|
||
describe('isResponseError', () => { | ||
it('returns `true` when the input is a `ResponseError`', () => { | ||
expect(isResponseError(new ResponseError(createApiResponseError()))).toBe(true); | ||
}); | ||
|
||
it('returns `false` when the input is not a `ResponseError`', () => { | ||
expect(isResponseError(new Error('foo'))).toBe(false); | ||
expect(isResponseError(new ConnectionError('error', createApiResponseError()))).toBe(false); | ||
expect(isResponseError(new ConfigurationError('foo'))).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('isUnauthorizedError', () => { | ||
it('returns true when the input is a `ResponseError` and statusCode === 401', () => { | ||
expect( | ||
isUnauthorizedError(new ResponseError(createApiResponseError({ statusCode: 401 }))) | ||
).toBe(true); | ||
}); | ||
|
||
it('returns false when the input is a `ResponseError` and statusCode !== 401', () => { | ||
expect( | ||
isUnauthorizedError(new ResponseError(createApiResponseError({ statusCode: 200 }))) | ||
).toBe(false); | ||
expect( | ||
isUnauthorizedError(new ResponseError(createApiResponseError({ statusCode: 403 }))) | ||
).toBe(false); | ||
expect( | ||
isUnauthorizedError(new ResponseError(createApiResponseError({ statusCode: 500 }))) | ||
).toBe(false); | ||
}); | ||
|
||
it('returns `false` when the input is not a `ResponseError`', () => { | ||
expect(isUnauthorizedError(new Error('foo'))).toBe(false); | ||
expect(isUnauthorizedError(new ConnectionError('error', createApiResponseError()))).toBe(false); | ||
expect(isUnauthorizedError(new ConfigurationError('foo'))).toBe(false); | ||
}); | ||
}); |
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,32 @@ | ||
/* | ||
* 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 { ResponseError } from '@elastic/elasticsearch/lib/errors'; | ||
|
||
export type UnauthorizedError = ResponseError & { | ||
statusCode: 401; | ||
}; | ||
|
||
export function isResponseError(error: any): error is ResponseError { | ||
return Boolean(error.body && error.statusCode && error.headers); | ||
} | ||
|
||
export function isUnauthorizedError(error: any): error is UnauthorizedError { | ||
return isResponseError(error) && error.statusCode === 401; | ||
} |
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
Oops, something went wrong.