-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace the disabled stack templates yaml test with java rest test (#…
- Loading branch information
Showing
2 changed files
with
59 additions
and
22 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
.../plugin/core/src/javaRestTest/java/org/elasticsearch/xpack/core/StackTemplatesRestIT.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
package org.elasticsearch.xpack.core; | ||
|
||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.ResponseException; | ||
import org.elasticsearch.client.RestClient; | ||
import org.elasticsearch.common.settings.SecureString; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.util.concurrent.ThreadContext; | ||
import org.elasticsearch.test.rest.ESRestTestCase; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
|
||
public class StackTemplatesRestIT extends ESRestTestCase { | ||
|
||
private static final String BASIC_AUTH_VALUE = basicAuthHeaderValue("x_pack_rest_user", new SecureString("x-pack-test-password")); | ||
|
||
@Override | ||
protected Settings restClientSettings() { | ||
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", BASIC_AUTH_VALUE).build(); | ||
} | ||
|
||
public void testTemplatesCanBeDisabled() throws Exception { | ||
RestClient client = client(); | ||
// Ensure the logs template has been added | ||
assertBusy(() -> { | ||
try { | ||
Request request = new Request("GET", "_index_template/logs"); | ||
assertOK(client.performRequest(request)); | ||
} catch (ResponseException e) { | ||
fail(e.getMessage()); | ||
} | ||
}); | ||
// Disable the stack templates | ||
{ | ||
Request request = new Request("PUT", "_cluster/settings"); | ||
request.setJsonEntity(""" | ||
{ | ||
"persistent": { | ||
"stack.templates.enabled": false | ||
} | ||
} | ||
"""); | ||
assertOK(client.performRequest(request)); | ||
} | ||
Request getRequest = new Request("GET", "_index_template/logs"); | ||
assertOK(client.performRequest(getRequest)); | ||
|
||
Request deleteRequest = new Request("DELETE", "_index_template/logs"); | ||
assertOK(client.performRequest(deleteRequest)); | ||
ResponseException exception = expectThrows(ResponseException.class, () -> client.performRequest(deleteRequest)); | ||
assertThat(exception.getResponse().getStatusLine().getStatusCode(), is(404)); | ||
} | ||
} |
22 changes: 0 additions & 22 deletions
22
...rest-tests-with-security/src/yamlRestTest/resources/rest-api-spec/test/stack/10_stack.yml
This file was deleted.
Oops, something went wrong.