-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Defend Workflows] Enable FTR API tests for serverless using tags #170418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ff169ee
1dd34cd
91b319c
94bc321
5c57e04
4d93130
cff21ff
a9071f2
a2926e8
549d0fb
1aa7753
f1d7586
5ce6108
00f1bc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ import { | |
| GLOBAL_ARTIFACT_TAG, | ||
| } from '@kbn/security-solution-plugin/common/endpoint/service/artifacts'; | ||
| import { ExceptionsListItemGenerator } from '@kbn/security-solution-plugin/common/endpoint/data_generators/exceptions_list_item_generator'; | ||
| import { targetTags } from '../../../security_solution_endpoint/target_tags'; | ||
| import { FtrProviderContext } from '../../ftr_provider_context'; | ||
| import { PolicyTestResourceInfo } from '../../../security_solution_endpoint/services/endpoint_policy'; | ||
| import { ArtifactTestData } from '../../../security_solution_endpoint/services/endpoint_artifacts'; | ||
|
|
@@ -24,7 +25,9 @@ export default function ({ getService }: FtrProviderContext) { | |
| const endpointPolicyTestResources = getService('endpointPolicyTestResources'); | ||
| const endpointArtifactTestResources = getService('endpointArtifactTestResources'); | ||
|
|
||
| describe('Endpoint artifacts (via lists plugin): Blocklists', () => { | ||
| describe('Endpoint artifacts (via lists plugin): Blocklists', function () { | ||
| targetTags(this, ['@ess', '@serverless']); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious - could this have been implemented using I know that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree on that, it would be cleaner. I found some clues about how mocha is decorated in our environment, but couldn't make this work in a short amount of time, so now I'd go with this solution, and maybe return to this later (e.g. on OnWeek) |
||
|
|
||
| let fleetEndpointPolicy: PolicyTestResourceInfo; | ||
|
|
||
| before(async () => { | ||
|
|
@@ -155,7 +158,7 @@ export default function ({ getService }: FtrProviderContext) { | |
|
|
||
| body.entries[0].field = 'some.invalid.field'; | ||
| await supertestWithoutAuth[blocklistApiCall.method](blocklistApiCall.path) | ||
| .auth(ROLE.analyst_hunter, 'changeme') | ||
| .auth(ROLE.endpoint_policy_manager, 'changeme') | ||
| .set('kbn-xsrf', 'true') | ||
| .send(body) | ||
| .expect(400) | ||
|
|
@@ -176,7 +179,7 @@ export default function ({ getService }: FtrProviderContext) { | |
| ]; | ||
|
|
||
| await supertestWithoutAuth[blocklistApiCall.method](blocklistApiCall.path) | ||
| .auth(ROLE.analyst_hunter, 'changeme') | ||
| .auth(ROLE.endpoint_policy_manager, 'changeme') | ||
| .set('kbn-xsrf', 'true') | ||
| .send(body) | ||
| .expect(400) | ||
|
|
@@ -197,7 +200,7 @@ export default function ({ getService }: FtrProviderContext) { | |
| ]; | ||
|
|
||
| await supertestWithoutAuth[blocklistApiCall.method](blocklistApiCall.path) | ||
| .auth(ROLE.analyst_hunter, 'changeme') | ||
| .auth(ROLE.endpoint_policy_manager, 'changeme') | ||
| .set('kbn-xsrf', 'true') | ||
| .send(body) | ||
| .expect(400) | ||
|
|
@@ -224,7 +227,7 @@ export default function ({ getService }: FtrProviderContext) { | |
| ]; | ||
|
|
||
| await supertestWithoutAuth[blocklistApiCall.method](blocklistApiCall.path) | ||
| .auth(ROLE.analyst_hunter, 'changeme') | ||
| .auth(ROLE.endpoint_policy_manager, 'changeme') | ||
| .set('kbn-xsrf', 'true') | ||
| .send(body) | ||
| .expect(400) | ||
|
|
@@ -258,7 +261,7 @@ export default function ({ getService }: FtrProviderContext) { | |
| ]; | ||
|
|
||
| await supertestWithoutAuth[blocklistApiCall.method](blocklistApiCall.path) | ||
| .auth(ROLE.analyst_hunter, 'changeme') | ||
| .auth(ROLE.endpoint_policy_manager, 'changeme') | ||
| .set('kbn-xsrf', 'true') | ||
| .send(body) | ||
| .expect(400) | ||
|
|
@@ -272,7 +275,7 @@ export default function ({ getService }: FtrProviderContext) { | |
| body.os_types = ['linux', 'windows']; | ||
|
|
||
| await supertestWithoutAuth[blocklistApiCall.method](blocklistApiCall.path) | ||
| .auth(ROLE.analyst_hunter, 'changeme') | ||
| .auth(ROLE.endpoint_policy_manager, 'changeme') | ||
| .set('kbn-xsrf', 'true') | ||
| .send(body) | ||
| .expect(400) | ||
|
|
@@ -297,32 +300,31 @@ export default function ({ getService }: FtrProviderContext) { | |
| for (const blocklistApiCall of [...needsWritePrivilege, ...needsReadPrivilege]) { | ||
| it(`should not error on [${blocklistApiCall.method}] - [${blocklistApiCall.info}]`, async () => { | ||
| await supertestWithoutAuth[blocklistApiCall.method](blocklistApiCall.path) | ||
| .auth(ROLE.analyst_hunter, 'changeme') | ||
| .auth(ROLE.endpoint_policy_manager, 'changeme') | ||
| .set('kbn-xsrf', 'true') | ||
| .send(blocklistApiCall.getBody()) | ||
| .expect(200); | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| describe('and user has authorization to read blocklist', () => { | ||
| describe('and user has authorization to read blocklist', function () { | ||
| targetTags(this, ['@skipInServerless']); // no such role in serverless | ||
|
|
||
| for (const blocklistApiCall of [...blocklistApiCalls, ...needsWritePrivilege]) { | ||
| it(`should error on [${blocklistApiCall.method}] - [${blocklistApiCall.info}]`, async () => { | ||
| await supertestWithoutAuth[blocklistApiCall.method](blocklistApiCall.path) | ||
| .auth(ROLE.artifact_read_role, 'changeme') | ||
| .auth(ROLE.artifact_read_privileges, 'changeme') | ||
| .set('kbn-xsrf', 'true') | ||
| .send(blocklistApiCall.getBody()) | ||
| .expect(403, { | ||
| status_code: 403, | ||
| message: 'EndpointArtifactError: Endpoint authorization failure', | ||
| }); | ||
| .expect(403); | ||
| }); | ||
| } | ||
|
|
||
| for (const blocklistApiCall of needsReadPrivilege) { | ||
| it(`should not error on [${blocklistApiCall.method}] - [${blocklistApiCall.info}]`, async () => { | ||
| await supertestWithoutAuth[blocklistApiCall.method](blocklistApiCall.path) | ||
| .auth(ROLE.artifact_read_role, 'changeme') | ||
| .auth(ROLE.artifact_read_privileges, 'changeme') | ||
| .set('kbn-xsrf', 'true') | ||
| .send(blocklistApiCall.getBody()) | ||
| .expect(200); | ||
|
|
@@ -341,10 +343,7 @@ export default function ({ getService }: FtrProviderContext) { | |
| .auth(ROLE.t1_analyst, 'changeme') | ||
| .set('kbn-xsrf', 'true') | ||
| .send(blocklistApiCall.getBody()) | ||
| .expect(403, { | ||
| status_code: 403, | ||
| message: 'EndpointArtifactError: Endpoint authorization failure', | ||
| }); | ||
| .expect(403); | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.