-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Support metadata on API keys #70292
Merged
+732
−229
Merged
Support metadata on API keys #70292
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
38902a9
wip
ywangd a5a52b1
working on tests
ywangd b0e5134
doc and yaml tests
ywangd bea4844
update on client side code
ywangd 16db065
fix tests
ywangd be989be
Merge remote-tracking branch 'origin/master' into es-48182-api-key-me…
ywangd 126de75
remove changes to setsecurityuser processor
ywangd c0a2456
refactor
ywangd 0bedaa0
fix test
ywangd 28d0e28
fix tests
ywangd 9030640
Update tests for HLRC
ywangd bbef321
Merge remote-tracking branch 'origin/master' into es-48182-api-key-me…
ywangd c9a6667
Address feedback
ywangd 0d6b0c2
checkstyle
ywangd 6871ab6
Merge remote-tracking branch 'origin/master' into es-48182-api-key-me…
ywangd d05d1f9
Fix test
ywangd fb53e14
address feedback
ywangd 8f60cd3
Merge remote-tracking branch 'origin/master' into es-48182-api-key-me…
ywangd 691b350
tweak
ywangd 39c0f6a
fix tests
ywangd 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
refactor
commit c0a2456eae2ee2f179d7470df3a9e3dffb6345b5
There are no files selected for viewing
This file contains 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 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 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 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
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.
This seems weird. Everything else in this method is provided by the caller, but the metadata is randomly generated and returned.
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.
I thought about letting callers pass it in, but then realised the callers were just going to pass
ApiKeyTests.randomMetadata()
anyway because there is no place where the metadata needs to be more specific. So instead of changing every call sites, I just added it here as an easy change.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.
It feels like we accumulating debt - we don't really know what we want our test-object-creation strategy to be, so we have a weird mix.
I don't know what the answer is, but I think this is a sign we're doing something wrong.
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.
I think this is true for the
metadata
field, at least for now. But it has a reasonable explanation. The metadata currently really does not do much other than being stored literally and retrieved literally. Therefore a simple random is sufficient for existing tests. We will need a better strategy when the metadata is searchable. When that happens, we will need to craft the metadata more specifically because we need to search for specific things. I think this can wait till we start working on the metadata search part.The existing
createApiKeys
methods are also aligned with the above reasoning. We currently have five of them:createApiKeys(int noOfApiKeys, TimeValue expiration)
createApiKeys(String user, int noOfApiKeys, TimeValue expiration, String... clusterPrivileges)
createApiKeys(String owningUser, String authenticatingUser, int noOfApiKeys, TimeValue expiration, String... clusterPrivileges)
createApiKeys(Map<String, String> headers, int noOfApiKeys, TimeValue expiration, String... clusterPrivileges)
createApiKeys(Map<String, String> headers, int noOfApiKeys, String namePrefix, TimeValue expiration, String... clusterPrivileges)
They are listed roughly in the order of delegation (or increasing complexity), i.e. (1) calls (2), (2) call (3), etc. For the more generic variation, say (1), it basically randomly chooses most of the attributes for an API key, while the more specific variation, (5), gets to specify many of the attributes. It is also where the
metadata
is currently randomised because the existing tests do not care about the exact content of metadata. When we start working on the metadata search, I imagine we can add a 6th variation ofcreateApiKeys
so it takes the metadata as an argument, i.e.:createApiKeys(Map<String, String> headers, int noOfApiKeys, String namePrefix, TimeValue expiration, Map<String, Object> metadata, String... clusterPrivileges)
and current variation (5) will delegate its call to (6).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.
I think we have a smell - the ApiKeyIntegTests are a bit weirdly stuck together, and would benefit from having some structured thinking about what they're trying to achieve and how best to do that.
I think that's a separate issue though.