use of org.apache.commons.httpclient.UsernamePasswordCredentials in project sling by apache.
the class UserManagerTestUtil method removeUserFromGroup.
/**
* Helper to assist removing a user from a group
* @param testUserId the user
* @param testGroupId the group
*/
public void removeUserFromGroup(String testUserId, String testGroupId) throws IOException {
String postUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".update.html";
List<NameValuePair> postParams = new ArrayList<NameValuePair>();
postParams.add(new NameValuePair(":member@Delete", testUserId));
Credentials creds = new UsernamePasswordCredentials("admin", "admin");
final String info = "Removing user " + testUserId + " from group via " + postUrl;
assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, info);
}
use of org.apache.commons.httpclient.UsernamePasswordCredentials in project sling by apache.
the class UserPrivilegesInfoTest method testCanAddUser.
/**
* Checks whether the current user has been granted privileges
* to add a new user.
*/
@Test
public void testCanAddUser() throws JsonException, IOException {
testUserId = H.createTestUser();
String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".privileges-info.json";
//fetch the JSON for the test page to verify the settings.
Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd");
String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
JsonObject jsonObj = JsonUtil.parseObject(json);
assertEquals(false, jsonObj.getBoolean("canAddUser"));
}
use of org.apache.commons.httpclient.UsernamePasswordCredentials in project sling by apache.
the class UserPrivilegesInfoTest method testCanUpdateGroupProperties.
/**
* Checks whether the current user has been granted privileges
* to update the properties of the specified group.
*/
@Test
public void testCanUpdateGroupProperties() throws IOException, JsonException {
testGroupId = H.createTestGroup();
testUserId = H.createTestUser();
//1. Verify non admin user can not update group properties
String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".privileges-info.json";
//fetch the JSON for the test page to verify the settings.
Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd");
String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
JsonObject jsonObj = JsonUtil.parseObject(json);
//normal user can not update group properties
assertEquals(false, jsonObj.getBoolean("canUpdateProperties"));
}
use of org.apache.commons.httpclient.UsernamePasswordCredentials in project sling by apache.
the class UserPrivilegesInfoTest method testCanRemoveGroup.
/**
* Checks whether the current user has been granted privileges
* to remove the specified group.
*/
@Test
public void testCanRemoveGroup() throws IOException, JsonException {
testGroupId = H.createTestGroup();
testUserId = H.createTestUser();
//1. Verify non admin user can not remove group
String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".privileges-info.json";
//fetch the JSON for the test page to verify the settings.
Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd");
String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
JsonObject jsonObj = JsonUtil.parseObject(json);
//normal user can not remove group
assertEquals(false, jsonObj.getBoolean("canRemove"));
}
use of org.apache.commons.httpclient.UsernamePasswordCredentials in project sling by apache.
the class UserPrivilegesInfoTest method testCanUpdateGroupMembers.
/**
* Checks whether the current user has been granted privileges
* to update the membership of the specified group.
*/
@Test
public void testCanUpdateGroupMembers() throws IOException, JsonException {
testGroupId = H.createTestGroup();
testUserId = H.createTestUser();
//1. Verify non admin user can not update group membership
String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".privileges-info.json";
//fetch the JSON for the test page to verify the settings.
Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd");
String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
JsonObject jsonObj = JsonUtil.parseObject(json);
//normal user can not remove group
assertEquals(false, jsonObj.getBoolean("canUpdateGroupMembers"));
}
Aggregations