-
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.
- Add Authorization type to ES UI shared. - Add convertPrivilegesToArray, patch to also accept privileges that might contain dots in its name, and add tests.
- Loading branch information
Showing
8 changed files
with
53 additions
and
14 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
28 changes: 28 additions & 0 deletions
28
.../es_ui_shared/__packages_do_not_import__/authorization/components/with_privileges.test.ts
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,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { convertPrivilegesToArray } from './with_privileges'; | ||
|
||
describe('convertPrivilegesToArray', () => { | ||
test('extracts section and privilege', () => { | ||
expect(convertPrivilegesToArray('index.index_name')).toEqual([['index', 'index_name']]); | ||
expect(convertPrivilegesToArray(['index.index_name', 'cluster.management'])).toEqual([ | ||
['index', 'index_name'], | ||
['cluster', 'management'], | ||
]); | ||
expect(convertPrivilegesToArray('index.index_name.with-many.dots')).toEqual([ | ||
['index', 'index_name.with-many.dots'], | ||
]); | ||
}); | ||
|
||
test('throws when it cannot extract section and privilege', () => { | ||
expect(() => { | ||
convertPrivilegesToArray('bad_privilege_string'); | ||
}).toThrow('Required privilege must have the format "section.privilege"'); | ||
}); | ||
}); |
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