use of org.apache.commons.httpclient.Credentials in project sling by apache.
the class UpdateUserTest method testChangeUserPasswordWrongOldPwd.
@Test
public void testChangeUserPasswordWrongOldPwd() throws IOException {
testUserId = H.createTestUser();
String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".changePassword.html";
List<NameValuePair> postParams = new ArrayList<NameValuePair>();
postParams.add(new NameValuePair("oldPwd", "wrongTestPwd"));
postParams.add(new NameValuePair("newPwd", "testNewPwd"));
postParams.add(new NameValuePair("newPwdConfirm", "testNewPwd"));
//Credentials creds = new UsernamePasswordCredentials(testUserId, "testPwd");
Credentials creds = new UsernamePasswordCredentials("admin", "admin");
H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, postParams, null);
}
use of org.apache.commons.httpclient.Credentials in project sling by apache.
the class UpdateUserTest method testUpdateUserResponseAsJSON.
/**
* Test for SLING-1677
*/
@Test
public void testUpdateUserResponseAsJSON() throws IOException, JsonException {
testUserId = H.createTestUser();
String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".update.json";
List<NameValuePair> postParams = new ArrayList<NameValuePair>();
postParams.add(new NameValuePair("displayName", "My Updated Test User"));
postParams.add(new NameValuePair("url", "http://www.apache.org/updated"));
Credentials creds = new UsernamePasswordCredentials(testUserId, "testPwd");
String json = H.getAuthenticatedPostContent(creds, postUrl, HttpTest.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.Credentials in project sling by apache.
the class UpdateUserTest method testChangeUserPasswordAsAdministratorWithoutOldPwd.
/**
* Test for SLING-2069
* @throws IOException
*/
@Test
public void testChangeUserPasswordAsAdministratorWithoutOldPwd() throws IOException {
testUserId = H.createTestUser();
String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".changePassword.html";
List<NameValuePair> postParams = new ArrayList<NameValuePair>();
postParams.add(new NameValuePair("newPwd", "testNewPwd"));
postParams.add(new NameValuePair("newPwdConfirm", "testNewPwd"));
Credentials creds = new UsernamePasswordCredentials("admin", "admin");
H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
}
use of org.apache.commons.httpclient.Credentials 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.Credentials 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);
}
Aggregations