Skip to content

Commit

Permalink
Reverting changes to genericize exempt consumer id
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Aug 11, 2021
1 parent 35f55ce commit 970cc12
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 302 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,35 +75,6 @@ test('creates an alerting authorization client with proper constructor arguments
auditLogger: expect.any(AlertingAuthorizationAuditLogger),
getSpace: expect.any(Function),
getSpaceId: expect.any(Function),
exemptConsumerIds: [],
});

expect(AlertingAuthorizationAuditLogger).toHaveBeenCalled();
expect(securityPluginSetup.audit.getLogger).toHaveBeenCalledWith(ALERTS_FEATURE_ID);
});

test('creates an alerting authorization client with proper constructor arguments when exemptConsumerIds are specified', async () => {
const factory = new AlertingAuthorizationClientFactory();
factory.initialize({
securityPluginSetup,
securityPluginStart,
...alertingAuthorizationClientFactoryParams,
});
const request = KibanaRequest.from(fakeRequest);
const { AlertingAuthorizationAuditLogger } = jest.requireMock('./authorization/audit_logger');

factory.create(request, ['exemptConsumerA', 'exemptConsumerB']);

const { AlertingAuthorization } = jest.requireMock('./authorization/alerting_authorization');
expect(AlertingAuthorization).toHaveBeenCalledWith({
request,
authorization: securityPluginStart.authz,
ruleTypeRegistry: alertingAuthorizationClientFactoryParams.ruleTypeRegistry,
features: alertingAuthorizationClientFactoryParams.features,
auditLogger: expect.any(AlertingAuthorizationAuditLogger),
getSpace: expect.any(Function),
getSpaceId: expect.any(Function),
exemptConsumerIds: ['exemptConsumerA', 'exemptConsumerB'],
});

expect(AlertingAuthorizationAuditLogger).toHaveBeenCalled();
Expand All @@ -126,7 +97,6 @@ test('creates an alerting authorization client with proper constructor arguments
auditLogger: expect.any(AlertingAuthorizationAuditLogger),
getSpace: expect.any(Function),
getSpaceId: expect.any(Function),
exemptConsumerIds: [],
});

expect(AlertingAuthorizationAuditLogger).toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class AlertingAuthorizationClientFactory {
this.getSpaceId = options.getSpaceId;
}

public create(request: KibanaRequest, exemptConsumerIds: string[] = []): AlertingAuthorization {
public create(request: KibanaRequest): AlertingAuthorization {
const { securityPluginSetup, securityPluginStart, features } = this;
return new AlertingAuthorization({
authorization: securityPluginStart?.authz,
Expand All @@ -57,7 +57,6 @@ export class AlertingAuthorizationClientFactory {
auditLogger: new AlertingAuthorizationAuditLogger(
securityPluginSetup?.audit.getLogger(ALERTS_FEATURE_ID)
),
exemptConsumerIds,
});
}
}
Loading

0 comments on commit 970cc12

Please sign in to comment.