Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Apr 16, 2024
1 parent af0baec commit dc91440
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('getSystemActionKibanaPrivileges', () => {
const privileges = getSystemActionKibanaPrivileges({
connectorAdapterRegistry: registry,
systemActions: [],
rule: { consumer: 'stackAlerts' },
rule: { consumer: 'stackAlerts', producer: 'alerts' },
});

expect(privileges).toEqual([]);
Expand All @@ -54,7 +54,7 @@ describe('getSystemActionKibanaPrivileges', () => {
it('should return an empty array if systemActions are not defined', () => {
const privileges = getSystemActionKibanaPrivileges({
connectorAdapterRegistry: registry,
rule: { consumer: 'stackAlerts' },
rule: { consumer: 'stackAlerts', producer: 'alerts' },
});

expect(privileges).toEqual([]);
Expand All @@ -64,7 +64,7 @@ describe('getSystemActionKibanaPrivileges', () => {
const privileges = getSystemActionKibanaPrivileges({
connectorAdapterRegistry: registry,
systemActions,
rule: { consumer: 'stackAlerts' },
rule: { consumer: 'stackAlerts', producer: 'alerts' },
});

expect(privileges).toEqual(['my-priv:stackAlerts', 'my-priv-2:stackAlerts']);
Expand All @@ -74,7 +74,7 @@ describe('getSystemActionKibanaPrivileges', () => {
const privileges = getSystemActionKibanaPrivileges({
connectorAdapterRegistry: registry,
systemActions: [...systemActions, { id: 'my-id-2', actionTypeId: '.not-valid', params: {} }],
rule: { consumer: 'stackAlerts' },
rule: { consumer: 'stackAlerts', producer: 'alerts' },
});

expect(privileges).toEqual(['my-priv:stackAlerts', 'my-priv-2:stackAlerts']);
Expand All @@ -84,7 +84,7 @@ describe('getSystemActionKibanaPrivileges', () => {
const privileges = getSystemActionKibanaPrivileges({
connectorAdapterRegistry: registry,
systemActions: [...systemActions, { id: 'my-id-2', actionTypeId: '.no-priv', params: {} }],
rule: { consumer: 'stackAlerts' },
rule: { consumer: 'stackAlerts', producer: 'alerts' },
});

expect(privileges).toEqual(['my-priv:stackAlerts', 'my-priv-2:stackAlerts']);
Expand All @@ -94,7 +94,7 @@ describe('getSystemActionKibanaPrivileges', () => {
const privileges = getSystemActionKibanaPrivileges({
connectorAdapterRegistry: registry,
systemActions: [systemActions[0], systemActions[0]],
rule: { consumer: 'stackAlerts' },
rule: { consumer: 'stackAlerts', producer: 'alerts' },
});

expect(privileges).toEqual(['my-priv:stackAlerts']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('validateAndAuthorizeSystemActions', () => {
systemActions: [],
actionsClient,
actionsAuthorization,
rule: { consumer: 'stackAlerts' },
rule: { consumer: 'stackAlerts', producer: 'alerts' },
});

expect(res).toBe(undefined);
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('validateAndAuthorizeSystemActions', () => {
systemActions,
actionsClient,
actionsAuthorization,
rule: { consumer: 'stackAlerts' },
rule: { consumer: 'stackAlerts', producer: 'alerts' },
})
).rejects.toThrowErrorMatchingInlineSnapshot(`"Action not-exist is not a system action"`);
});
Expand All @@ -103,7 +103,7 @@ describe('validateAndAuthorizeSystemActions', () => {
systemActions,
actionsClient,
actionsAuthorization,
rule: { consumer: 'stackAlerts' },
rule: { consumer: 'stackAlerts', producer: 'alerts' },
})
).rejects.toThrowErrorMatchingInlineSnapshot(`"Action not-exist is not a system action"`);
});
Expand All @@ -128,7 +128,7 @@ describe('validateAndAuthorizeSystemActions', () => {
systemActions,
actionsClient,
actionsAuthorization,
rule: { consumer: 'stackAlerts' },
rule: { consumer: 'stackAlerts', producer: 'alerts' },
})
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Invalid system action params. System action type: .test - [foo]: expected value of type [string] but got [undefined]"`
Expand Down Expand Up @@ -161,7 +161,7 @@ describe('validateAndAuthorizeSystemActions', () => {
systemActions,
actionsClient,
actionsAuthorization,
rule: { consumer: 'stackAlerts' },
rule: { consumer: 'stackAlerts', producer: 'alerts' },
})
).rejects.toThrowErrorMatchingInlineSnapshot(`"Cannot use the same system action twice"`);
});
Expand Down Expand Up @@ -213,7 +213,7 @@ describe('validateAndAuthorizeSystemActions', () => {
systemActions,
actionsClient,
actionsAuthorization,
rule: { consumer: 'stackAlerts' },
rule: { consumer: 'stackAlerts', producer: 'alerts' },
});

expect(res).toBe(undefined);
Expand Down Expand Up @@ -281,7 +281,7 @@ describe('validateAndAuthorizeSystemActions', () => {
systemActions,
actionsClient,
actionsAuthorization,
rule: { consumer: 'stackAlerts' },
rule: { consumer: 'stackAlerts', producer: 'alerts' },
});

expect(actionsAuthorization.ensureAuthorized).toBeCalledWith({
Expand Down

0 comments on commit dc91440

Please sign in to comment.