|
16 | 16 | package com.marklogic.client.test; |
17 | 17 |
|
18 | 18 | import static org.junit.Assert.assertEquals; |
| 19 | +import static org.junit.Assert.assertNotNull; |
| 20 | +import static org.junit.Assert.assertTrue; |
| 21 | +import static org.junit.Assert.fail; |
19 | 22 |
|
20 | 23 | import org.junit.Test; |
21 | 24 |
|
22 | 25 | import com.marklogic.client.DatabaseClient; |
23 | 26 | import com.marklogic.client.DatabaseClientFactory; |
24 | 27 | import com.marklogic.client.FailedRequestException; |
| 28 | +import com.marklogic.client.ForbiddenUserException; |
25 | 29 | import com.marklogic.client.DatabaseClientFactory.Authentication; |
26 | 30 | import com.marklogic.client.document.TextDocumentManager; |
27 | 31 | import com.marklogic.client.io.StringHandle; |
@@ -58,4 +62,22 @@ public void testInvalidUserAuth() { |
58 | 62 | assertEquals(expectedException, exception); |
59 | 63 |
|
60 | 64 | } |
| 65 | + |
| 66 | + @Test |
| 67 | + public void test_issue_762() { |
| 68 | + DatabaseClient readOnlyClient = DatabaseClientFactory.newClient( |
| 69 | + Common.HOST, Common.PORT, "rest-reader", "x", Authentication.DIGEST); |
| 70 | + try { |
| 71 | + readOnlyClient.newDocumentManager().writeAs("test.txt", "test"); |
| 72 | + fail("reader could write a document, but shouldn't be able to"); |
| 73 | + } catch (ForbiddenUserException e) { |
| 74 | + String message = e.getFailedRequest().getMessageCode(); |
| 75 | + int statusCode = e.getFailedRequest().getStatusCode(); |
| 76 | + assertNotNull("Error Message is null", message); |
| 77 | + assertTrue("Error Message", message.equals("SEC-PRIV")); |
| 78 | + assertTrue("Status code", (statusCode == 403)); |
| 79 | + } finally { |
| 80 | + readOnlyClient.release(); |
| 81 | + } |
| 82 | + } |
61 | 83 | } |
0 commit comments