|
@@ -200,8 +200,8 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(ReservedRolesStore.isReserved(RemoteMonitoringUser.COLLECTION_ROLE_NAME), is(true));
|
|
|
assertThat(ReservedRolesStore.isReserved(RemoteMonitoringUser.INDEXING_ROLE_NAME), is(true));
|
|
|
assertThat(ReservedRolesStore.isReserved("snapshot_user"), is(true));
|
|
|
- assertThat(ReservedRolesStore.isReserved("code_admin"), is(true));
|
|
|
- assertThat(ReservedRolesStore.isReserved("code_user"), is(true));
|
|
|
+ assertThat(ReservedRolesStore.isReserved("code_admin"), is(false));
|
|
|
+ assertThat(ReservedRolesStore.isReserved("code_user"), is(false));
|
|
|
}
|
|
|
|
|
|
public void testSnapshotUserRole() {
|
|
@@ -1383,60 +1383,4 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(logstashAdminRole.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(index), is(true));
|
|
|
assertThat(logstashAdminRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(index), is(true));
|
|
|
}
|
|
|
-
|
|
|
- public void testCodeAdminRole() {
|
|
|
- RoleDescriptor roleDescriptor = new ReservedRolesStore().roleDescriptor("code_admin");
|
|
|
- assertNotNull(roleDescriptor);
|
|
|
- assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
-
|
|
|
- Role codeAdminRole = Role.builder(roleDescriptor, null).build();
|
|
|
-
|
|
|
- assertThat(codeAdminRole.cluster().check(DelegatePkiAuthenticationAction.NAME, mock(TransportRequest.class),
|
|
|
- mock(Authentication.class)), is(false));
|
|
|
-
|
|
|
- assertThat(codeAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test("foo"), is(false));
|
|
|
- assertThat(codeAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(".reporting"), is(false));
|
|
|
- assertThat(codeAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(".code-"), is(true));
|
|
|
- assertThat(codeAdminRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)),
|
|
|
- is(false));
|
|
|
-
|
|
|
- final String index = ".code-" + randomIntBetween(0, 5);
|
|
|
-
|
|
|
- assertThat(codeAdminRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(index), is(true));
|
|
|
- assertThat(codeAdminRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(true));
|
|
|
- assertThat(codeAdminRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(true));
|
|
|
- assertThat(codeAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(index), is(true));
|
|
|
- assertThat(codeAdminRole.indices().allowedIndicesMatcher(GetAction.NAME).test(index), is(true));
|
|
|
- assertThat(codeAdminRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(index), is(true));
|
|
|
- assertThat(codeAdminRole.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(index), is(true));
|
|
|
- assertThat(codeAdminRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(index), is(true));
|
|
|
- }
|
|
|
-
|
|
|
- public void testCodeUserRole() {
|
|
|
- RoleDescriptor roleDescriptor = new ReservedRolesStore().roleDescriptor("code_user");
|
|
|
- assertNotNull(roleDescriptor);
|
|
|
- assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
-
|
|
|
- Role codeUserRole = Role.builder(roleDescriptor, null).build();
|
|
|
-
|
|
|
- assertThat(codeUserRole.cluster().check(DelegatePkiAuthenticationAction.NAME, mock(TransportRequest.class),
|
|
|
- mock(Authentication.class)), is(false));
|
|
|
-
|
|
|
- assertThat(codeUserRole.indices().allowedIndicesMatcher(SearchAction.NAME).test("foo"), is(false));
|
|
|
- assertThat(codeUserRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(".reporting"), is(false));
|
|
|
- assertThat(codeUserRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(".code-"), is(true));
|
|
|
- assertThat(codeUserRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)),
|
|
|
- is(false));
|
|
|
-
|
|
|
- final String index = ".code-" + randomIntBetween(0, 5);
|
|
|
-
|
|
|
- assertThat(codeUserRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(index), is(false));
|
|
|
- assertThat(codeUserRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(false));
|
|
|
- assertThat(codeUserRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(false));
|
|
|
- assertThat(codeUserRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(index), is(false));
|
|
|
- assertThat(codeUserRole.indices().allowedIndicesMatcher(GetAction.NAME).test(index), is(true));
|
|
|
- assertThat(codeUserRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(index), is(true));
|
|
|
- assertThat(codeUserRole.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(index), is(true));
|
|
|
- assertThat(codeUserRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(index), is(false));
|
|
|
- }
|
|
|
}
|