Skip to content
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

[App Search] Role mappings migration part 2 #94461

Conversation

scottybollinger
Copy link
Contributor

Summary

This is the part 2 of the Role Mappings to Kibana migration. This PR ports the logic file over. The full code can be found here, if QA is to be done.

Checklist

The original asRoleMapping was merely for a smoke test in the shared component. Refactored to work better in App Search component
@scottybollinger scottybollinger added Feature:Plugins release_note:skip Skip the PR/issue when compiling release notes v7.13.0 auto-backport Deprecated - use backport:version if exact versions are needed labels Mar 11, 2021
@scottybollinger scottybollinger requested review from a team March 11, 2021 16:47
Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

Thanks a ton for this Scotty! Some minor comments and general questions for you - I'm definitely not super familiar with the in-depth role mappings functionality, so appreciate any answers/knawledge you can toss me

Copy link
Member

@JasonStoltz JasonStoltz left a comment

Choose a reason for hiding this comment

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

[EDIT] Just now realizing this PR is from you @scottybollinger . I reviewed this like I review any other App Search Logic file. If it seems too onerous, that is fine. I can make updates in a follow up PR or something. I realize you might not use the same patterns or standards on the WS half of things. So consider this optional.

I reviewed the test file only, a few general comments that they can all boil down to...

  1. Consider making assertions in tests directly on .values and spreading DEFAULT_VALUES.
  2. Consider using mount when setting up initial data, and consider doing it more often to get better, more understandable tests.
  3. Consider using better descriptions on tests. It can be a valuable living documentation source.

My comments identify a few specific instances where that would help, but I think there are probably others as well.

scottybollinger and others added 2 commits March 15, 2021 10:22
Co-authored-by: Jason Stoltzfus <[email protected]>
Co-authored-by: Jason Stoltzfus <[email protected]>
Copy link
Contributor Author

@scottybollinger scottybollinger left a comment

Choose a reason for hiding this comment

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

@JasonStoltz thanks for the edit above. I would actually like to make the changes you suggested, as I agree with them and they will help make our tests better in Workplace Search.

Refactoring the tests showed me that some parts of the state weren’t being reset.
I some how got the test coverage at 100% with my wrong way of doing tests before (scary). When I fixed it I noticed that noting I could do would trigger the fallback of just returning the `[ANY_AUTH_PROVIDER]` array. After talking with Constance, we could not come up with a way to trigger it either, given the conditions.

She had suggested removing the first return statement but that caused an empty array being returned sometimes.

Ultimately, I was able to get it working and covered with these changes.
The places where `role: 'superuser’` was deleted in the listeners was a side effect of using `setRoleMappingData` and not `mount`
@scottybollinger
Copy link
Contributor Author

@elasticmachine merge upstream

@scottybollinger
Copy link
Contributor Author

scottybollinger commented Mar 15, 2021

@JasonStoltz this should be ready for another look. I have updated the full-feature code on this branch if you want to do any QA

@JasonStoltz JasonStoltz self-requested a review March 16, 2021 11:39
Co-authored-by: Constance <[email protected]>
@scottybollinger scottybollinger enabled auto-merge (squash) March 16, 2021 18:11
@scottybollinger scottybollinger enabled auto-merge (squash) March 16, 2021 18:23
Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

Mostly just minor test nits comments on my part - feel free to commit & auto-merge after. Thanks so much for the changes and awesome work Scotty!! You rock!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
enterpriseSearch 2.1MB 2.1MB +888.0B

History

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

@scottybollinger scottybollinger merged commit 4aa7036 into elastic:master Mar 16, 2021
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Mar 16, 2021
* Add engines mock and fix mock role mapping

The original asRoleMapping was merely for a smoke test in the shared component. Refactored to work better in App Search component

* Add RoleMappingsLogic

* Fix test description

Co-authored-by: Jason Stoltzfus <[email protected]>

* Fix test description

Co-authored-by: Jason Stoltzfus <[email protected]>

* Add flash messages when creating, updating or deleting

* Add path and resetState calls

Refactoring the tests showed me that some parts of the state weren’t being reset.

* Refactor handleAuthProviderChange logic

I some how got the test coverage at 100% with my wrong way of doing tests before (scary). When I fixed it I noticed that noting I could do would trigger the fallback of just returning the `[ANY_AUTH_PROVIDER]` array. After talking with Constance, we could not come up with a way to trigger it either, given the conditions.

