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

Merged
merged 6 commits into from
Sep 26, 2022

Conversation

Tostti
Copy link
Member

@Tostti Tostti commented Sep 16, 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 with a version mismatch between Wazuh API and Wazuh App occurs, to make it more clear.
  • 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 Dashboard, in which the major and minor are not the same.
When the user opens the Wazuh section
Then the health-check confirmation should show an error on Check Wazuh API Version
And the log message should contain a URL to the Wazuh dashboard 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 Wazuh dashboard troubleshooting section of Wazuh Documentation.

Scenario: have an environment with different versions of Wazuh API and Wazuh Dashboard, 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 Wazuh Dashboard 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 Wazuh Dashboard troubleshooting section of Wazuh Documentation.

@Tostti Tostti linked an issue Sep 16, 2022 that may be closed by this pull request
2 tasks
@AlexRuiz7 AlexRuiz7 changed the title Feature/enhance mismatch api plugin message os Change message for API version mismatch in WzD 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

Screenshot from 2022-09-26 10-07-02

@Tostti Tostti merged commit d3cb5cb into 4.4-1.2-wzd Sep 26, 2022
@Tostti Tostti deleted the feature/Enhance-mismatch-API-plugin-message-OS branch September 26, 2022 14:40
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