@@ -36,13 +36,17 @@ public class ClusterPrivilegeTests extends AbstractPrivilegeTestCase {
3636 " - names: 'someindex'\n " +
3737 " privileges: [ all ]\n " +
3838 "role_d:\n " +
39- " cluster: [ create_snapshot ]\n " ;
39+ " cluster: [ create_snapshot ]\n " +
40+ "\n " +
41+ "role_e:\n " +
42+ " cluster: [ monitor_snapshot]\n " ;
4043
4144 private static final String USERS_ROLES =
4245 "role_a:user_a\n " +
4346 "role_b:user_b\n " +
4447 "role_c:user_c\n " +
45- "role_d:user_d\n " ;
48+ "role_d:user_d\n " +
49+ "role_e:user_e\n " ;
4650
4751 private static Path repositoryLocation ;
4852
@@ -81,7 +85,8 @@ protected String configUsers() {
8185 "user_a:" + usersPasswdHashed + "\n " +
8286 "user_b:" + usersPasswdHashed + "\n " +
8387 "user_c:" + usersPasswdHashed + "\n " +
84- "user_d:" + usersPasswdHashed + "\n " ;
88+ "user_d:" + usersPasswdHashed + "\n " +
89+ "user_e:" + usersPasswdHashed + "\n " ;
8590 }
8691
8792 @ Override
@@ -139,6 +144,19 @@ public void testThatClusterPrivilegesWorkAsExpectedViaHttp() throws Exception {
139144 assertAccessIsDenied ("user_d" , "GET" , "/_nodes/infos" );
140145 assertAccessIsDenied ("user_d" , "POST" , "/_cluster/reroute" );
141146 assertAccessIsDenied ("user_d" , "PUT" , "/_cluster/settings" , "{ \" transient\" : { \" search.default_search_timeout\" : \" 1m\" } }" );
147+
148+ // user_e can view repos and snapshots on existing repos, everything else is DENIED
149+ assertAccessIsDenied ("user_e" , "GET" , "/_cluster/state" );
150+ assertAccessIsDenied ("user_e" , "GET" , "/_cluster/health" );
151+ assertAccessIsDenied ("user_e" , "GET" , "/_cluster/settings" );
152+ assertAccessIsDenied ("user_e" , "GET" , "/_cluster/stats" );
153+ assertAccessIsDenied ("user_e" , "GET" , "/_cluster/pending_tasks" );
154+ assertAccessIsDenied ("user_e" , "GET" , "/_nodes/stats" );
155+ assertAccessIsDenied ("user_e" , "GET" , "/_nodes/hot_threads" );
156+ assertAccessIsDenied ("user_e" , "GET" , "/_nodes/infos" );
157+ assertAccessIsDenied ("user_e" , "POST" , "/_cluster/reroute" );
158+ assertAccessIsDenied ("user_e" , "PUT" , "/_cluster/settings" , "{ \" transient\" : { \" search.default_search_timeout\" : \" 1m\" } }" );
159+
142160 }
143161
144162 public void testThatSnapshotAndRestore () throws Exception {
@@ -147,6 +165,7 @@ public void testThatSnapshotAndRestore() throws Exception {
147165 assertAccessIsDenied ("user_b" , "PUT" , "/_snapshot/my-repo" , repoJson );
148166 assertAccessIsDenied ("user_c" , "PUT" , "/_snapshot/my-repo" , repoJson );
149167 assertAccessIsDenied ("user_d" , "PUT" , "/_snapshot/my-repo" , repoJson );
168+ assertAccessIsDenied ("user_e" , "PUT" , "/_snapshot/my-repo" , repoJson );
150169 assertAccessIsAllowed ("user_a" , "PUT" , "/_snapshot/my-repo" , repoJson );
151170
152171 Request createBar = new Request ("PUT" , "/someindex/_doc/1" );
@@ -155,16 +174,19 @@ public void testThatSnapshotAndRestore() throws Exception {
155174 assertAccessIsDenied ("user_a" , createBar );
156175 assertAccessIsDenied ("user_b" , createBar );
157176 assertAccessIsDenied ("user_d" , createBar );
177+ assertAccessIsDenied ("user_e" , createBar );
158178 assertAccessIsAllowed ("user_c" , createBar );
159179
160180 assertAccessIsDenied ("user_b" , "PUT" , "/_snapshot/my-repo/my-snapshot" , "{ \" indices\" : \" someindex\" }" );
161181 assertAccessIsDenied ("user_c" , "PUT" , "/_snapshot/my-repo/my-snapshot" , "{ \" indices\" : \" someindex\" }" );
182+ assertAccessIsDenied ("user_e" , "PUT" , "/_snapshot/my-repo/my-snapshot" , "{ \" indices\" : \" someindex\" }" );
162183 assertAccessIsAllowed ("user_a" , "PUT" , "/_snapshot/my-repo/my-snapshot" , "{ \" indices\" : \" someindex\" }" );
163184
164185 assertAccessIsDenied ("user_b" , "GET" , "/_snapshot/my-repo/my-snapshot/_status" );
165186 assertAccessIsDenied ("user_c" , "GET" , "/_snapshot/my-repo/my-snapshot/_status" );
166187 assertAccessIsAllowed ("user_a" , "GET" , "/_snapshot/my-repo/my-snapshot/_status" );
167188 assertAccessIsAllowed ("user_d" , "GET" , "/_snapshot/my-repo/my-snapshot/_status" );
189+ assertAccessIsAllowed ("user_e" , "GET" , "/_snapshot/my-repo/my-snapshot/_status" );
168190
169191 // This snapshot needs to be finished in order to be restored
170192 waitForSnapshotToFinish ("my-repo" , "my-snapshot" );
@@ -175,28 +197,33 @@ public void testThatSnapshotAndRestore() throws Exception {
175197 assertAccessIsDenied ("user_a" , "DELETE" , "/someindex" );
176198 assertAccessIsDenied ("user_b" , "DELETE" , "/someindex" );
177199 assertAccessIsDenied ("user_d" , "DELETE" , "/someindex" );
200+ assertAccessIsDenied ("user_e" , "DELETE" , "/someindex" );
178201 assertAccessIsAllowed ("user_c" , "DELETE" , "/someindex" );
179202
180203 Request restoreSnapshotRequest = new Request ("POST" , "/_snapshot/my-repo/my-snapshot/_restore" );
181204 restoreSnapshotRequest .addParameter ("wait_for_completion" , "true" );
182205 assertAccessIsDenied ("user_b" , restoreSnapshotRequest );
183206 assertAccessIsDenied ("user_c" , restoreSnapshotRequest );
184207 assertAccessIsDenied ("user_d" , restoreSnapshotRequest );
208+ assertAccessIsDenied ("user_e" , restoreSnapshotRequest );
185209 assertAccessIsAllowed ("user_a" , restoreSnapshotRequest );
186210
187211 assertAccessIsDenied ("user_a" , "GET" , "/someindex/_doc/1" );
188212 assertAccessIsDenied ("user_b" , "GET" , "/someindex/_doc/1" );
189213 assertAccessIsDenied ("user_d" , "GET" , "/someindex/_doc/1" );
214+ assertAccessIsDenied ("user_e" , "GET" , "/someindex/_doc/1" );
190215 assertAccessIsAllowed ("user_c" , "GET" , "/someindex/_doc/1" );
191216
192217 assertAccessIsDenied ("user_b" , "DELETE" , "/_snapshot/my-repo/my-snapshot" );
193218 assertAccessIsDenied ("user_c" , "DELETE" , "/_snapshot/my-repo/my-snapshot" );
194219 assertAccessIsDenied ("user_d" , "DELETE" , "/_snapshot/my-repo/my-snapshot" );
220+ assertAccessIsDenied ("user_e" , "DELETE" , "/_snapshot/my-repo/my-snapshot" );
195221 assertAccessIsAllowed ("user_a" , "DELETE" , "/_snapshot/my-repo/my-snapshot" );
196222
197223 assertAccessIsDenied ("user_b" , "DELETE" , "/_snapshot/my-repo" );
198224 assertAccessIsDenied ("user_c" , "DELETE" , "/_snapshot/my-repo" );
199225 assertAccessIsDenied ("user_d" , "DELETE" , "/_snapshot/my-repo" );
226+ assertAccessIsDenied ("user_e" , "DELETE" , "/_snapshot/my-repo" );
200227 assertAccessIsAllowed ("user_a" , "DELETE" , "/_snapshot/my-repo" );
201228 }
202229
0 commit comments