-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Set metadata on initial request in API key noop test #88507
Conversation
Pinging @elastic/es-security (Team:Security) |
@elasticmachine run elasticsearch-ci/bwc |
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 am not sure whether this is the right fix. The failure occurs at line 1805:
Line 1805 in baadfb9
assertTrue(response.isUpdated()); |
The associated updateRequest is prepared to have a non-null metadata and also not the same as the initial metadata at line 1801:
Line 1801 in baadfb9
randomValueOtherThanMany(md -> md == null || md.equals(initialRequest.getMetadata()), ApiKeyTests::randomMetadata) |
So why forcing a non-null initial metadata would help?
Also, I think the following random logic is incorrect:
Lines 1774 to 1781 in baadfb9
randomValueOtherThanMany( | |
rd -> (RoleDescriptorRequestValidator.validate(rd) != null) && initialRequest.getRoleDescriptors().contains(rd) == false, | |
() -> RoleDescriptorTests.randomRoleDescriptor(false) | |
), | |
randomValueOtherThanMany( | |
rd -> (RoleDescriptorRequestValidator.validate(rd) != null) && initialRequest.getRoleDescriptors().contains(rd) == false, | |
() -> RoleDescriptorTests.randomRoleDescriptor(false) | |
) |
We want it the new descriptor to be (1) valid and (2) not contained by the initial descriptors. So I think it should be something like the follows?
randomValueOtherThanMany(
rd -> RoleDescriptorRequestValidator.validate(rd) != null || initialRequest.getRoleDescriptors().contains(rd),
() -> RoleDescriptorTests.randomRoleDescriptor(false)
),
If Suppose: created.metadata = |
Absolutely, De Morgan's law! Thanks for catching will fix. |
Thanks for the explanation. I forgot about there is the initial creation! |
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.
LGTM
@elasticmachine run elasticsearch-ci/part-1 |
* upstream/master: (2974 commits) Reserved cluster state service (elastic#88527) Add transport action immutable state checks (elastic#88491) Remove suggest flag from index stats docs (elastic#85479) Polling cluster formation state for master-is-stable health indicator (elastic#88397) Add test execution guide in yamlRestTest asciidoc (elastic#88490) Add troubleshooting guide for corrupt repository (elastic#88391) [Transform] Finetune Schedule to be less noisy on retry and retry slower (elastic#88531) Updatable API keys - auto-update legacy RDs (elastic#88514) Fix typo in TransportForceMergeAction and TransportClearIndicesCacheA… (elastic#88064) Fixed NullPointerException on bulk request (elastic#88358) Avoid needless index metadata builders during reroute (elastic#88506) Set metadata on request in API key noop test (elastic#88507) Fix passing positional args to ES in Docker (elastic#88502) Improve description for task api detailed param (elastic#88493) Support cartesian shape with doc values (elastic#88487) Promote usage of Subjects in Authentication class (elastic#88494) Add CCx 2.0 feature flag (elastic#88451) Reword the watcher 'always' and 'never' condition docs (elastic#86105) Simplify azure discovery installation docs (elastic#88404) Breakup FIPS CI testing jobs ... # Conflicts: # server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java # x-pack/plugin/mapper-aggregate-metric/src/main/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
This PR fixes API key integration test setup for noops. In the noop
test, we use the initial update request as a reference to choose
suitable values to force non-noop updates, including metadata. However,
metadata can be
null
on the initial request, meaning that theunderlying API key will retain the metadata it was assigned on
creation. This can lead to test failure when the metadata on the
initial request is
null
, and the subsequent metadata update matchesthe metadata chosen at API key creation time.
Closes #88503.