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

[Fleet] fix validation of output secret fields #172795

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

juliaElastic
Copy link
Contributor

@juliaElastic juliaElastic commented Dec 7, 2023

Summary

Closes #172481

Fixed validation of secret output fields. Updated cypress tests that validates output secrets.

Create a new remote elasticsearch output and verify that service token field is required when clicking Save without filling it in.
image

Same for Logstash ssl key:
image

Kafka password and ssl key:
image

In edit mode, when the secret field is empty, the validation is shown again and goes away when clicking on Cancel changes.
image
image

Checklist

@juliaElastic juliaElastic added release_note:skip Skip the PR/issue when compiling release notes v8.12.0 labels Dec 7, 2023
@juliaElastic juliaElastic self-assigned this Dec 7, 2023
@juliaElastic juliaElastic requested a review from a team as a code owner December 7, 2023 10:36
@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Dec 7, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

is_default_monitoring: false,
hosts: ['https://bla.co'],
secrets: { service_token: 'token' },
preset: 'balanced',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

strangely leaving the preset out had the effect of the secret not being created

Copy link
Member

Choose a reason for hiding this comment

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

Hmm interesting. Any further indication why that might have happened? Might be worth experimenting with or exploring further 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't reproduce it, tried with curl to leave out preset field, but I get a different 400 error:

  curl 'http://localhost:5601/julia/api/fleet/outputs' \
  -sk -XPOST -u elastic:changeme  \
  -H 'elastic-api-version: 2023-10-31' \
  -H "kbn-xsrf: reporting" \
  --data-raw '{"name":"remote","type":"remote_elasticsearch","hosts":["http://localhost"],"is_default":false,"is_default_monitoring":false,"config_yaml":"","secrets":{"service_token":"token"},"proxy_id":null}'

{"statusCode":400,"error":"Bad Request","message":"[request body]: types that failed validation:\n- [request body.0.name]: expected value of type [string] but got [undefined]\n- [request body.1.name]: expected value of type [string] but got [undefined]\n- [request body.2.name]: expected value of type [string] but got [undefined]\n- [request body.3.name]: expected value of type [string] but got [undefined]"}%

I also tried to comment out the preset field from the UI code, but then the output was created successfully with the secret. I'm not sure what was different in cypress.

is_default_monitoring: false,
hosts: ['https://bla.co'],
secrets: { service_token: 'token' },
preset: 'balanced',
Copy link
Member

Choose a reason for hiding this comment

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

Hmm interesting. Any further indication why that might have happened? Might be worth experimenting with or exploring further 🤷

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

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
fleet 1.2MB 1.2MB +211.0B

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

cc @juliaElastic

@juliaElastic juliaElastic merged commit a8f8f08 into elastic:main Dec 7, 2023
38 of 39 checks passed
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 7, 2023
## Summary

Closes elastic#172481

Fixed validation of secret output fields. Updated cypress tests that
validates output secrets.

Create a new remote elasticsearch output and verify that service token
field is required when clicking Save without filling it in.
<img width="673" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/29774463-23de-495a-a1c7-49fd3281877c">

Same for Logstash ssl key:
<img width="678" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/7b41d95f-8066-47d1-a662-2e696399f90c">

Kafka password and ssl key:
<img width="669" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/2ea4dade-beb2-41e8-b068-6d6c42dca498">

In edit mode, when the secret field is empty, the validation is shown
again and goes away when clicking on Cancel changes.
<img width="680" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/93500091-05a5-458c-a42e-97d5f8937d15">
<img width="667" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/b7434126-bf20-40ce-9605-f63d694ea9ca">

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

(cherry picked from commit a8f8f08)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.12

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Dec 7, 2023
)

# Backport

This will backport the following commits from `main` to `8.12`:
- [[Fleet] fix validation of output secret fields
(#172795)](#172795)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Julia
Bardi","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-12-07T13:14:56Z","message":"[Fleet]
fix validation of output secret fields (#172795)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/172481\r\n\r\nFixed validation
of secret output fields. Updated cypress tests that\r\nvalidates output
secrets.\r\n\r\nCreate a new remote elasticsearch output and verify that
service token\r\nfield is required when clicking Save without filling it
in.\r\n<img width=\"673\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/29774463-23de-495a-a1c7-49fd3281877c\">\r\n\r\nSame
for Logstash ssl key:\r\n<img width=\"678\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/7b41d95f-8066-47d1-a662-2e696399f90c\">\r\n\r\nKafka
password and ssl key:\r\n<img width=\"669\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/2ea4dade-beb2-41e8-b068-6d6c42dca498\">\r\n\r\nIn
edit mode, when the secret field is empty, the validation is
shown\r\nagain and goes away when clicking on Cancel changes.\r\n<img
width=\"680\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/93500091-05a5-458c-a42e-97d5f8937d15\">\r\n<img
width=\"667\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/b7434126-bf20-40ce-9605-f63d694ea9ca\">\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"a8f8f087d3ba622970ff9075beab2a1693e3a7d3","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v8.12.0","v8.13.0"],"number":172795,"url":"https://github.com/elastic/kibana/pull/172795","mergeCommit":{"message":"[Fleet]
fix validation of output secret fields (#172795)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/172481\r\n\r\nFixed validation
of secret output fields. Updated cypress tests that\r\nvalidates output
secrets.\r\n\r\nCreate a new remote elasticsearch output and verify that
service token\r\nfield is required when clicking Save without filling it
in.\r\n<img width=\"673\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/29774463-23de-495a-a1c7-49fd3281877c\">\r\n\r\nSame
for Logstash ssl key:\r\n<img width=\"678\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/7b41d95f-8066-47d1-a662-2e696399f90c\">\r\n\r\nKafka
password and ssl key:\r\n<img width=\"669\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/2ea4dade-beb2-41e8-b068-6d6c42dca498\">\r\n\r\nIn
edit mode, when the secret field is empty, the validation is
shown\r\nagain and goes away when clicking on Cancel changes.\r\n<img
width=\"680\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/93500091-05a5-458c-a42e-97d5f8937d15\">\r\n<img
width=\"667\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/b7434126-bf20-40ce-9605-f63d694ea9ca\">\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"a8f8f087d3ba622970ff9075beab2a1693e3a7d3"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/172795","number":172795,"mergeCommit":{"message":"[Fleet]
fix validation of output secret fields (#172795)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/172481\r\n\r\nFixed validation
of secret output fields. Updated cypress tests that\r\nvalidates output
secrets.\r\n\r\nCreate a new remote elasticsearch output and verify that
service token\r\nfield is required when clicking Save without filling it
in.\r\n<img width=\"673\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/29774463-23de-495a-a1c7-49fd3281877c\">\r\n\r\nSame
for Logstash ssl key:\r\n<img width=\"678\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/7b41d95f-8066-47d1-a662-2e696399f90c\">\r\n\r\nKafka
password and ssl key:\r\n<img width=\"669\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/2ea4dade-beb2-41e8-b068-6d6c42dca498\">\r\n\r\nIn
edit mode, when the secret field is empty, the validation is
shown\r\nagain and goes away when clicking on Cancel changes.\r\n<img
width=\"680\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/93500091-05a5-458c-a42e-97d5f8937d15\">\r\n<img
width=\"667\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/b7434126-bf20-40ce-9605-f63d694ea9ca\">\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"a8f8f087d3ba622970ff9075beab2a1693e3a7d3"}}]}]
BACKPORT-->

Co-authored-by: Julia Bardi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.12.0 v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Output secret field is missing UI required validation
6 participants