She had suggested removing the first return statement but that caused an empty array being returned sometimes.

Ultimately, I was able to get it working and covered with these changes.

* Refactor tests per PR feedback

The places where `role: 'superuser’` was deleted in the listeners was a side effect of using `setRoleMappingData` and not `mount`

* Add back deleted assertion

* Copy nit

Co-authored-by: Constance <[email protected]>

Co-authored-by: Jason Stoltzfus <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Constance <[email protected]>
@kibanamachine
Copy link
Contributor

💚 Backport successful

7.x / #94762

Successful backport PRs will be merged automatically after passing CI.

@scottybollinger scottybollinger deleted the scottybollinger/as-role-mappings-2 branch March 16, 2021 21:17
kibanamachine added a commit that referenced this pull request Mar 16, 2021
* Add engines mock and fix mock role mapping

The original asRoleMapping was merely for a smoke test in the shared component. Refactored to work better in App Search component

* Add RoleMappingsLogic

* Fix test description

Co-authored-by: Jason Stoltzfus <[email protected]>

* Fix test description

Co-authored-by: Jason Stoltzfus <[email protected]>

* Add flash messages when creating, updating or deleting

* Add path and resetState calls

Refactoring the tests showed me that some parts of the state weren’t being reset.

* Refactor handleAuthProviderChange logic

I some how got the test coverage at 100% with my wrong way of doing tests before (scary). When I fixed it I noticed that noting I could do would trigger the fallback of just returning the `[ANY_AUTH_PROVIDER]` array. After talking with Constance, we could not come up with a way to trigger it either, given the conditions.

She had suggested removing the first return statement but that caused an empty array being returned sometimes.

Ultimately, I was able to get it working and covered with these changes.

* Refactor tests per PR feedback

The places where `role: 'superuser’` was deleted in the listeners was a side effect of using `setRoleMappingData` and not `mount`

* Add back deleted assertion

* Copy nit

Co-authored-by: Constance <[email protected]>

Co-authored-by: Jason Stoltzfus <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Constance <[email protected]>

Co-authored-by: Scotty Bollinger <[email protected]>
Co-authored-by: Jason Stoltzfus <[email protected]>
Co-authored-by: Constance <[email protected]>
jloleysens added a commit that referenced this pull request Mar 17, 2021
…-action

* 'master' of github.com:elastic/kibana: (44 commits)
  Migrate the optimizer mixin to core (#94272)
  Replace EuiCodeBlock with JsonCodeEditor in DiscoverGrid (#92442)
  [ML] Anomaly Detection: Migrate validation messages links to use docLinks. (#94568)
  [Lists][Exceptions] - Adding basic linting, i18n and storybook support (#94772)
  [Fleet] Add test/fix for invalid/missing ids in bulk agent reassign (#94632)
  [Security Solution] [Cases] Move create page components and dependencies to Cases (#94444)
  [ML] Data Frame Analytics accessibility tests: fix flaky outlier creation test (#94735)
  [Security Solutions] Remove commented out old linter rules (#94753)
  [App Search] Role mappings migration part 2 (#94461)
  [CI] Update Backport action inputs to match updated ones (#94721)
  [chore] Remove the infra team from CODEOWNERS (#94740)
  [Connectors UI] Make UI use new connector APIs (#94180)
  [ML] Use indices options in anomaly detection job wizards (#91830)
  Remove `string` as a valid registry var type value (#94174)
  [Alerts] Replaces legacy es client with the ElasticsearchClient for alerts and triggers_actions_ui plugins. (#93364)
  [Reporting-CSV Export] Re-write CSV Export using SearchSource (#88303)
  chore(NA): upgrade bazel rules nodejs to v3.2.2 (#94726)
  [APM] Settings: Update layout and update/add descriptions (#94398)
  skip flaky suite (#94666)
  [XY axis] Integrates legend color picker with the eui palette (#90589)
  ...

# Conflicts:
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/cold_phase/cold_phase.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/searchable_snapshot_field/searchable_snapshot_field.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/constants.ts
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/configuration_context.tsx
#	x-pack/plugins/index_lifecycle_management/public/shared_imports.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:Plugins release_note:skip Skip the PR/issue when compiling release notes v7.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants