-
Couldn't load subscription status.
- Fork 25.6k
Add manage_search_synonyms privilege #97853
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
Merged
carlosdelest
merged 8 commits into
elastic:main
from
carlosdelest:carlosdelest/synonyms-manage-privilege
Jul 26, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
22d10cd
Add new privilege
carlosdelest 1205e84
Add tests
carlosdelest f9fac1a
Add new cluster privilege to test
carlosdelest e713643
Add synonym sets actions to cluster privilege
carlosdelest 6af2d3e
PR review comments
carlosdelest 14bef42
Spotless
carlosdelest 68a5a61
Remove unused test user and role
carlosdelest c6d99cf
Merge branch 'main' into carlosdelest/synonyms-manage-privilege
carlosdelest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...RestTest/resources/rest-api-spec/test/synonyms_privileges/10_synonyms_with_privileges.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| setup: | ||
| - skip: | ||
| features: headers | ||
| version: " - 8.9.99" | ||
| reason: Introduced in 8.10.0 | ||
|
|
||
| - do: | ||
| security.put_user: | ||
| username: "synonyms-user" | ||
| body: | ||
| password: "synonyms-user-password" | ||
| roles : [ "synonyms-role" ] | ||
|
|
||
| - do: | ||
| security.put_role: | ||
| name: "synonyms-role" | ||
| body: | ||
| cluster: ["manage_search_synonyms"] | ||
|
|
||
| --- | ||
| teardown: | ||
| - do: | ||
| security.delete_user: | ||
| username: "synonyms-user" | ||
| ignore: 404 | ||
| - do: | ||
| security.delete_role: | ||
| name: "synonyms-role" | ||
| ignore: 404 | ||
|
|
||
| --- | ||
| "Check synonyms set operations - with manage_search_synonyms privilege": | ||
| - do: | ||
| headers: { Authorization: "Basic c3lub255bXMtdXNlcjpzeW5vbnltcy11c2VyLXBhc3N3b3Jk" } # synonyms-user | ||
| synonyms.put: | ||
| synonyms_set: test-synonyms | ||
| body: | ||
| synonyms_set: | ||
| - synonyms: "hello, hi" | ||
| id: "test-id" | ||
|
|
||
| - match: { result: "created" } | ||
|
|
||
| - do: | ||
| headers: { Authorization: "Basic c3lub255bXMtdXNlcjpzeW5vbnltcy11c2VyLXBhc3N3b3Jk" } # synonyms-user | ||
| synonyms.get: | ||
| synonyms_set: test-synonyms | ||
|
|
||
| - match: | ||
| count: 1 | ||
|
|
||
| - do: | ||
| headers: { Authorization: "Basic c3lub255bXMtdXNlcjpzeW5vbnltcy11c2VyLXBhc3N3b3Jk" } # synonyms-user | ||
| synonyms_sets.get: { } | ||
|
|
||
| - match: | ||
| count: 1 | ||
|
|
||
| - do: | ||
| headers: { Authorization: "Basic c3lub255bXMtdXNlcjpzeW5vbnltcy11c2VyLXBhc3N3b3Jk" } # synonyms-user | ||
| synonym_rule.put: | ||
| synonyms_set: "test-synonyms" | ||
| synonym_rule: "test-id-0" | ||
| body: | ||
| synonyms: "i-phone, iphone" | ||
|
|
||
| - match: { result: "created" } | ||
|
|
||
| - do: | ||
| headers: { Authorization: "Basic c3lub255bXMtdXNlcjpzeW5vbnltcy11c2VyLXBhc3N3b3Jk" } # synonyms-user | ||
| synonym_rule.get: | ||
| synonyms_set: "test-synonyms" | ||
| synonym_rule: "test-id-0" | ||
|
|
||
| - match: {id: "test-id-0"} | ||
|
|
||
| - do: | ||
| headers: { Authorization: "Basic c3lub255bXMtdXNlcjpzeW5vbnltcy11c2VyLXBhc3N3b3Jk" } # synonyms-user | ||
| synonym_rule.delete: | ||
| synonyms_set: test-synonyms | ||
| synonym_rule: test-id-0 | ||
|
|
||
| - do: | ||
| headers: { Authorization: "Basic c3lub255bXMtdXNlcjpzeW5vbnltcy11c2VyLXBhc3N3b3Jk" } # synonyms-user | ||
| synonyms.delete: | ||
| synonyms_set: test-synonyms | ||
|
|
||
| - match: | ||
| acknowledged: true | ||
93 changes: 93 additions & 0 deletions
93
...mlRestTest/resources/rest-api-spec/test/synonyms_privileges/20_synonyms_no_privileges.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| setup: | ||
| - skip: | ||
| features: headers | ||
| version: " - 8.9.99" | ||
| reason: Introduced in 8.10.0 | ||
|
|
||
| - do: | ||
| security.put_user: | ||
| username: "non-synonyms-user" | ||
| body: | ||
| password: "non-synonyms-user-password" | ||
| roles : [ "non-synonyms-role" ] | ||
|
|
||
| - do: | ||
| security.put_role: | ||
| name: "non-synonyms-role" | ||
| body: | ||
| indices: | ||
| - names: ["*"] | ||
| privileges: [ "manage", "write", "read" ] | ||
| --- | ||
| teardown: | ||
| - do: | ||
| security.delete_user: | ||
| username: "non-synonyms-user" | ||
| ignore: 404 | ||
| - do: | ||
| security.delete_role: | ||
| name: "non-synonyms-role" | ||
| ignore: 404 | ||
|
|
||
| --- | ||
| "Create synonyms set - no manage_search_synonyms privilege": | ||
| - do: | ||
| catch: "forbidden" | ||
| headers: { Authorization: "Basic bm9uLXN5bm9ueW1zLXVzZXI6bm9uLXN5bm9ueW1zLXVzZXItcGFzc3dvcmQ=" } # non-synonyms-user | ||
| synonyms.put: | ||
| synonyms_set: test-synonyms | ||
| body: | ||
| synonyms_set: | ||
| - synonyms: "hello, hi" | ||
| id: "test-id" | ||
|
|
||
| --- | ||
| "Get synonyms set - no manage_search_synonyms privilege": | ||
| - do: | ||
| catch: "forbidden" | ||
| headers: { Authorization: "Basic bm9uLXN5bm9ueW1zLXVzZXI6bm9uLXN5bm9ueW1zLXVzZXItcGFzc3dvcmQ=" } # non-synonyms-user | ||
| synonyms.get: | ||
| synonyms_set: test-synonyms | ||
|
|
||
| --- | ||
| "Delete synonyms set - no manage_search_synonyms privilege": | ||
| - do: | ||
| catch: "forbidden" | ||
| headers: { Authorization: "Basic bm9uLXN5bm9ueW1zLXVzZXI6bm9uLXN5bm9ueW1zLXVzZXItcGFzc3dvcmQ=" } # non-synonyms-user | ||
| synonyms.delete: | ||
| synonyms_set: test-synonyms | ||
| --- | ||
| "List synonyms sets - no manage_search_synonyms privilege": | ||
| - do: | ||
| catch: "forbidden" | ||
| headers: { Authorization: "Basic bm9uLXN5bm9ueW1zLXVzZXI6bm9uLXN5bm9ueW1zLXVzZXItcGFzc3dvcmQ=" } # non-synonyms-user | ||
| synonyms_sets.get: { } | ||
|
|
||
| --- | ||
| "Update a synonyms rule - no manage_search_synonyms privilege": | ||
| - do: | ||
| catch: "forbidden" | ||
| headers: { Authorization: "Basic bm9uLXN5bm9ueW1zLXVzZXI6bm9uLXN5bm9ueW1zLXVzZXItcGFzc3dvcmQ=" } # non-synonyms-user | ||
| synonym_rule.put: | ||
| synonyms_set: "test-synonyms" | ||
| synonym_rule: "test-id-2" | ||
| body: | ||
| synonyms: "bye, goodbye, seeya" | ||
|
|
||
| --- | ||
| "Get a synonym rule - no manage_search_synonyms privilege": | ||
| - do: | ||
| catch: "forbidden" | ||
| headers: { Authorization: "Basic bm9uLXN5bm9ueW1zLXVzZXI6bm9uLXN5bm9ueW1zLXVzZXItcGFzc3dvcmQ=" } # non-synonyms-user | ||
| synonym_rule.get: | ||
| synonyms_set: "test-synonyms" | ||
| synonym_rule: "test-id-2" | ||
|
|
||
| --- | ||
| "Delete synonym rule - no manage_search_synonyms privilege": | ||
| - do: | ||
| catch: "forbidden" | ||
| headers: { Authorization: "Basic bm9uLXN5bm9ueW1zLXVzZXI6bm9uLXN5bm9ueW1zLXVzZXItcGFzc3dvcmQ=" } # non-synonyms-user | ||
| synonym_rule.delete: | ||
| synonyms_set: test-synonyms | ||
| synonym_rule: test-id-2 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice test organization 👍