use of org.apache.commons.httpclient.UsernamePasswordCredentials in project sling by apache.
the class CreateGroupTest method testCreateGroupResponseAsJSON.
/**
* Test for SLING-1677
*/
public void testCreateGroupResponseAsJSON() throws IOException, JsonException {
String postUrl = HTTP_BASE_URL + "/system/userManager/group.create.json";
testGroupId = "testGroup" + random.nextInt();
List<NameValuePair> postParams = new ArrayList<NameValuePair>();
postParams.add(new NameValuePair(":name", testGroupId));
postParams.add(new NameValuePair("marker", testGroupId));
Credentials creds = new UsernamePasswordCredentials("admin", "admin");
String json = getAuthenticatedPostContent(creds, postUrl, CONTENT_TYPE_JSON, postParams, HttpServletResponse.SC_OK);
//make sure the json response can be parsed as a JSON object
JsonObject jsonObj = JsonUtil.parseObject(json);
assertNotNull(jsonObj);
}
use of org.apache.commons.httpclient.UsernamePasswordCredentials in project sling by apache.
the class CreateUserTest method testCreateUserMissingUserId.
@Test
public void testCreateUserMissingUserId() throws IOException {
String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user.create.html";
List<NameValuePair> postParams = new ArrayList<NameValuePair>();
Credentials creds = new UsernamePasswordCredentials("admin", "admin");
H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, postParams, null);
}
use of org.apache.commons.httpclient.UsernamePasswordCredentials in project sling by apache.
the class RemoveAuthorizablesTest method testRemoveUser.
public void testRemoveUser() throws IOException {
String userId = createTestUser();
Credentials creds = new UsernamePasswordCredentials("admin", "admin");
String getUrl = HTTP_BASE_URL + "/system/userManager/user/" + userId + ".json";
//make sure the profile request returns some data
assertAuthenticatedHttpStatus(creds, getUrl, HttpServletResponse.SC_OK, null);
String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + userId + ".delete.html";
List<NameValuePair> postParams = new ArrayList<NameValuePair>();
assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
getUrl = HTTP_BASE_URL + "/system/userManager/user/" + userId + ".json";
//make sure the profile request returns some data
assertAuthenticatedHttpStatus(creds, getUrl, HttpServletResponse.SC_NOT_FOUND, null);
}
use of org.apache.commons.httpclient.UsernamePasswordCredentials in project sling by apache.
the class RemoveAuthorizablesTest method testRemoveAuthorizablesResponseAsJSON.
/**
* Test for SLING-1677
*/
public void testRemoveAuthorizablesResponseAsJSON() throws IOException, JsonException {
String userId = createTestUser();
String groupId = createTestGroup();
Credentials creds = new UsernamePasswordCredentials("admin", "admin");
String postUrl = HTTP_BASE_URL + "/system/userManager.delete.json";
List<NameValuePair> postParams = new ArrayList<NameValuePair>();
postParams.add(new NameValuePair(":applyTo", "group/" + groupId));
postParams.add(new NameValuePair(":applyTo", "user/" + userId));
String json = getAuthenticatedPostContent(creds, postUrl, CONTENT_TYPE_JSON, postParams, HttpServletResponse.SC_OK);
//make sure the json response can be parsed as a JSON object
JsonObject jsonObj = JsonUtil.parseObject(json);
assertNotNull(jsonObj);
}
use of org.apache.commons.httpclient.UsernamePasswordCredentials in project sling by apache.
the class RemoveAuthorizablesTest method testRemoveGroup.
public void testRemoveGroup() throws IOException {
String groupId = createTestGroup();
Credentials creds = new UsernamePasswordCredentials("admin", "admin");
String getUrl = HTTP_BASE_URL + "/system/userManager/group/" + groupId + ".json";
//make sure the profile request returns some data
assertAuthenticatedHttpStatus(creds, getUrl, HttpServletResponse.SC_OK, null);
String postUrl = HTTP_BASE_URL + "/system/userManager/group/" + groupId + ".delete.html";
List<NameValuePair> postParams = new ArrayList<NameValuePair>();
assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
getUrl = HTTP_BASE_URL + "/system/userManager/group/" + groupId + ".json";
//make sure the profile request returns some data
assertAuthenticatedHttpStatus(creds, getUrl, HttpServletResponse.SC_NOT_FOUND, null);
}
Aggregations