Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
1f1f841
Enable queryable built-in roles feature by default
slobodanadamovic Jan 16, 2025
71dff22
fix ReadActionsTests
slobodanadamovic Jan 17, 2025
1fadace
fix FleetDataStreamIT
slobodanadamovic Jan 17, 2025
d4a7f19
fix WriteActionsTests
slobodanadamovic Jan 17, 2025
aa23217
fix PermissionPrecedenceTests
slobodanadamovic Jan 17, 2025
be5fedc
really fix PermissionPrecedenceTests
slobodanadamovic Jan 17, 2025
5ae202b
handle 'node closed' exception as expected
slobodanadamovic Jan 20, 2025
c00c82b
fix role yaml tests
slobodanadamovic Jan 20, 2025
f9d550d
do not delete `.security-*` indices in DotPrefixClientYamlTestSuiteIT
slobodanadamovic Jan 20, 2025
0bdf414
fix docs tests
slobodanadamovic Jan 20, 2025
68b1431
do no include feature states in snapshot doc tests
slobodanadamovic Jan 20, 2025
43bcf32
Merge branch 'main' of github.com:elastic/elasticsearch into sa-defau…
slobodanadamovic Jan 20, 2025
c3e0f5a
revert docs change and disable queryable feature
slobodanadamovic Jan 20, 2025
ecb1d90
revert snapshot docs changes
slobodanadamovic Jan 20, 2025
a49b86b
increase number of retries
slobodanadamovic Jan 20, 2025
d5b5cd7
temporary disable queryable for core and rest compatibility tests
slobodanadamovic Jan 20, 2025
d1c46e0
no need to create security index - avoids resource already exists exc…
slobodanadamovic Jan 20, 2025
864bbb4
Merge branch 'main' of github.com:elastic/elasticsearch into sa-defau…
slobodanadamovic Jan 20, 2025
db933e1
handle resource already exists revert other changes
slobodanadamovic Jan 20, 2025
eff001d
fix IpFilteringIntegrationTests
slobodanadamovic Jan 20, 2025
86dbcd3
ignore reserved roles
slobodanadamovic Jan 20, 2025
353191b
spotless
slobodanadamovic Jan 20, 2025
0d2c32b
ignore reserved roles in LicenseDLSFLSRoleIT
slobodanadamovic Jan 20, 2025
6c7cd5b
wait for active security index
slobodanadamovic Jan 20, 2025
122a0c3
fix testAnonymousUserFromQueryClusterWorks
slobodanadamovic Jan 20, 2025
ce64c85
Merge branch 'main' of github.com:elastic/elasticsearch into sa-defau…
slobodanadamovic Jan 21, 2025
2a5968b
wait for migration before searching
slobodanadamovic Jan 21, 2025
ec6b390
fix ReservedRealmElasticAutoconfigIntegTests
slobodanadamovic Jan 21, 2025
7e10d30
disable queryable built-in roles feature for rest compatibility tests
slobodanadamovic Jan 21, 2025
ce66ed1
revert changes to ReservedRealmElasticAutoconfigIntegTests
slobodanadamovic Jan 21, 2025
2f0d846
user reset password instead of setup
slobodanadamovic Jan 21, 2025
5ede368
revert change
slobodanadamovic Jan 21, 2025
6585c22
Merge branch 'main' of github.com:elastic/elasticsearch into sa-defau…
slobodanadamovic Jan 21, 2025
8803225
Merge branch 'main' into sa-default-enable-queryable-built-in-roles-f…
slobodanadamovic Jan 21, 2025
ef8e159
enable feature in core and adjust single failing test
slobodanadamovic Jan 21, 2025
31d78a7
Merge branch 'main' of github.com:elastic/elasticsearch into sa-defau…
slobodanadamovic Jan 21, 2025
42ff42f
attempt to fix PasswordToolsTests by waiting for green health
slobodanadamovic Jan 21, 2025
36bc5d8
disable yamlRestCompatTest for XPackCoreClientYamlTestSuiteIT
slobodanadamovic Jan 21, 2025
6cd2425
increase docker timeout for waiting on security index
slobodanadamovic Jan 21, 2025
fa2a29b
fix tests
slobodanadamovic Jan 21, 2025
2bc36cb
fix testNewIndexSkipMigration
slobodanadamovic Jan 21, 2025
b05408d
fix testSimpleQueryAllRoles
slobodanadamovic Jan 21, 2025
e24c6e6
move deletion later
slobodanadamovic Jan 21, 2025
b47523e
Merge branch 'main' of github.com:elastic/elasticsearch into sa-defau…
slobodanadamovic Jan 22, 2025
ee42e42
disable feature for flaky integ tests
slobodanadamovic Jan 22, 2025
0eab0b7
suppress forbidden apis
slobodanadamovic Jan 22, 2025
bcb29f9
[CI] Auto commit changes from spotless
Jan 22, 2025
8707455
spotless
slobodanadamovic Jan 22, 2025
4b76919
increase timeout
slobodanadamovic Jan 22, 2025
4b85915
Merge branch 'sa-default-enable-queryable-built-in-roles-feature' of …
slobodanadamovic Jan 22, 2025
edf4d77
Merge branch 'main' of github.com:elastic/elasticsearch into sa-defau…
slobodanadamovic Jan 22, 2025
3279bdb
change the approach to go with the retry on unavailable security shard
slobodanadamovic Jan 22, 2025
0b2b151
remove await for security migration
slobodanadamovic Jan 22, 2025
55d3055
remove in other places
slobodanadamovic Jan 22, 2025
5c76728
Merge branch 'main' of github.com:elastic/elasticsearch into sa-defau…
slobodanadamovic Jan 22, 2025
09924df
use ServerUtils wait method and reduce the increased timeout
slobodanadamovic Jan 22, 2025
637fc5f
Merge branch 'main' of github.com:elastic/elasticsearch into sa-defau…
slobodanadamovic Jan 22, 2025
4fb3493
Merge branch 'main' of github.com:elastic/elasticsearch into sa-defau…
slobodanadamovic Jan 22, 2025
df0e17b
retry on 401
slobodanadamovic Jan 22, 2025
25987ad
Merge branch 'main' into sa-default-enable-queryable-built-in-roles-f…
slobodanadamovic Jan 22, 2025
e389c3e
make retry logic generic to retry on failing command results as well
slobodanadamovic Jan 23, 2025
1db9511
avoid getting .security alias
slobodanadamovic Jan 23, 2025
c94a637
handle ShellException with authentication failure result in message
slobodanadamovic Jan 23, 2025
0f347b3
throw on interrupted exceptions
slobodanadamovic Jan 23, 2025
6c57650
revert changes to ReservedRealmElasticAutoconfigIntegTests and move the
slobodanadamovic Jan 24, 2025
aa38644
retry test40GeneratePasswordsBootstrapAlreadySet on auth failures
slobodanadamovic Jan 24, 2025
adcbb0f
Merge branch 'main' of github.com:elastic/elasticsearch into sa-defau…
slobodanadamovic Jan 24, 2025
d458e5d
Merge branch 'main' into sa-default-enable-queryable-built-in-roles-f…
slobodanadamovic Jan 26, 2025
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
2 changes: 2 additions & 0 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ testClusters.matching { it.name == "yamlRestTest"}.configureEach {
// TODO: remove this once cname is prepended to transport.publish_address by default in 8.0
systemProperty 'es.transport.cname_in_publish_address', 'true'

systemProperty 'es.queryable_built_in_roles_enabled', 'false'

requiresFeature 'es.index_mode_feature_flag_registered', Version.fromString("8.0.0")
requiresFeature 'es.failure_store_feature_flag_enabled', Version.fromString("8.12.0")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@
test: {}

- do:
indices.get_alias: { }
indices.get_alias:
index: test*
- match: { test1.aliases.test: { } }
- match: { test2.aliases.test: { } }
- match: { test3.aliases.test: { } }
Expand All @@ -255,7 +256,8 @@
- is_true: acknowledged

- do:
indices.get_alias: {}
indices.get_alias:
index: test*
- match: {test1.aliases: {}}
- match: {test2.aliases: {}}
- match: {test3.aliases: {}}
Expand Down
1 change: 1 addition & 0 deletions modules/dot-prefix-validation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ tasks.named('yamlRestTest') {

tasks.named('yamlRestCompatTest') {
usesDefaultDistribution()
systemProperty 'es.queryable_built_in_roles_enabled', 'false'
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.junit.ClassRule;

import java.util.Objects;

import static org.elasticsearch.test.cluster.FeatureFlag.FAILURE_STORE_ENABLED;

public class DotPrefixClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
Expand Down Expand Up @@ -55,6 +57,10 @@ private static ElasticsearchCluster createCluster() {
if (setNodes) {
clusterBuilder.nodes(2);
}
clusterBuilder.systemProperty("es.queryable_built_in_roles_enabled", () -> {
final String enabled = System.getProperty("es.queryable_built_in_roles_enabled");
return Objects.requireNonNullElse(enabled, "");
});
return clusterBuilder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
teardown:
- do:
indices.delete:
index: .*
index: .*,-.security-*

---
"Index creation with a dot-prefix is deprecated unless x-elastic-product-origin set":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
Expand Down Expand Up @@ -47,7 +48,9 @@ public void test010Install() throws Exception {
public void test20GeneratePasswords() throws Exception {
assertWhileRunning(() -> {
ServerUtils.waitForElasticsearch(installation);
Shell.Result result = installation.executables().setupPasswordsTool.run("auto --batch", null);
Shell.Result result = retryOnAuthenticationErrors(
() -> installation.executables().setupPasswordsTool.run("auto --batch", null)
);
Map<String, String> userpasses = parseUsersAndPasswords(result.stdout());
for (Map.Entry<String, String> userpass : userpasses.entrySet()) {
String response = ServerUtils.makeRequest(
Expand Down Expand Up @@ -102,20 +105,26 @@ public void test30AddBootstrapPassword() throws Exception {
installation.executables().keystoreTool.run("add --stdin bootstrap.password", BOOTSTRAP_PASSWORD);

assertWhileRunning(() -> {
String response = ServerUtils.makeRequest(
Request.Get("http://localhost:9200/_cluster/health?wait_for_status=green&timeout=180s"),
"elastic",
BOOTSTRAP_PASSWORD,
null
ServerUtils.waitForElasticsearch("green", null, installation, "elastic", BOOTSTRAP_PASSWORD, null);
final String response = retryOnAuthenticationErrors(
() -> ServerUtils.makeRequest(
Request.Get("http://localhost:9200/_cluster/health?wait_for_status=green&timeout=180s"),
"elastic",
BOOTSTRAP_PASSWORD,
null
)
);
assertThat(response, containsString("\"status\":\"green\""));
});

}

public void test40GeneratePasswordsBootstrapAlreadySet() throws Exception {
assertWhileRunning(() -> {

Shell.Result result = installation.executables().setupPasswordsTool.run("auto --batch", null);
ServerUtils.waitForElasticsearch("green", null, installation, "elastic", BOOTSTRAP_PASSWORD, null);
Shell.Result result = retryOnAuthenticationErrors(
() -> installation.executables().setupPasswordsTool.run("auto --batch", null)
);
Map<String, String> userpasses = parseUsersAndPasswords(result.stdout());
assertThat(userpasses, hasKey("elastic"));
for (Map.Entry<String, String> userpass : userpasses.entrySet()) {
Expand All @@ -130,6 +139,48 @@ public void test40GeneratePasswordsBootstrapAlreadySet() throws Exception {
});
}

/**
* The security index is created on startup.
* It can happen that even when the security index exists, we get an authentication failure as `elastic`
* user because the reserved realm checks the security index first.
* This is because we check the security index too early (just after the creation) when all shards did not get allocated yet.
* Hence, the call can result in an `UnavailableShardsException` and cause the authentication to fail.
* We retry here on authentication errors for a couple of seconds just to verify that this is not the case.
*/
private <R> R retryOnAuthenticationErrors(final Callable<R> callable) throws Exception {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retrying here because the calls would have succeeded if we just waited a bit longer:

[2025-01-23T00:00:51,232][ERROR][o.e.x.s.a.e.ReservedRealm] failed to retrieve password hash for reserved user [elastic]
org.elasticsearch.action.UnavailableShardsException: at least one primary shard for the index [.security-7] is unavailable
[2025-01-23T00:00:51,237][INFO ][o.e.x.s.a.RealmsAuthenticator] Authentication of [elastic] was terminated by realm [reserved] - failed to authenticate user [elastic]
[2025-01-23T00:00:51,358][INFO ][o.e.c.r.a.AllocationService]  current.health="GREEN" message="Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[.security-7][0]]])." previous.health="YELLOW" reason="shards started [[.security-7][0]]"

Exception failure = null;
int retries = 5;
while (retries-- > 0) {
try {
return callable.call();
} catch (Exception e) {
if (e.getMessage() != null
&& (e.getMessage().contains("401 Unauthorized") || e.getMessage().contains("Failed to authenticate user"))) {
logger.info(
"Authentication failed (possibly due to UnavailableShardsException for the security index), retrying [{}].",
retries,
e
);
if (failure == null) {
failure = e;
} else {
failure.addSuppressed(e);
}
try {
Thread.sleep(1000);
} catch (InterruptedException interrupted) {
Thread.currentThread().interrupt();
failure.addSuppressed(interrupted);
throw failure;
}
} else {
throw e;
}
}
}
throw failure;
}

private Map<String, String> parseUsersAndPasswords(String output) {
Matcher matcher = USERPASS_REGEX.matcher(output);
assertNotNull(matcher);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class ServerUtils {
private static final long waitTime = TimeUnit.MINUTES.toMillis(3);
private static final long timeoutLength = TimeUnit.SECONDS.toMillis(30);
private static final long requestInterval = TimeUnit.SECONDS.toMillis(5);
private static final long dockerWaitForSecurityIndex = TimeUnit.SECONDS.toMillis(25);
private static final long dockerWaitForSecurityIndex = TimeUnit.SECONDS.toMillis(60);

public static void waitForElasticsearch(Installation installation) throws Exception {
final boolean securityEnabled;
Expand Down Expand Up @@ -260,9 +260,7 @@ public static void waitForElasticsearch(
// `elastic` , the reserved realm checks the security index first. It can happen that we check the security index
// too early after the security index creation in DockerTests causing an UnavailableShardsException. We retry
// authentication errors for a couple of seconds just to verify this is not the case.
if (installation.distribution.isDocker()
&& timeElapsed < dockerWaitForSecurityIndex
&& response.getStatusLine().getStatusCode() == 401) {
if (timeElapsed < dockerWaitForSecurityIndex && response.getStatusLine().getStatusCode() == 401) {
logger.info(
"Authentication against docker failed (possibly due to UnavailableShardsException for the security index)"
+ ", retrying..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.store.AlreadyClosedException;
import org.elasticsearch.action.UnavailableShardsException;
import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsRequest;
import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsRequest;
import org.elasticsearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction;
Expand Down Expand Up @@ -146,6 +147,8 @@
import static org.elasticsearch.node.Node.INITIAL_STATE_TIMEOUT_SETTING;
import static org.elasticsearch.test.ESTestCase.TEST_REQUEST_TIMEOUT;
import static org.elasticsearch.test.ESTestCase.assertBusy;
import static org.elasticsearch.test.ESTestCase.assertFalse;
import static org.elasticsearch.test.ESTestCase.assertTrue;
import static org.elasticsearch.test.ESTestCase.randomFrom;
import static org.elasticsearch.test.ESTestCase.runInParallel;
import static org.elasticsearch.test.ESTestCase.safeAwait;
Expand All @@ -160,9 +163,7 @@
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

/**
Expand Down Expand Up @@ -1240,16 +1241,29 @@ public synchronized void validateClusterFormed() {
}
logger.trace("validating cluster formed, expecting {}", expectedNodes);

assertFalse(
client().admin()
.cluster()
.prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes(Integer.toString(expectedNodes.size()))
.get(TimeValue.timeValueSeconds(40))
.isTimedOut()
);
try {
assertBusy(() -> {
try {
final boolean timeout = client().admin()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call may fail when client user has role with application privileges and security index is still not available for searching. See my other #120323 (comment)

.cluster()
.prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes(Integer.toString(expectedNodes.size()))
.get(TimeValue.timeValueSeconds(40))
.isTimedOut();
if (timeout) {
throw new IllegalStateException("timed out waiting for cluster to form");
}
} catch (UnavailableShardsException e) {
if (e.getMessage() != null && e.getMessage().contains(".security")) {
// security index may not be ready yet, throwing assertion error to retry
throw new AssertionError(e);
} else {
throw e;
}
}
}, 30, TimeUnit.SECONDS);

final Object[] previousStates = new Object[1];
assertBusy(() -> {
final List<ClusterState> states = nodes.values()
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,6 @@ tasks.named("yamlRestCompatTestTransform").configure({ task ->

})

tasks.named('yamlRestCompatTest').configure {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only disabling it for yamlRestCompatTest which fail because Query Roles API now returns built-in reserved roles. I will be handling this in a followup after backporting the changes to 8.18.0 branch.

systemProperty 'es.queryable_built_in_roles_enabled', 'false'
}
1 change: 1 addition & 0 deletions x-pack/plugin/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ testClusters.configureEach {
keystore 'bootstrap.password', 'x-pack-test-password'
user username: "x_pack_rest_user", password: "x-pack-test-password"
requiresFeature 'es.failure_store_feature_flag_enabled', Version.fromString("8.15.0")
systemProperty 'es.queryable_built_in_roles_enabled', 'false'
}

if (buildParams.isSnapshotBuild() == false) {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugin/fleet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ testClusters.configureEach {
setting 'xpack.security.enabled', 'true'
setting 'xpack.security.autoconfiguration.enabled', 'false'
user username: 'x_pack_rest_user', password: 'x-pack-test-password'
systemProperty 'es.queryable_built_in_roles_enabled', 'false'
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ protected Settings restAdminSettings() {
.build();
}

@Override
protected boolean preserveSecurityIndicesUponCompletion() {
return true;
}

public void testAliasWithSystemDataStream() throws Exception {
// Create a system data stream
Request initialDocResponse = new Request("POST", ".fleet-actions-results/_doc");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public void testAnonymousUserFromQueryClusterWorks() throws Exception {
{ "password": "%s" }""", PASS));
assertOK(client().performRequest(changePasswordRequest));

final Request elasticUserSearchRequest = new Request("GET", "/*:.security*/_search");
final Request elasticUserSearchRequest = new Request("GET", "/*:.security*/_search?size=1");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We get now more than one result from .security-7 index which are not relevant to assert all of them for this test case. Getting at least one result is enough.

elasticUserSearchRequest.setOptions(
RequestOptions.DEFAULT.toBuilder().addHeader("Authorization", basicAuthHeaderValue("elastic", PASS))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ public void testQueryDLSFLSRolesShowAsDisabled() throws Exception {
.build() };
createRoleWithIndicesPrivileges(adminClient(), "role_with_FLS_and_DLS", indicesPrivileges);
}
assertQuery(client(), "", 4, roles -> {
assertQuery(client(), """
{"query":{"bool":{"must_not":{"term":{"metadata._reserved":true}}}}}""", 4, roles -> {
roles.sort(Comparator.comparing(o -> ((String) o.get("name"))));
assertThat(roles, iterableWithSize(4));
assertThat(roles.get(0).get("name"), equalTo("role_with_DLS"));
Expand All @@ -152,7 +153,8 @@ public void testQueryDLSFLSRolesShowAsDisabled() throws Exception {
assertTrue(((Boolean) responseMap.get("basic_was_started")));
assertTrue(((Boolean) responseMap.get("acknowledged")));
// now the same roles show up as disabled ("enabled" is "false")
assertQuery(client(), "", 4, roles -> {
assertQuery(client(), """
{"query":{"bool":{"must_not":{"term":{"metadata._reserved":true}}}}}""", 4, roles -> {
roles.sort(Comparator.comparing(o -> ((String) o.get("name"))));
assertThat(roles, iterableWithSize(4));
assertThat(roles.get(0).get("name"), equalTo("role_with_DLS"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.xpack.core.security.authz.RoleDescriptor;
import org.elasticsearch.xpack.core.security.authz.RoleDescriptor.ApplicationResourcePrivileges;
import org.elasticsearch.xpack.core.security.authz.store.ReservedRolesStore;
import org.elasticsearch.xpack.security.support.SecurityMigrations;
import org.hamcrest.Matchers;
import org.junit.Before;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -49,15 +51,23 @@ public final class QueryRoleIT extends SecurityInBasicRestTestCase {

private static final String READ_SECURITY_USER_AUTH_HEADER = "Basic cmVhZF9zZWN1cml0eV91c2VyOnJlYWQtc2VjdXJpdHktcGFzc3dvcmQ=";

public void testSimpleQueryAllRoles() throws IOException {
assertQuery("", 0, roles -> assertThat(roles, emptyIterable()));
RoleDescriptor createdRole = createRandomRole();
assertQuery("", 1, roles -> {
assertThat(roles, iterableWithSize(1));
assertRoleMap(roles.get(0), createdRole);
@Before
public void initialize() {
new ReservedRolesStore();
}

public void testSimpleQueryAllRoles() throws Exception {
createRandomRole();
assertQuery("", 1 + ReservedRolesStore.names().size(), roles -> {
// default size is 10
assertThat(roles, iterableWithSize(10));
});
assertQuery("""
{"query":{"match_all":{}},"from":1}""", 1, roles -> assertThat(roles, emptyIterable()));
assertQuery(
Strings.format("""
{"query":{"match_all":{}},"from":%d}""", 1 + ReservedRolesStore.names().size()),
1 + ReservedRolesStore.names().size(),
roles -> assertThat(roles, emptyIterable())
);
}

public void testDisallowedFields() throws Exception {
Expand Down
Loading