@@ -13,13 +13,15 @@ import org.junit.After
13
13
import org.junit.Before
14
14
import org.junit.BeforeClass
15
15
import org.opensearch.alerting.ALERTING_GET_EMAIL_ACCOUNT_ACCESS
16
+ import org.opensearch.alerting.ALERTING_NO_ACCESS_ROLE
16
17
import org.opensearch.alerting.ALERTING_SEARCH_EMAIL_ACCOUNT_ACCESS
17
18
import org.opensearch.alerting.AlertingPlugin
18
19
import org.opensearch.alerting.AlertingRestTestCase
19
20
import org.opensearch.alerting.TEST_HR_BACKEND_ROLE
20
21
import org.opensearch.alerting.TEST_HR_INDEX
21
22
import org.opensearch.alerting.TEST_HR_ROLE
22
23
import org.opensearch.alerting.makeRequest
24
+ import org.opensearch.client.ResponseException
23
25
import org.opensearch.client.RestClient
24
26
import org.opensearch.commons.rest.SecureRestClientBuilder
25
27
import org.opensearch.rest.RestStatus
@@ -50,7 +52,7 @@ class SecureEmailAccountRestApiIT : AlertingRestTestCase() {
50
52
}
51
53
}
52
54
53
- val user = " userOne "
55
+ val user = " userB "
54
56
var userClient: RestClient ? = null
55
57
56
58
@Before
@@ -129,7 +131,7 @@ class SecureEmailAccountRestApiIT : AlertingRestTestCase() {
129
131
130
132
/*
131
133
TODO: https://github.com/opensearch-project/alerting/issues/300
132
-
134
+ */
133
135
fun `test get email accounts with an user without get email account role` () {
134
136
createUserWithTestDataAndCustomRole(
135
137
user,
@@ -138,9 +140,7 @@ class SecureEmailAccountRestApiIT : AlertingRestTestCase() {
138
140
listOf (TEST_HR_BACKEND_ROLE ),
139
141
getClusterPermissionsFromCustomRole(ALERTING_NO_ACCESS_ROLE )
140
142
)
141
-
142
143
val emailAccount = createRandomEmailAccountWithGivenName(true , randomAlphaOfLength(5 ))
143
-
144
144
try {
145
145
userClient?.makeRequest(
146
146
" GET" ,
@@ -158,19 +158,15 @@ class SecureEmailAccountRestApiIT : AlertingRestTestCase() {
158
158
deleteRoleAndRoleMapping(TEST_HR_ROLE )
159
159
}
160
160
}
161
-
162
161
fun `test search email accounts with an user without search email account role` () {
163
-
164
162
createUserWithTestDataAndCustomRole(
165
163
user,
166
164
TEST_HR_INDEX ,
167
165
TEST_HR_ROLE ,
168
166
listOf (TEST_HR_BACKEND_ROLE ),
169
167
getClusterPermissionsFromCustomRole(ALERTING_NO_ACCESS_ROLE )
170
168
)
171
-
172
169
createRandomEmailAccountWithGivenName(true , randomAlphaOfLength(5 ))
173
-
174
170
try {
175
171
userClient?.makeRequest(
176
172
" POST" ,
@@ -185,6 +181,4 @@ class SecureEmailAccountRestApiIT : AlertingRestTestCase() {
185
181
deleteRoleAndRoleMapping(TEST_HR_ROLE )
186
182
}
187
183
}
188
-
189
- */
190
184
}
0 commit comments