-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix to include hidden indices when resolving wildcards (#1488)
(cherry-picked from commit 5a9935a) Signed-off-by: Nidhi Sridhar <[email protected]>
- Loading branch information
Showing
4 changed files
with
57 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
42 changes: 42 additions & 0 deletions
42
src/test/java/com/amazon/opendistroforelasticsearch/security/PrivilegesEvaluationTest.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,42 @@ | ||
package com.amazon.opendistroforelasticsearch.security; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; | ||
import org.elasticsearch.action.index.IndexRequest; | ||
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; | ||
import org.elasticsearch.client.Client; | ||
import org.elasticsearch.common.xcontent.XContentType; | ||
import com.amazon.opendistroforelasticsearch.security.test.SingleClusterTest; | ||
import com.amazon.opendistroforelasticsearch.security.test.helper.rest.RestHelper; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
|
||
public class PrivilegesEvaluationTest extends SingleClusterTest { | ||
@Test | ||
public void resolveTestHidden() throws Exception { | ||
|
||
setup(); | ||
|
||
try (Client client = getInternalTransportClient()) { | ||
|
||
client.index(new IndexRequest("hidden_test_not_hidden").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source(XContentType.JSON, "index", | ||
"hidden_test_not_hidden", "b", "y", "date", "1985/01/01")).actionGet(); | ||
|
||
client.admin().indices().create(new CreateIndexRequest(".hidden_test_actually_hidden").settings(ImmutableMap.of("index.hidden", true))) | ||
.actionGet(); | ||
client.index(new IndexRequest(".hidden_test_actually_hidden").id("test").source("a", "b").setRefreshPolicy(RefreshPolicy.IMMEDIATE)) | ||
.actionGet(); | ||
} | ||
RestHelper rh = nonSslRestHelper(); | ||
RestHelper.HttpResponse httpResponse = rh.executeGetRequest("/*hidden_test*/_search?expand_wildcards=all&pretty=true", | ||
encodeBasicHeader("hidden_test", "nagilum")); | ||
Assert.assertEquals(httpResponse.getBody(), 403, httpResponse.getStatusCode()); | ||
|
||
httpResponse = rh.executeGetRequest("/hidden_test_not_hidden?pretty=true", | ||
encodeBasicHeader("hidden_test", "nagilum")); | ||
Assert.assertEquals(httpResponse.getBody(), 200, httpResponse.getStatusCode()); | ||
} | ||
} | ||
|
||
|
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