@@ -96,8 +96,13 @@ class SecureMonitorRestApiIT : AlertingRestTestCase() {
96
96
// Create Monitor related security tests
97
97
fun `test create monitor with an user with alerting role` () {
98
98
99
- createUserWithTestData(user, TEST_HR_INDEX , TEST_HR_ROLE , TEST_HR_BACKEND_ROLE )
100
- createUserRolesMapping(ALERTING_FULL_ACCESS_ROLE , arrayOf(user))
99
+ createUserWithTestDataAndCustomRole(
100
+ user,
101
+ TEST_HR_INDEX ,
102
+ TEST_HR_ROLE ,
103
+ TEST_HR_BACKEND_ROLE ,
104
+ getClusterPermissionsFromCustomRole(ALERTING_INDEX_MONITOR_ACCESS )
105
+ )
101
106
try {
102
107
// randomMonitor has a dummy user, api ignores the User passed as part of monitor, it picks user info from the logged-in user.
103
108
val monitor = randomQueryLevelMonitor().copy(
@@ -113,7 +118,6 @@ class SecureMonitorRestApiIT : AlertingRestTestCase() {
113
118
assertUserNull(createResponse?.asMap()!! [" monitor" ] as HashMap <String , Any >)
114
119
} finally {
115
120
deleteRoleAndRoleMapping(TEST_HR_ROLE )
116
- deleteRoleMapping(ALERTING_FULL_ACCESS_ROLE )
117
121
}
118
122
}
119
123
@@ -451,7 +455,13 @@ class SecureMonitorRestApiIT : AlertingRestTestCase() {
451
455
assertEquals(" Unexpected status" , RestStatus .FORBIDDEN , e.response.restStatus())
452
456
}
453
457
// add alerting roles and search as userOne - must return 1 docs
454
- createUserRolesMapping(ALERTING_FULL_ACCESS_ROLE , arrayOf(user))
458
+ createUserWithTestDataAndCustomRole(
459
+ user,
460
+ TEST_HR_INDEX ,
461
+ TEST_HR_ROLE ,
462
+ TEST_HR_BACKEND_ROLE ,
463
+ getClusterPermissionsFromCustomRole(ALERTING_SEARCH_MONITOR_ONLY_ACCESS )
464
+ )
455
465
try {
456
466
val userOneSearchResponse = userClient?.makeRequest(
457
467
" POST" ,
@@ -462,7 +472,7 @@ class SecureMonitorRestApiIT : AlertingRestTestCase() {
462
472
assertEquals(" Search monitor failed" , RestStatus .OK , userOneSearchResponse?.restStatus())
463
473
assertEquals(" Monitor not found during search" , 1 , getDocs(userOneSearchResponse))
464
474
} finally {
465
- deleteRoleMapping( ALERTING_FULL_ACCESS_ROLE )
475
+ deleteRoleAndRoleMapping( TEST_HR_ROLE )
466
476
}
467
477
}
468
478
@@ -822,7 +832,7 @@ class SecureMonitorRestApiIT : AlertingRestTestCase() {
822
832
823
833
createUser(user, user, arrayOf(TEST_HR_BACKEND_ROLE ))
824
834
createTestIndex(TEST_HR_INDEX )
825
- createCustomIndexRoleWithDocLevelSecurity (TEST_HR_ROLE , TEST_HR_INDEX , TERM_DLS_QUERY , getClusterPermissionsFromCustomRole(ALERTING_INDEX_MONITOR_ACCESS ))
835
+ createIndexRoleWithDocLevelSecurity (TEST_HR_ROLE , TEST_HR_INDEX , TERM_DLS_QUERY , getClusterPermissionsFromCustomRole(ALERTING_INDEX_MONITOR_ACCESS ))
826
836
createUserRolesMapping(TEST_HR_ROLE , arrayOf(user))
827
837
828
838
// Add a doc that is accessible to the user
@@ -872,7 +882,7 @@ class SecureMonitorRestApiIT : AlertingRestTestCase() {
872
882
873
883
createUser(user, user, arrayOf(TEST_HR_BACKEND_ROLE ))
874
884
createTestIndex(TEST_HR_INDEX )
875
- createCustomIndexRoleWithDocLevelSecurity (TEST_HR_ROLE , TEST_HR_INDEX , TERM_DLS_QUERY , getClusterPermissionsFromCustomRole(ALERTING_INDEX_MONITOR_ACCESS ))
885
+ createIndexRoleWithDocLevelSecurity (TEST_HR_ROLE , TEST_HR_INDEX , TERM_DLS_QUERY , getClusterPermissionsFromCustomRole(ALERTING_INDEX_MONITOR_ACCESS ))
876
886
createUserRolesMapping(TEST_HR_ROLE , arrayOf(user))
877
887
878
888
// Add a doc that is accessible to the user
0 commit comments