Skip to content

Commit

Permalink
Exposes authenticate user mock from core-security-server-mocks (#187318)
Browse files Browse the repository at this point in the history
Needed for #187306 and [probably
more to come](#186574).
Expose authenticated user mock and type from core-security server &
browser mocks.
Exposing the mock from Core avoids dependencies on the Security Plugin
remaining just for mocks.
It also helps avoid creating duplicates specifically for tests.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
TinaHeiligers and elasticmachine authored Jul 2, 2024
1 parent 47a92f4 commit 525d24e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
InternalSecurityServiceSetup,
InternalSecurityServiceStart,
} from '@kbn/core-security-browser-internal';
import { mockAuthenticatedUser, MockAuthenticatedUserProps } from '@kbn/core-security-common/mocks';

const createSetupMock = () => {
const mock: jest.Mocked<SecurityServiceSetup> = {
Expand Down Expand Up @@ -64,4 +65,6 @@ export const securityServiceMock = {
createStart: createStartMock,
createInternalSetup: createInternalSetupMock,
createInternalStart: createInternalStartMock,
createMockAuthenticatedUser: (props: MockAuthenticatedUserProps = {}) =>
mockAuthenticatedUser(props),
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"kbn_references": [
"@kbn/core-security-browser",
"@kbn/core-security-browser-internal",
"@kbn/core-security-common",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
InternalSecurityServiceStart,
} from '@kbn/core-security-server-internal';
import { auditServiceMock, type MockedAuditService } from './audit.mock';
import { mockAuthenticatedUser, MockAuthenticatedUserProps } from '@kbn/core-security-common/mocks';

const createSetupMock = () => {
const mock: jest.Mocked<SecurityServiceSetup> = {
Expand Down Expand Up @@ -99,4 +100,6 @@ export const securityServiceMock = {
createInternalSetup: createInternalSetupMock,
createInternalStart: createInternalStartMock,
createRequestHandlerContext: createRequestHandlerContextMock,
createMockAuthenticatedUser: (props: MockAuthenticatedUserProps = {}) =>
mockAuthenticatedUser(props),
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"@kbn/core-security-server",
"@kbn/core-security-server-internal",
"@kbn/core-http-server",
"@kbn/core-security-common",
]
}

0 comments on commit 525d24e

Please sign in to comment.