Skip to content

Commit

Permalink
[Security Solutions] Fixes and unskips tests (#94391) (#94623)
Browse files Browse the repository at this point in the history
## Summary

Fixes and unskips tests. Also makes the tests less picky. Although I enjoy seeing the changes on ES promotions of error messages in case we see something really bad happening, it's too manual of a process to fix and puts too much of a burden on operations to skip the error messages. 

### Checklist

- [x] [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

Co-authored-by: Frank Hassanabad <[email protected]>
  • Loading branch information
kibanamachine and FrankHassanabad authored Mar 15, 2021
1 parent 53b70f4 commit a7f7705
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export default ({ getService }: FtrProviderContext) => {
const supertest = getService('supertest');
const supertestWithoutAuth = getService('supertestWithoutAuth');

// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/94367
describe.skip('create_index', () => {
describe('create_index', () => {
afterEach(async () => {
await deleteSignalsIndex(supertest);
});
Expand Down Expand Up @@ -90,11 +89,8 @@ export default ({ getService }: FtrProviderContext) => {
.auth(role, 'changeme')
.send()
.expect(403);
expect(body).to.eql({
message:
'security_exception: action [cluster:admin/ilm/get] is unauthorized for user [t1_analyst], this action is granted by the cluster privileges [read_ilm,manage_ilm,manage,all]',
status_code: 403,
});
expect(body.message).to.match(/^security_exception/);
expect(body.status_code).to.eql(403);
});

it('should be able to read the index name and status as not being outdated', async () => {
Expand Down Expand Up @@ -140,11 +136,8 @@ export default ({ getService }: FtrProviderContext) => {
.auth(role, 'changeme')
.send()
.expect(403);
expect(body).to.eql({
message:
'security_exception: action [cluster:admin/ilm/get] is unauthorized for user [t2_analyst], this action is granted by the cluster privileges [read_ilm,manage_ilm,manage,all]',
status_code: 403,
});
expect(body.message).to.match(/^security_exception/);
expect(body.status_code).to.eql(403);
});

it('should be able to read the index name and status as not being outdated', async () => {
Expand Down Expand Up @@ -240,11 +233,8 @@ export default ({ getService }: FtrProviderContext) => {
.auth(role, 'changeme')
.send()
.expect(403);
expect(body).to.eql({
message:
'security_exception: action [cluster:admin/ilm/get] is unauthorized for user [soc_manager], this action is granted by the cluster privileges [read_ilm,manage_ilm,manage,all]',
status_code: 403,
});
expect(body.message).to.match(/^security_exception/);
expect(body.status_code).to.eql(403);
});

it('should be able to read the index name and status as not being outdated', async () => {
Expand Down Expand Up @@ -290,11 +280,8 @@ export default ({ getService }: FtrProviderContext) => {
.auth(role, 'changeme')
.send()
.expect(403);
expect(body).to.eql({
message:
'security_exception: action [cluster:admin/ilm/get] is unauthorized for user [hunter], this action is granted by the cluster privileges [read_ilm,manage_ilm,manage,all]',
status_code: 403,
});
expect(body.message).to.match(/^security_exception/);
expect(body.status_code).to.eql(403);
});

it('should be able to read the index name and status as not being outdated', async () => {
Expand Down Expand Up @@ -390,11 +377,8 @@ export default ({ getService }: FtrProviderContext) => {
.auth(role, 'changeme')
.send()
.expect(403);
expect(body).to.eql({
message:
'security_exception: action [cluster:admin/ilm/get] is unauthorized for user [reader], this action is granted by the cluster privileges [read_ilm,manage_ilm,manage,all]',
status_code: 403,
});
expect(body.message).to.match(/^security_exception/);
expect(body.status_code).to.eql(403);
});

it('should be able to read the index name and status as being outdated.', async () => {
Expand Down Expand Up @@ -440,11 +424,8 @@ export default ({ getService }: FtrProviderContext) => {
.auth(role, 'changeme')
.send()
.expect(403);
expect(body).to.eql({
message:
'security_exception: action [cluster:admin/ilm/get] is unauthorized for user [rule_author], this action is granted by the cluster privileges [read_ilm,manage_ilm,manage,all]',
status_code: 403,
});
expect(body.message).to.match(/^security_exception/);
expect(body.status_code).to.eql(403);
});

it('should be able to read the index name and status as being outdated.', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const supertestWithoutAuth = getService('supertestWithoutAuth');

// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/94367
describe.skip('deleting signals migrations', () => {
describe('deleting signals migrations', () => {
let outdatedSignalsIndexName: string;
let createdMigration: CreateResponse;
let finalizedMigration: FinalizeResponse;
Expand Down Expand Up @@ -129,11 +128,8 @@ export default ({ getService }: FtrProviderContext): void => {
const deletedMigration = body.migrations[0];

expect(deletedMigration.id).to.eql(createdMigration.migration_id);
expect(deletedMigration.error).to.eql({
message:
'security_exception: action [indices:admin/settings/update] is unauthorized for user [t1_analyst] on indices [], this action is granted by the index privileges [manage,all]',
status_code: 403,
});
expect(deletedMigration.error.message).to.match(/^security_exception/);
expect(deletedMigration.error.status_code).to.eql(403);
});
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const supertestWithoutAuth = getService('supertestWithoutAuth');

// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/94367
describe.skip('Finalizing signals migrations', () => {
describe('Finalizing signals migrations', () => {
let legacySignalsIndexName: string;
let outdatedSignalsIndexName: string;
let createdMigrations: CreateResponse[];
Expand Down Expand Up @@ -245,16 +244,14 @@ export default ({ getService }: FtrProviderContext): void => {
.auth(ROLES.t1_analyst, 'changeme')
.expect(200);

const finalizeResponse: FinalizeResponse = body.migrations[0];
const finalizeResponse: FinalizeResponse & {
error: { message: string; status_code: number };
} = body.migrations[0];

expect(finalizeResponse.id).to.eql(createdMigration.migration_id);
expect(finalizeResponse.completed).not.to.eql(true);
expect(finalizeResponse.error).to.eql({
message:
'security_exception: action [cluster:monitor/task/get] is unauthorized for user [t1_analyst], this action is granted by the cluster privileges [monitor,manage,all]',
status_code: 403,
});

expect(finalizeResponse.error.message).to.match(/^security_exception/);
expect(finalizeResponse.error.status_code).to.eql(403);
await deleteUserAndRole(getService, ROLES.t1_analyst);
});
});
Expand Down

0 comments on commit a7f7705

Please sign in to comment.