* Add test for APM beats index perms * Grant monitoring index privs to apm_system user * Review feedback * Fix compilation problem
This commit is contained in:
parent
ac2774c9fa
commit
549b103458
|
@ -148,7 +148,12 @@ public class ReservedRolesStore implements BiConsumer<Set<String>, ActionListene
|
||||||
},
|
},
|
||||||
null, MetadataUtils.DEFAULT_RESERVED_METADATA))
|
null, MetadataUtils.DEFAULT_RESERVED_METADATA))
|
||||||
.put(UsernamesField.APM_ROLE, new RoleDescriptor(UsernamesField.APM_ROLE,
|
.put(UsernamesField.APM_ROLE, new RoleDescriptor(UsernamesField.APM_ROLE,
|
||||||
new String[] { "monitor", MonitoringBulkAction.NAME}, null, null, MetadataUtils.DEFAULT_RESERVED_METADATA))
|
new String[] { "monitor", MonitoringBulkAction.NAME},
|
||||||
|
new RoleDescriptor.IndicesPrivileges[]{
|
||||||
|
RoleDescriptor.IndicesPrivileges.builder()
|
||||||
|
.indices(".monitoring-beats-*").privileges("create_index", "create_doc").build()
|
||||||
|
},
|
||||||
|
null, MetadataUtils.DEFAULT_RESERVED_METADATA))
|
||||||
.put("apm_user", new RoleDescriptor("apm_user",
|
.put("apm_user", new RoleDescriptor("apm_user",
|
||||||
null, new RoleDescriptor.IndicesPrivileges[] {
|
null, new RoleDescriptor.IndicesPrivileges[] {
|
||||||
RoleDescriptor.IndicesPrivileges.builder().indices("apm-*")
|
RoleDescriptor.IndicesPrivileges.builder().indices("apm-*")
|
||||||
|
|
|
@ -892,7 +892,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
||||||
|
|
||||||
|
|
||||||
final String index = ".monitoring-beats-" + randomIntBetween(0, 5);;
|
final String index = ".monitoring-beats-" + randomIntBetween(0, 5);;
|
||||||
logger.info("index name [{}]", index);
|
logger.info("beats monitoring index name [{}]", index);
|
||||||
assertThat(beatsSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test("foo"), is(false));
|
assertThat(beatsSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test("foo"), is(false));
|
||||||
assertThat(beatsSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(".reporting"), is(false));
|
assertThat(beatsSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(".reporting"), is(false));
|
||||||
assertThat(beatsSystemRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)),
|
assertThat(beatsSystemRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)),
|
||||||
|
@ -930,7 +930,20 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
||||||
assertThat(APMSystemRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)),
|
assertThat(APMSystemRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)),
|
||||||
is(false));
|
is(false));
|
||||||
|
|
||||||
|
final String index = ".monitoring-beats-" + randomIntBetween(10, 15);
|
||||||
|
logger.info("APM beats monitoring index name [{}]", index);
|
||||||
|
|
||||||
|
assertThat(APMSystemRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(true));
|
||||||
|
assertThat(APMSystemRole.indices().allowedIndicesMatcher("indices:data/write/index:op_type/create").test(index), is(true));
|
||||||
|
assertThat(APMSystemRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(index), is(false));
|
||||||
|
assertThat(APMSystemRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(index), is(true));
|
||||||
|
|
||||||
|
assertThat(APMSystemRole.indices().allowedIndicesMatcher("indices:data/write/index:op_type/index").test(index), is(false));
|
||||||
|
assertThat(APMSystemRole.indices().allowedIndicesMatcher(
|
||||||
|
"indices:data/write/index:op_type/" + randomAlphaOfLengthBetween(3,5)).test(index), is(false));
|
||||||
|
|
||||||
assertNoAccessAllowed(APMSystemRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
assertNoAccessAllowed(APMSystemRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAPMUserRole() {
|
public void testAPMUserRole() {
|
||||||
|
|
Loading…
Reference in New Issue