Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Jul 8, 2023
1 parent 637a6b3 commit eca005d
Showing 1 changed file with 0 additions and 76 deletions.
76 changes: 0 additions & 76 deletions x-pack/plugins/actions/server/actions_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,40 +928,6 @@ describe('get()', () => {
expect(authorization.ensureAuthorized).toHaveBeenCalledWith({ operation: 'get' });
});

test('ensures user is authorised to get a system action', async () => {
actionsClient = new ActionsClient({
logger,
actionTypeRegistry,
unsecuredSavedObjectsClient,
scopedClusterClient,
kibanaIndices,
actionExecutor,
executionEnqueuer,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
inMemoryConnectors: [
{
actionTypeId: '.cases',
config: {},
id: 'system-connector-.cases',
name: 'System action: .cases',
secrets: {},
isPreconfigured: false,
isDeprecated: false,
isSystemAction: true,
},
],
connectorTokenClient: connectorTokenClientMock.create(),
getEventLogClient,
});

await actionsClient.get({ id: 'system-connector-.cases' });

expect(authorization.ensureAuthorized).toHaveBeenCalledWith('get');
});

test('throws when user is not authorised to get the type of action', async () => {
unsecuredSavedObjectsClient.get.mockResolvedValueOnce({
id: '1',
Expand Down Expand Up @@ -1071,48 +1037,6 @@ describe('get()', () => {

expect(authorization.ensureAuthorized).toHaveBeenCalledWith({ operation: 'get' });
});

test('throws when user is not authorised to get a system action', async () => {
actionsClient = new ActionsClient({
logger,
actionTypeRegistry,
unsecuredSavedObjectsClient,
scopedClusterClient,
kibanaIndices,
actionExecutor,
executionEnqueuer,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
inMemoryConnectors: [
{
actionTypeId: '.cases',
config: {},
id: 'system-connector-.cases',
name: 'System action: .cases',
secrets: {},
isPreconfigured: false,
isDeprecated: false,
isSystemAction: true,
},
],
connectorTokenClient: connectorTokenClientMock.create(),
getEventLogClient,
});

authorization.ensureAuthorized.mockRejectedValue(
new Error(`Unauthorized to get a "system-connector-.cases" action`)
);

await expect(
actionsClient.get({ id: 'system-connector-.cases' })
).rejects.toMatchInlineSnapshot(
`[Error: Unauthorized to get a "system-connector-.cases" action]`
);

expect(authorization.ensureAuthorized).toHaveBeenCalledWith('get');
});
});

describe('auditLogger', () => {
Expand Down

0 comments on commit eca005d

Please sign in to comment.