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

Change message for API version mismatch in Kibana #4529

Merged
merged 12 commits into from Sep 26, 2022

Conversation

Tostti
Copy link
Member

@Tostti Tostti commented Sep 15, 2022

Solves #4299

Important information

On PR #4103, a method was changed to request the API endpoint. Only for testing purposes of this particular issue, it is possible to replace line 50 of server/lib/api-interceptor.ts with the following: method: !!authContext ? 'POST' : 'GET', to avoid getting an error due to a not allowed method and trigger the desired error.

Changes made:

  • Modified the message displayed when there is a version mismatch between the Wazuh API and the Wazuh App, to make it easier to understand.
  • Removed the <a> tags on the message.
  • Added PLUGIN_APP_NAME constant to make the message match the same structure as in Wazuh Dashboard, for easier modifications in the future.
  • Added addTagsToUrl function on health-check-container.tsx and modified the displayed error message to use that function.

addTagsToUrl

This function receives a string and returns it with the next modifications:

  • If the string contains a structure <something> guide: <URL>, it will modify that part to return <something> guide wrapped in <a> tags with the href pointing to the URL.
  • If the string contains a URL without guide: before it, it will wrap the URL in <a> tags.
  • If the string doesn't contain any URL, it will return it without modifications.

Before the changes:

image

After the changes:

image

Tests

Scenario: have an environment with different versions of Wazuh API and Wazuh app, in which the major and minor are not the same.
When the user opens the Wazuh plugin
Then the health-check confirmation should show an error on Check Wazuh API Version
And the log message should contain a URL to the Elasticsearch troubleshooting section of Wazuh Documentation.
And the log message should not contain any <a> tags or HTML structure
And the message shown at the bottom should contain a clickable link to the Elasticsearch troubleshooting section of Wazuh Documentation.

Scenario: have an environment with different versions of Wazuh API and Wazuh app, in which the major and minor are not the same.
When the user forces a health check in debug mode
Then the health-check confirmation should show an error on Check Wazuh API Version
And the log message should contain a URL to the Elasticsearch troubleshooting section of Wazuh Documentation.
And the log message should not contain any <a> tags or HTML structure
And the message shown at the bottom should contain a clickable link to the Elasticsearch troubleshooting section of Wazuh Documentation.

@AlexRuiz7 AlexRuiz7 changed the title Feature/enhance mismatch api plugin message es Change message for API version mismatch in Kibana Sep 22, 2022
@Tostti Tostti marked this pull request as ready for review September 23, 2022 13:16
Copy link
Contributor

@Mayons95 Mayons95 left a comment

Choose a reason for hiding this comment

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

TR: ✔️
LGTM

Screenshot from 2022-09-26 10-06-52

@Tostti Tostti merged commit 28370ee into 4.4-7.10 Sep 26, 2022
@Tostti Tostti deleted the feature/Enhance-mismatch-API-plugin-message-ES branch September 26, 2022 14:40
@github-actions
Copy link
Contributor

The backport to 4.4-7.16 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.4-7.16 4.4-7.16
# Navigate to the new working tree
cd .worktrees/backport-4.4-7.16
# Create a new branch
git switch --create backport-4529-to-4.4-7.16
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 28370ee826292a40f658ac0f36791e8a7dec773a
# Push it to GitHub
git push --set-upstream origin backport-4529-to-4.4-7.16
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.4-7.16

Then, create a pull request where the base branch is 4.4-7.16 and the compare/head branch is backport-4529-to-4.4-7.16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance the message displayed when there is a mismatch in API and plugin versions
3 participants