Skip to content

Commit 48c11f7

Browse files
committed
updated with a test for issue 141
1 parent d09ee94 commit 48c11f7

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

test-complete/src/test/java/com/marklogic/javaclient/TestRuntimeDBselection.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.marklogic.client.DatabaseClientFactory;
1515
import com.marklogic.client.DatabaseClientFactory.Authentication;
1616
import com.marklogic.client.FailedRequestException;
17+
import com.marklogic.client.ForbiddenUserException;
1718

1819
public class TestRuntimeDBselection extends BasicJavaClientREST {
1920
private static String dbName = "TestRuntimeDB";
@@ -72,5 +73,21 @@ public void testRuntimeDBclientWithDifferentAuthType() throws Exception {
7273
client.release();
7374
associateRESTServerWithDefaultUser(restServerName,"nobody","digest");
7475
}
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+
}
7693
}

0 commit comments

Comments
 (0)