Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -411,17 +411,12 @@ public void testApiKeySuperuser() throws IOException {

// read is ok
final Request searchRequest = new Request("GET", ".security/_search");
// TODO: change the warning expectation to be always once #82837 is fixed
// Configure the warning to be optional due to #82837, it is ok since this test is for something else
searchRequest.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(warnings -> {
if (warnings.isEmpty()) {
return false;
} else if (warnings.size() == 1) {
return false == warnings.get(0).startsWith("this request accesses system indices: [.security-7]");
} else {
return true;
}
}).addHeader("Authorization", apiKeyAuthHeader));
searchRequest.setOptions(
expectWarnings(
"this request accesses system indices: [.security-7], but in a future major "
+ "version, direct access to system indices will be prevented by default"
).toBuilder().addHeader("Authorization", apiKeyAuthHeader)
);
assertOK(client().performRequest(searchRequest));

// write must not be allowed
Expand All @@ -430,7 +425,12 @@ public void testApiKeySuperuser() throws IOException {
{
"doc_type": "foo"
}""");
indexRequest.setOptions(RequestOptions.DEFAULT.toBuilder().addHeader("Authorization", apiKeyAuthHeader));
indexRequest.setOptions(
expectWarnings(
"this request accesses system indices: [.security-7], but in a future major "
+ "version, direct access to system indices will be prevented by default"
).toBuilder().addHeader("Authorization", apiKeyAuthHeader)
);
final ResponseException e = expectThrows(ResponseException.class, () -> client().performRequest(indexRequest));
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(403));
assertThat(e.getMessage(), containsString("is unauthorized"));
Expand Down