forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
211 additions
and
2 deletions.
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
64 changes: 64 additions & 0 deletions
64
...on/src/yamlRestTest/java/org/elasticsearch/validation/DotPrefixClientYamlTestSuiteIT.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,64 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
package org.elasticsearch.validation; | ||
|
||
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; | ||
|
||
import org.elasticsearch.common.settings.SecureString; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.util.concurrent.ThreadContext; | ||
import org.elasticsearch.test.cluster.ElasticsearchCluster; | ||
import org.elasticsearch.test.cluster.local.LocalClusterSpecBuilder; | ||
import org.elasticsearch.test.cluster.local.distribution.DistributionType; | ||
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; | ||
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; | ||
import org.junit.ClassRule; | ||
|
||
import static org.elasticsearch.test.cluster.FeatureFlag.FAILURE_STORE_ENABLED; | ||
|
||
public class DotPrefixClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { | ||
|
||
public DotPrefixClientYamlTestSuiteIT(final ClientYamlTestCandidate testCandidate) { | ||
super(testCandidate); | ||
} | ||
|
||
@ParametersFactory | ||
public static Iterable<Object[]> parameters() throws Exception { | ||
return createParameters(); | ||
} | ||
|
||
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(); | ||
} | ||
|
||
@ClassRule | ||
public static ElasticsearchCluster cluster = createCluster(); | ||
|
||
private static ElasticsearchCluster createCluster() { | ||
LocalClusterSpecBuilder<ElasticsearchCluster> clusterBuilder = ElasticsearchCluster.local() | ||
.distribution(DistributionType.DEFAULT) | ||
.feature(FAILURE_STORE_ENABLED) | ||
.setting("xpack.security.enabled", "true") | ||
.keystore("bootstrap.password", "x-pack-test-password") | ||
.user("x_pack_rest_user", "x-pack-test-password"); | ||
boolean setNodes = Boolean.parseBoolean(System.getProperty("yaml.rest.tests.set_num_nodes", "true")); | ||
if (setNodes) { | ||
clusterBuilder.nodes(2); | ||
} | ||
return clusterBuilder.build(); | ||
} | ||
|
||
@Override | ||
protected String getTestRestCluster() { | ||
return cluster.getHttpAddresses(); | ||
} | ||
|
||
} |
139 changes: 139 additions & 0 deletions
139
...t-prefix-validation/src/yamlRestTest/resources/rest-api-spec/test/dot_prefix/10_basic.yml
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,139 @@ | ||
--- | ||
"Index creation with a dot-prefix is deprecated unless x-elastic-product-origin set": | ||
- requires: | ||
test_runner_features: ["warnings", "warnings_regex", "headers"] | ||
|
||
- do: | ||
warnings: | ||
- "Index [.myindex] name begins with a dot (.), which is deprecated, and will not be allowed in a future Elasticsearch version." | ||
- "index name [.myindex] starts with a dot '.', in the next major version, index names starting with a dot are reserved for hidden indices and system indices" | ||
indices.create: | ||
index: .myindex | ||
|
||
- do: | ||
headers: { x-elastic-product-origin: kibana } | ||
warnings: | ||
- "index name [.myindex2] starts with a dot '.', in the next major version, index names starting with a dot are reserved for hidden indices and system indices" | ||
indices.create: | ||
index: .myindex2 | ||
|
||
- do: | ||
warnings_regex: | ||
- "Index \\[.*\\] name begins with a dot \\(\\.\\), which is deprecated, and will not be allowed in a future Elasticsearch version\\." | ||
- "index name \\[.*\\] starts with a dot '\\.', in the next major version, index names starting with a dot are reserved for hidden indices and system indices" | ||
indices.create: | ||
index: <.myindex-{now/d}> | ||
|
||
--- | ||
"Reject auto-creation of dot-prefixed indices": | ||
- requires: | ||
test_runner_features: ["warnings", "headers"] | ||
|
||
- do: | ||
warnings: | ||
- "Index [.myindex] name begins with a dot (.), which is deprecated, and will not be allowed in a future Elasticsearch version." | ||
- "index name [.myindex] starts with a dot '.', in the next major version, index names starting with a dot are reserved for hidden indices and system indices" | ||
index: | ||
index: .myindex | ||
id: "1" | ||
body: {foo: bar} | ||
|
||
- do: | ||
warnings: | ||
- "Index [.myindex3] name begins with a dot (.), which is deprecated, and will not be allowed in a future Elasticsearch version." | ||
- "index name [.myindex3] starts with a dot '.', in the next major version, index names starting with a dot are reserved for hidden indices and system indices" | ||
bulk: | ||
body: | ||
- index: | ||
_index: other | ||
- message: foo | ||
- index: | ||
_index: .myindex3 | ||
- message: foo | ||
|
||
--- | ||
"Reject auto-creation of dot-prefixed indices through pipelines": | ||
- requires: | ||
test_runner_features: ["warnings", "headers"] | ||
|
||
- do: | ||
ingest.put_pipeline: | ||
id: mypipeline | ||
body: > | ||
{ | ||
"processors": [ | ||
{ | ||
"set" : { | ||
"field" : "_index", | ||
"value": "{{redirect_to}}" | ||
} | ||
} | ||
] | ||
} | ||
- do: | ||
warnings: | ||
- "Index [.other] name begins with a dot (.), which is deprecated, and will not be allowed in a future Elasticsearch version." | ||
- "index name [.other] starts with a dot '.', in the next major version, index names starting with a dot are reserved for hidden indices and system indices" | ||
index: | ||
index: myindex | ||
id: "1" | ||
body: {redirect_to: ".other"} | ||
pipeline: mypipeline | ||
|
||
- do: | ||
warnings: | ||
- "Index [.other2] name begins with a dot (.), which is deprecated, and will not be allowed in a future Elasticsearch version." | ||
- "index name [.other2] starts with a dot '.', in the next major version, index names starting with a dot are reserved for hidden indices and system indices" | ||
bulk: | ||
body: | ||
- index: | ||
_index: other | ||
- message: foo | ||
- index: | ||
_index: myindex | ||
pipeline: mypipeline | ||
- redirect_to: .other2 | ||
|
||
- do: | ||
index: | ||
index: original | ||
id: "1" | ||
body: { "redirect_to": ".other3" } | ||
- do: | ||
indices.refresh: {} | ||
- do: | ||
warnings: | ||
- "Index [.other3] name begins with a dot (.), which is deprecated, and will not be allowed in a future Elasticsearch version." | ||
- "index name [.other3] starts with a dot '.', in the next major version, index names starting with a dot are reserved for hidden indices and system indices" | ||
reindex: | ||
body: | ||
source: | ||
index: original | ||
dest: | ||
index: newindex | ||
pipeline: mypipeline | ||
|
||
- do: | ||
warnings: | ||
- "Index [.reindex] name begins with a dot (.), which is deprecated, and will not be allowed in a future Elasticsearch version." | ||
- "index name [.reindex] starts with a dot '.', in the next major version, index names starting with a dot are reserved for hidden indices and system indices" | ||
reindex: | ||
body: | ||
source: | ||
index: original | ||
dest: | ||
index: .reindex | ||
|
||
--- | ||
"Reject index template that has a dot prefix index pattern": | ||
- requires: | ||
test_runner_features: ["warnings", "headers"] | ||
|
||
- do: | ||
warnings: | ||
- "Index [.data-*] name begins with a dot (.), which is deprecated, and will not be allowed in a future Elasticsearch version." | ||
indices.put_index_template: | ||
name: my-template | ||
body: | ||
index_patterns: [regular, .data-*] | ||
data_stream: {} |