Skip to content

Commit

Permalink
Reuse core-security-service createMockAuthenticatedUser mock (#187426)
Browse files Browse the repository at this point in the history
Follow up to #187318

Implement core `createMockAuthenticatedUser` in the security plugin mock
to avoid divergence.

---------

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
TinaHeiligers and elasticmachine authored Jul 3, 2024
1 parent 482f2a9 commit ee80b74
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions x-pack/plugins/security/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import { of } from 'rxjs';

import { securityServiceMock } from '@kbn/core-security-server-mocks';

import { authenticationMock, authorizationMock } from './authentication/index.mock';
import { navControlServiceMock } from './nav_control/index.mock';
import { getUiApiMock } from './ui_api/index.mock';
import { licenseMock } from '../common/licensing/index.mock';
import type { MockAuthenticatedUserProps } from '../common/model/authenticated_user.mock';
import { mockAuthenticatedUser } from '../common/model/authenticated_user.mock';

function createSetupMock() {
return {
Expand Down Expand Up @@ -43,6 +43,5 @@ function createStartMock() {
export const securityMock = {
createSetup: createSetupMock,
createStart: createStartMock,
createMockAuthenticatedUser: (props: MockAuthenticatedUserProps = {}) =>
mockAuthenticatedUser(props),
createMockAuthenticatedUser: securityServiceMock.createMockAuthenticatedUser,
};
7 changes: 3 additions & 4 deletions x-pack/plugins/security/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

import type { TransportResult } from '@elastic/elasticsearch';

import { securityServiceMock } from '@kbn/core-security-server-mocks';

import { auditServiceMock } from './audit/mocks';
import { authenticationServiceMock } from './authentication/authentication_service.mock';
import { authorizationMock } from './authorization/index.mock';
import { userProfileServiceMock } from './user_profile/user_profile_service.mock';
import { licenseMock } from '../common/licensing/index.mock';
import { mockAuthenticatedUser } from '../common/model/authenticated_user.mock';
import type { MockAuthenticatedUserProps } from '../common/model/authenticated_user.mock';

function createSetupMock() {
const mockAuthz = authorizationMock.create();
Expand Down Expand Up @@ -79,6 +79,5 @@ export const securityMock = {
createSetup: createSetupMock,
createStart: createStartMock,
createApiResponse: createApiResponseMock,
createMockAuthenticatedUser: (props: MockAuthenticatedUserProps = {}) =>
mockAuthenticatedUser(props),
createMockAuthenticatedUser: securityServiceMock.createMockAuthenticatedUser,
};
3 changes: 2 additions & 1 deletion x-pack/plugins/security/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"@kbn/core-user-profile-server",
"@kbn/core-user-profile-browser",
"@kbn/security-api-key-management",
"@kbn/security-form-components"
"@kbn/security-form-components",
"@kbn/core-security-server-mocks",
],
"exclude": [
"target/**/*",
Expand Down

0 comments on commit ee80b74

Please sign in to comment.