|
14 | 14 | import com.marklogic.client.DatabaseClientFactory; |
15 | 15 | import com.marklogic.client.DatabaseClientFactory.Authentication; |
16 | 16 | import com.marklogic.client.FailedRequestException; |
| 17 | +import com.marklogic.client.ForbiddenUserException; |
17 | 18 |
|
18 | 19 | public class TestRuntimeDBselection extends BasicJavaClientREST { |
19 | 20 | private static String dbName = "TestRuntimeDB"; |
@@ -72,5 +73,21 @@ public void testRuntimeDBclientWithDifferentAuthType() throws Exception { |
72 | 73 | client.release(); |
73 | 74 | associateRESTServerWithDefaultUser(restServerName,"nobody","digest"); |
74 | 75 | } |
75 | | - |
| 76 | + //issue 141 user with no privileges for eval |
| 77 | + @Test(expected=FailedRequestException.class) |
| 78 | + public void testRuntimeDBclientWithNoPrivUser() throws Exception { |
| 79 | + |
| 80 | + client = DatabaseClientFactory.newClient("localhost", restPort,dbName,"rest-admin","x",Authentication.BASIC); |
| 81 | + String insertJSON = "xdmp:document-insert(\"test2.json\",object-node {\"test\":\"hello\"})"; |
| 82 | + client.newServerEval().xquery(insertJSON).eval(); |
| 83 | + String query1 = "fn:count(fn:doc())"; |
| 84 | + int response = client.newServerEval().xquery(query1).eval().next().getNumber().intValue(); |
| 85 | + assertEquals("count of documents ",1,response); |
| 86 | + String query2 ="declareUpdate();xdmp.documentDelete(\"test2.json\");"; |
| 87 | + client.newServerEval().javascript(query2).eval(); |
| 88 | + int response2 = client.newServerEval().xquery(query1).eval().next().getNumber().intValue(); |
| 89 | + assertEquals("count of documents ",0,response2); |
| 90 | + client.release(); |
| 91 | + |
| 92 | + } |
76 | 93 | } |
0 commit comments