Skip to content

[Security Solutions][Detection Engine] Adds e2e and unit tests for PR #89947 #89973

Merged
FrankHassanabad merged 4 commits intoelastic:masterfrom
FrankHassanabad:add-e2e-tests
Feb 2, 2021
Merged

[Security Solutions][Detection Engine] Adds e2e and unit tests for PR #89947 #89973
FrankHassanabad merged 4 commits intoelastic:masterfrom
FrankHassanabad:add-e2e-tests

Conversation

@FrankHassanabad
Copy link
Copy Markdown
Contributor

@FrankHassanabad FrankHassanabad commented Feb 2, 2021

Summary

Adds e2e and unit tests for PR:
#89947

  • Adds e2e tests for create_index
  • Adds e2e tests for get_privileges
  • Adds unit test for use_privilege_user
  • Adds exhaustive switch for the roles in the e2e tests
  • Adds some typescript barrel rolls for the .json scripts to make TypeScript a bit more readable when doing imports
  • Fixes some of the types that were not matched up with the recent privilege endpoint

Checklist

@FrankHassanabad FrankHassanabad requested review from a team as code owners February 2, 2021 06:28
@FrankHassanabad FrankHassanabad self-assigned this Feb 2, 2021
.send()
.expect(200);
expect(body).to.eql({
index_mapping_outdated: null,
Copy link
Copy Markdown
Contributor Author

@FrankHassanabad FrankHassanabad Feb 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: I think this index_mapping_outdated: null is returned intentionally for when the user does not have correct permissions to read if the index mapping exists or not. It exists here in a few other tests.

@FrankHassanabad FrankHassanabad added release_note:skip Skip the PR/issue when compiling release notes Feature:Detection Alerts Security Solution Detection Alerts Feature v8.0.0 v7.14.0 v7.12.0 v7.11.1 and removed v7.14.0 labels Feb 2, 2021
detections_admin = 'detections_admin',
}

export type RolesType = keyof typeof ROLES;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: removed as I directly use the ROLES below now and this enables me to use an exhaustive switch.


import * as t1AnalystUser from './detections_user.json';
import * as t1AnalystRole from './detections_role.json';
export { t1AnalystUser, t1AnalystRole };
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: I get that these are script folders, but the tests and imports cleaned up when I did the NodeJS index barrel rolls here.

return postRoleAndUser(ROLES.reader, readerRole, readerUser, securityService);
default:
break;
return assertUnreachable(role);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: Using this and changing the enum above gives us exhaustive switches where when someone adds a new role type such as ROLES.reader (which was missing I noticed), they are forced to add it to this function as well.

Copy link
Copy Markdown
Contributor

@dhurley14 dhurley14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup and the additional tests LGTM!

@FrankHassanabad
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@FrankHassanabad FrankHassanabad merged commit de216e6 into elastic:master Feb 2, 2021
@FrankHassanabad FrankHassanabad deleted the add-e2e-tests branch February 2, 2021 21:26
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request Feb 2, 2021
…lastic#89947  (elastic#89973)

## Summary

Adds e2e and unit tests for PR:
elastic#89947

* Adds e2e tests for create_index
* Adds e2e tests for get_privileges
* Adds unit test for use_privilege_user
* Adds exhaustive switch for the roles in the e2e tests
* Adds some typescript barrel rolls for the .json scripts to make TypeScript a bit more readable when doing imports 
* Fixes some of the types that were not matched up with the recent privilege endpoint

### 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
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request Feb 2, 2021
…lastic#89947  (elastic#89973)

## Summary

Adds e2e and unit tests for PR:
elastic#89947

* Adds e2e tests for create_index
* Adds e2e tests for get_privileges
* Adds unit test for use_privilege_user
* Adds exhaustive switch for the roles in the e2e tests
* Adds some typescript barrel rolls for the .json scripts to make TypeScript a bit more readable when doing imports 
* Fixes some of the types that were not matched up with the recent privilege endpoint

### 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
FrankHassanabad added a commit that referenced this pull request Feb 3, 2021
…for PR #89947  (#89973) (#90091)

* [Security Solutions][Detection Engine] Adds e2e and unit tests for PR #89947  (#89973)

## Summary

Adds e2e and unit tests for PR:
#89947

* Adds e2e tests for create_index
* Adds e2e tests for get_privileges
* Adds unit test for use_privilege_user
* Adds exhaustive switch for the roles in the e2e tests
* Adds some typescript barrel rolls for the .json scripts to make TypeScript a bit more readable when doing imports 
* Fixes some of the types that were not matched up with the recent privilege endpoint

### 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

* Fixes the backport for test to work correctly as the messages are different

* Fixes one permission change issue between versions
FrankHassanabad added a commit that referenced this pull request Feb 3, 2021
… for PR #89947  (#89973) (#90092)

* [Security Solutions][Detection Engine] Adds e2e and unit tests for PR #89947  (#89973)

## Summary

Adds e2e and unit tests for PR:
#89947

* Adds e2e tests for create_index
* Adds e2e tests for get_privileges
* Adds unit test for use_privilege_user
* Adds exhaustive switch for the roles in the e2e tests
* Adds some typescript barrel rolls for the .json scripts to make TypeScript a bit more readable when doing imports 
* Fixes some of the types that were not matched up with the recent privilege endpoint

### 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

* Updated to work with the right messages

* Fixes permissions that are slightly different
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Detection Alerts Security Solution Detection Alerts Feature release_note:skip Skip the PR/issue when compiling release notes v7.11.1 v7.12.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants