Skip to content

Commit 7cbc35f

Browse files
committed
Add/fix tests for internal user for .kibana-reporting data stream
1 parent cdd3935 commit 7cbc35f

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/user/InternalUsersTests.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import static org.elasticsearch.xpack.core.security.test.TestRestrictedIndices.SECURITY_MAIN_ALIAS;
6464
import static org.elasticsearch.xpack.core.security.test.TestRestrictedIndices.SECURITY_TOKENS_ALIAS;
6565
import static org.elasticsearch.xpack.core.security.user.UsernamesField.REINDEX_DATA_STREAM_NAME;
66+
import static org.hamcrest.Matchers.anyOf;
6667
import static org.hamcrest.Matchers.arrayContaining;
6768
import static org.hamcrest.Matchers.equalTo;
6869
import static org.hamcrest.Matchers.hasSize;
@@ -244,10 +245,17 @@ public void testDataStreamLifecycleUser() {
244245
assertThat(role.application(), is(ApplicationPermission.NONE));
245246
assertThat(role.remoteIndices(), is(RemoteIndicesPermission.NONE));
246247

247-
final List<String> allowedSystemDataStreams = Arrays.asList(".fleet-actions-results", ".fleet-fileds*");
248+
final List<String> allowedFleetSystemDataStreams = Arrays.asList(".fleet-actions-results", ".fleet-fileds*");
249+
final List<String> allowedKibanaSystemDataStreams = List.of(".kibana-reporting");
248250
for (var group : role.indices().groups()) {
249251
if (group.allowRestrictedIndices()) {
250-
assertThat(group.indices(), arrayContaining(allowedSystemDataStreams.toArray(new String[0])));
252+
assertThat(
253+
group.indices(),
254+
anyOf(
255+
arrayContaining(allowedFleetSystemDataStreams.toArray(new String[0])),
256+
arrayContaining(allowedKibanaSystemDataStreams.toArray(new String[0]))
257+
)
258+
);
251259
}
252260
}
253261

@@ -290,7 +298,25 @@ public void testDataStreamLifecycleUser() {
290298
true
291299
);
292300

293-
allowedSystemDataStreams.forEach(allowedSystemDataStream -> {
301+
allowedFleetSystemDataStreams.forEach(allowedSystemDataStream -> {
302+
checkIndexAccess(role, randomFrom(sampleSystemDataStreamActions), allowedSystemDataStream, true);
303+
checkIndexAccess(
304+
role,
305+
randomFrom(sampleSystemDataStreamActions),
306+
DataStream.BACKING_INDEX_PREFIX + allowedSystemDataStream + randomAlphaOfLengthBetween(4, 8),
307+
true
308+
);
309+
310+
checkIndexAccess(role, randomFrom(sampleSystemDataStreamActions), allowedSystemDataStream + "::failures", true);
311+
checkIndexAccess(
312+
role,
313+
randomFrom(sampleSystemDataStreamActions),
314+
DataStream.FAILURE_STORE_PREFIX + allowedSystemDataStream + randomAlphaOfLengthBetween(4, 8),
315+
true
316+
);
317+
});
318+
319+
allowedKibanaSystemDataStreams.forEach(allowedSystemDataStream -> {
294320
checkIndexAccess(role, randomFrom(sampleSystemDataStreamActions), allowedSystemDataStream, true);
295321
checkIndexAccess(
296322
role,

0 commit comments

Comments
 (0)