@@ -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
@@ -126,7 +128,7 @@ class SecureEmailAccountRestApiIT : AlertingRestTestCase() {
126
128
127
129
/*
128
130
TODO: https://github.com/opensearch-project/alerting/issues/300
129
-
131
+ */
130
132
fun `test get email accounts with an user without get email account role` () {
131
133
createUserWithTestDataAndCustomRole(
132
134
user,
@@ -135,9 +137,7 @@ class SecureEmailAccountRestApiIT : AlertingRestTestCase() {
135
137
listOf (TEST_HR_BACKEND_ROLE ),
136
138
getClusterPermissionsFromCustomRole(ALERTING_NO_ACCESS_ROLE )
137
139
)
138
-
139
140
val emailAccount = createRandomEmailAccountWithGivenName(true , randomAlphaOfLength(5 ))
140
-
141
141
try {
142
142
userClient?.makeRequest(
143
143
" GET" ,
@@ -155,19 +155,15 @@ class SecureEmailAccountRestApiIT : AlertingRestTestCase() {
155
155
deleteRoleAndRoleMapping(TEST_HR_ROLE )
156
156
}
157
157
}
158
-
159
158
fun `test search email accounts with an user without search email account role` () {
160
-
161
159
createUserWithTestDataAndCustomRole(
162
160
user,
163
161
TEST_HR_INDEX ,
164
162
TEST_HR_ROLE ,
165
163
listOf (TEST_HR_BACKEND_ROLE ),
166
164
getClusterPermissionsFromCustomRole(ALERTING_NO_ACCESS_ROLE )
167
165
)
168
-
169
166
createRandomEmailAccountWithGivenName(true , randomAlphaOfLength(5 ))
170
-
171
167
try {
172
168
userClient?.makeRequest(
173
169
" POST" ,
@@ -182,6 +178,4 @@ class SecureEmailAccountRestApiIT : AlertingRestTestCase() {
182
178
deleteRoleAndRoleMapping(TEST_HR_ROLE )
183
179
}
184
180
}
185
-
186
- */
187
181
}
0 commit comments