@@ -3058,89 +3058,6 @@ public void testAPMSystemRole() {
30583058 assertNoAccessAllowed (APMSystemRole , XPackPlugin .ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween (0 , 2 ));
30593059 }
30603060
3061- public void testAPMUserRole () {
3062- final TransportRequest request = mock (TransportRequest .class );
3063- final Authentication authentication = AuthenticationTestHelper .builder ().build ();
3064-
3065- final RoleDescriptor roleDescriptor = ReservedRolesStore .roleDescriptor ("apm_user" );
3066- assertNotNull (roleDescriptor );
3067- assertThat (roleDescriptor .getMetadata (), hasEntry ("_reserved" , true ));
3068-
3069- final String allowedApplicationActionPattern = "example/custom/action/*" ;
3070- final String kibanaApplicationWithRandomIndex = "kibana-" + randomFrom (randomAlphaOfLengthBetween (8 , 24 ), ".kibana" );
3071- Role role = Role .buildFromRoleDescriptor (
3072- roleDescriptor ,
3073- new FieldPermissionsCache (Settings .EMPTY ),
3074- RESTRICTED_INDICES ,
3075- List .of (
3076- new ApplicationPrivilegeDescriptor (
3077- kibanaApplicationWithRandomIndex ,
3078- "reserved_ml_apm_user" ,
3079- Set .of (allowedApplicationActionPattern ),
3080- Map .of ()
3081- )
3082- )
3083- );
3084-
3085- assertThat (role .cluster ().check (DelegatePkiAuthenticationAction .NAME , request , authentication ), is (false ));
3086- assertThat (role .runAs ().check (randomAlphaOfLengthBetween (1 , 12 )), is (false ));
3087-
3088- assertNoAccessAllowed (role , "foo" );
3089- assertNoAccessAllowed (role , "foo-apm" );
3090- assertNoAccessAllowed (role , "foo-logs-apm.bar" );
3091- assertNoAccessAllowed (role , "foo-logs-apm-bar" );
3092- assertNoAccessAllowed (role , "foo-traces-apm.bar" );
3093- assertNoAccessAllowed (role , "foo-traces-apm-bar" );
3094- assertNoAccessAllowed (role , "foo-metrics-apm.bar" );
3095- assertNoAccessAllowed (role , "foo-metrics-apm-bar" );
3096-
3097- assertOnlyReadAllowed (role , "logs-apm." + randomIntBetween (0 , 5 ));
3098- assertOnlyReadAllowed (role , "logs-apm-" + randomIntBetween (0 , 5 ));
3099- assertOnlyReadAllowed (role , "traces-apm." + randomIntBetween (0 , 5 ));
3100- assertOnlyReadAllowed (role , "traces-apm-" + randomIntBetween (0 , 5 ));
3101- assertOnlyReadAllowed (role , "metrics-apm." + randomIntBetween (0 , 5 ));
3102- assertOnlyReadAllowed (role , "metrics-apm-" + randomIntBetween (0 , 5 ));
3103- assertOnlyReadAllowed (role , "apm-" + randomIntBetween (0 , 5 ));
3104- assertOnlyReadAllowed (role , AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields .RESULTS_INDEX_DEFAULT );
3105-
3106- assertOnlyReadAllowed (role , "observability-annotations" );
3107-
3108- assertThat (
3109- role .application ().grants (ApplicationPrivilegeTests .createPrivilege (kibanaApplicationWithRandomIndex , "app-foo" , "foo" ), "*" ),
3110- is (false )
3111- );
3112- assertThat (
3113- role .application ()
3114- .grants (
3115- ApplicationPrivilegeTests .createPrivilege (
3116- kibanaApplicationWithRandomIndex ,
3117- "app-reserved_ml_apm_user" ,
3118- allowedApplicationActionPattern
3119- ),
3120- "*"
3121- ),
3122- is (true )
3123- );
3124-
3125- final String otherApplication = "logstash-" + randomAlphaOfLengthBetween (8 , 24 );
3126- assertThat (
3127- role .application ().grants (ApplicationPrivilegeTests .createPrivilege (otherApplication , "app-foo" , "foo" ), "*" ),
3128- is (false )
3129- );
3130- assertThat (
3131- role .application ()
3132- .grants (
3133- ApplicationPrivilegeTests .createPrivilege (
3134- otherApplication ,
3135- "app-reserved_ml_apm_user" ,
3136- allowedApplicationActionPattern
3137- ),
3138- "*"
3139- ),
3140- is (false )
3141- );
3142- }
3143-
31443061 public void testMachineLearningAdminRole () {
31453062 final TransportRequest request = mock (TransportRequest .class );
31463063 final Authentication authentication = AuthenticationTestHelper .builder ().build ();
0 commit comments