use of com.ibm.cloud.cloudant.v1.model.SecurityObject in project cloudant-java-sdk by IBM.
the class CloudantTest method testPutCloudantSecurityConfigurationWOptions.
@Test
public void testPutCloudantSecurityConfigurationWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"ok\": true}";
String putCloudantSecurityConfigurationPath = "/_api/v2/db/testString/_security";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the SecurityObject model
SecurityObject securityObjectModel = new SecurityObject.Builder().names(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).roles(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).build();
// Construct an instance of the PutCloudantSecurityConfigurationOptions model
PutCloudantSecurityConfigurationOptions putCloudantSecurityConfigurationOptionsModel = new PutCloudantSecurityConfigurationOptions.Builder().db("testString").cloudant(new java.util.HashMap<String, List<String>>() {
{
put("foo", new java.util.ArrayList<String>(java.util.Arrays.asList("_reader")));
}
}).admins(securityObjectModel).members(securityObjectModel).couchdbAuthOnly(true).build();
// Invoke operation with valid options model (positive test)
Response<Ok> response = cloudantService.putCloudantSecurityConfiguration(putCloudantSecurityConfigurationOptionsModel).execute();
assertNotNull(response);
Ok responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "PUT");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, putCloudantSecurityConfigurationPath);
}
Aggregations