-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ResponseOps] Granular connector RBAC followup (#205818)
## Summary This PR is followup to, #203503. This PR adds a test to make sure that sub-feature description remains accurate, and changes to hide the connector edit test tab and create connector button when a user only has read access. ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### To verify 1. Create a new read only role and disable EDR connectors under the Actions and Connectors privilege 2. Create a new user and assign that role to user 3. Create a Sentinel One connector (It doesn't need to work, you can use fake values for the url and token) 4. Login as the new user and go to the connector page in stack management 5. Verify that the "Create connector" button is not visible 6. Click on the connector you created, verify that you can't see the test tab
- Loading branch information
Showing
8 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...ting_api_integration/security_and_spaces/group2/tests/actions/sub_feature_descriptions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../../../common/ftr_provider_context'; | ||
|
||
const SUB_FEATURE_DESC_PREFIX = 'Includes: '; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default function subFeatureDescriptionsTest({ getService }: FtrProviderContext) { | ||
const supertest = getService('supertest'); | ||
|
||
describe('sub feature descriptions', () => { | ||
it('should have each connector in a sub feature description', async () => { | ||
const { body: features } = await supertest.get('/api/features').expect(200); | ||
expect(Array.isArray(features)).to.be(true); | ||
const actionsFeature = features.find((o: any) => o.id === 'actions'); | ||
expect(!!actionsFeature).to.be(true); | ||
|
||
const connectorTitles = []; | ||
for (const subFeature of actionsFeature.subFeatures) { | ||
expect(subFeature.description.indexOf(SUB_FEATURE_DESC_PREFIX)).to.be(0); | ||
connectorTitles.push( | ||
...subFeature.description.substring(SUB_FEATURE_DESC_PREFIX.length).split(', ') | ||
); | ||
} | ||
|
||
const { body: connectorTypes } = await supertest | ||
.get('/api/actions/connector_types') | ||
.expect(200); | ||
for (const connectorType of connectorTypes) { | ||
if (connectorType.sub_feature && !connectorTitles.includes(connectorType.name)) { | ||
throw new Error( | ||
`Connector type "${connectorType.name}" is not included in any of the "Actions & Connectors" sub-feature descriptions. Each new connector type must be manually added to the relevant sub-features. Please update the sub-feature descriptions in "x-pack/plugins/actions/server/feature.ts" to include "${connectorType.name}" to make this test pass.` | ||
); | ||
} | ||
} | ||
for (const connectorTitle of connectorTitles) { | ||
if (!connectorTypes.find((o: any) => o.name === connectorTitle)) { | ||
throw new Error( | ||
`Connector type "${connectorTitle}" is included in the "Actions & Connectors" sub-feature descriptions but not registered as a connector type. Please update the sub-feature descriptions in "x-pack/plugins/actions/server/feature.ts" to remove "${connectorTitle}" to make this test pass.` | ||
); | ||
} | ||
} | ||
}); | ||
}); | ||
} |