- 
                Notifications
    You must be signed in to change notification settings 
- Fork 74
Closed
Description
Version of MarkLogic Java Client API :
4.1
Version of MarkLogic Server:
10.0 nightly build
Java version :
1.8
OS and version
Windows
Input: Some code to illustrate the problem, preferably in a state that can be independently reproduced on our end
{
  "functionName" : "TestE2ERequiredParam",
 "params" : [ {
    "name" : "items",
    "datatype" : "int",
    "multiple" : false,
    "nullable" : false
  }, 
  {
    "name" : "price",
    "datatype" : "int",
    "multiple" : false,
	"$javaClass" : "java.lang.Integer"
  } 
  ],
  "return" : {
    "datatype" : "float",
    "multiple" : false,
    "nullable" : true,
	"$javaClass" : "java.lang.Float"
  }
}
Module file:
function TestE2EItemPrice(inputIntegertVaue) {
var retDoubleValue;
if (inputIntegertVaue == null) {
// Return a valid datatype back to client so that we know null input parameter works
retDoubleValue = 55555.00;
return encodeURI(retDoubleValue);
}
console.debug("Inside CLIENT API inputIntegertVaue %s", inputIntegertVaue);
var inputInt = parseInt(inputIntegertVaue, 10);
if (inputInt == 10) {
// Return invalid datatype when input is 10
retDoubleValue = "String10";
}
else if (inputInt == 1000) {
// Return null when input is 1000
retDoubleValue = null;
}
else {
retDoubleValue = inputInt + 1.00;
}
console.debug("Return from CLIENT API new double value is : %s", retDoubleValue);
return encodeURI(retDoubleValue);
}
var t = TestE2EItemPrice(xdmp.getRequestField("items"));
t;
Test Code
 createUserRolesWithPrevilages("ForbiddenRole", "any-uri");
        createRESTUser("ForbiddenUser", "ap1U53r", "apiRole", "rest-admin", "rest-writer", "rest-reader", "manage-user");
...
...
 @Test
		public void TestE2EForbiddenUser() throws Exception {
		   
		  System.out.println("Running TestE2EForbiddenUser");
		  DatabaseClient dbForbiddenclient = getDatabaseClientOnDatabase(host, port, dbName, "ForbiddenUser", "ap1U53r", Authentication.DIGEST);
	    // Invoke the function with no Params - API decl states params as required
		  String msg;
		try {
		Float responseBack1 = TestE2EInegerParaReturnDouble.on(dbForbiddenclient).TestE2ERequiredParam(10, 50);
		}
		catch (Exception ex) {
			msg = ex.toString();
			System.out.println("Exception response from the Client API call is " + ex.toString());
			assertTrue("Expected exception type not returned", msg.contains("RequiredParamException"));
			assertTrue("Expected exception type not returned", msg.contains("null value for required parameter: items"));
		}
	  }
Actual output: What did you observe? What errors did you see? Can you attach the logs? (Java logs, MarkLogic logs)
java.lang.RuntimeException: Returned document as text/html; charset=utf-8 instead of text/plain
Expected output: What specifically did you expect to happen?
ForbiddenException
Alternatives: What else have you tried, actual/expected?
None.