-
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.
Migrate authc dependency from security plugin to core security service (
#187124) ## Summary Part of #186574 Background: This PR is an example of a plugin migrating away from depending on the Security plugin, which is a high-priority effort for the last release before 9.0. The Cases plugin uses authc.getCurrentUser from the security plugin's start contract on the server side. This PR migrates authc.getCurrentUser from the security plugin start contract to the core security service. Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
28cad8d
commit 4eb07b1
Showing
6 changed files
with
19 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ describe('CasesClientFactory', () => { | |
}); | ||
|
||
expect(args.securityPluginStart.userProfiles.getCurrent).toHaveBeenCalled(); | ||
expect(args.securityPluginStart.authc.getCurrentUser).not.toHaveBeenCalled(); | ||
expect(args.securityServiceStart.authc.getCurrentUser).not.toHaveBeenCalled(); | ||
expect(createCasesClientMocked.mock.calls[0][0].user).toEqual({ | ||
username: 'my_user', | ||
full_name: 'My user', | ||
|
@@ -63,7 +63,7 @@ describe('CasesClientFactory', () => { | |
it('constructs the user info from the authc service if the user profile is not available', async () => { | ||
const scopedClusterClient = coreStart.elasticsearch.client.asScoped(request).asCurrentUser; | ||
// @ts-expect-error: not all fields are needed | ||
args.securityPluginStart.authc.getCurrentUser.mockReturnValueOnce({ | ||
args.securityServiceStart.authc.getCurrentUser.mockReturnValueOnce({ | ||
username: 'my_user_2', | ||
full_name: 'My user 2', | ||
email: '[email protected]', | ||
|
@@ -76,7 +76,7 @@ describe('CasesClientFactory', () => { | |
}); | ||
|
||
expect(args.securityPluginStart.userProfiles.getCurrent).toHaveBeenCalled(); | ||
expect(args.securityPluginStart.authc.getCurrentUser).toHaveBeenCalled(); | ||
expect(args.securityServiceStart.authc.getCurrentUser).toHaveBeenCalled(); | ||
expect(createCasesClientMocked.mock.calls[0][0].user).toEqual({ | ||
username: 'my_user_2', | ||
full_name: 'My user 2', | ||
|
@@ -95,7 +95,7 @@ describe('CasesClientFactory', () => { | |
}); | ||
|
||
expect(args.securityPluginStart.userProfiles.getCurrent).toHaveBeenCalled(); | ||
expect(args.securityPluginStart.authc.getCurrentUser).toHaveBeenCalled(); | ||
expect(args.securityServiceStart.authc.getCurrentUser).toHaveBeenCalled(); | ||
expect(createCasesClientMocked.mock.calls[0][0].user).toEqual({ | ||
username: 'elastic/kibana', | ||
full_name: null, | ||
|
@@ -113,7 +113,7 @@ describe('CasesClientFactory', () => { | |
}); | ||
|
||
expect(args.securityPluginStart.userProfiles.getCurrent).toHaveBeenCalled(); | ||
expect(args.securityPluginStart.authc.getCurrentUser).toHaveBeenCalled(); | ||
expect(args.securityServiceStart.authc.getCurrentUser).toHaveBeenCalled(); | ||
expect(createCasesClientMocked.mock.calls[0][0].user).toEqual({ | ||
username: null, | ||
full_name: null, | ||
|
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