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.
Merge branch 'alerting/consumer-based-rbac' into alerting/management-…
…feature-privileges * alerting/consumer-based-rbac: (30 commits) removed uneeded tests expclude security wrapper in SO client passed to ActionsClient allow some env settings for ingest manager (elastic#72544) Add inspector for VEGA (elastic#70941) chore(NA): fix grunt task for test:coverage (elastic#72539) Archive e2e test results in ES (elastic#72575) preserve 401 errors from new es client (elastic#71248) [SIEM][Detections] Updates text for severity and risk_score overrides (elastic#72244) fixing error occurences tooltip (elastic#72425) use KibanaClient interface instead of Client for new client interface (elastic#72388) [APM] Handle ML errors (elastic#72316) [Discover] Improve histogram tests (elastic#72235) [ftr/webdriver] retry on all errors, use Rx so that timers are canceled (elastic#72540) [pre-req] Move .storybook to storybook; standardize files (elastic#72384) [Security_Solution][Resolver][Bug]: Restore breadcrumb background (elastic#72538) [ML] Fix annotation detector linking & delayed_data(0) (elastic#72468) [Security Solution][Exceptions] - Make esTypes and subType available to index patterns (elastic#72336) [SIEM] Uses faster wait from testing-library and removes duplicate older wait idiom (elastic#72509) Fix long combo box items breaking out of flex item width (elastic#72512) [pipeline/commitStatus] update commit status in baseline-capture job (elastic#72366) ...
- Loading branch information
Showing
265 changed files
with
3,763 additions
and
2,269 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.