Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.Credentials


   */
  public void testRemoveGroupWithMembers() throws IOException {
    String groupId = createTestGroup();
    String userId = createTestUser();
   
        Credentials creds = new UsernamePasswordCredentials("admin", "admin");
        String addMemberPostUrl = HTTP_BASE_URL + "/system/userManager/group/" + groupId + ".update.html";
    List<NameValuePair> addMemberPostParams = new ArrayList<NameValuePair>();
    addMemberPostParams.add(new NameValuePair(":member", userId));
    assertAuthenticatedPostStatus(creds, addMemberPostUrl, HttpServletResponse.SC_OK, addMemberPostParams, null);

View Full Code Here


   */
  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));
View Full Code Here

public class AuthenticatedTestUtil extends HttpTest {

    /** Execute a POST request and check status */
    public void assertAuthenticatedAdminPostStatus(String url, int expectedStatusCode, List<NameValuePair> postParams, String assertMessage)
    throws IOException {
        Credentials defaultcreds = new UsernamePasswordCredentials("admin", "admin");
        assertAuthenticatedPostStatus(defaultcreds, url, expectedStatusCode, postParams, assertMessage);
    }
View Full Code Here

        post.setFollowRedirects(false);

        URL baseUrl = new URL(HTTP_BASE_URL);
        AuthScope authScope = new AuthScope(baseUrl.getHost(), baseUrl.getPort(), AuthScope.ANY_REALM);
        post.setDoAuthentication(true);
        Credentials oldCredentials = httpClient.getState().getCredentials(authScope);
        try {
            httpClient.getState().setCredentials(authScope, creds);

            if(postParams!=null) {
                final NameValuePair [] nvp = {};
View Full Code Here

    public void assertAuthenticatedHttpStatus(Credentials creds, String urlString, int expectedStatusCode, String assertMessage) throws IOException {
        URL baseUrl = new URL(HTTP_BASE_URL);
        AuthScope authScope = new AuthScope(baseUrl.getHost(), baseUrl.getPort(), AuthScope.ANY_REALM);
        GetMethod getMethod = new GetMethod(urlString);
        getMethod.setDoAuthentication(true);
        Credentials oldCredentials = httpClient.getState().getCredentials(authScope);
        try {
            httpClient.getState().setCredentials(authScope, creds);

            final int status = httpClient.executeMethod(getMethod);
            if(assertMessage == null) {
View Full Code Here

        final GetMethod get = new GetMethod(url);

        URL baseUrl = new URL(HTTP_BASE_URL);
        AuthScope authScope = new AuthScope(baseUrl.getHost(), baseUrl.getPort(), AuthScope.ANY_REALM);
        get.setDoAuthentication(true);
        Credentials oldCredentials = httpClient.getState().getCredentials(authScope);
        try {
            httpClient.getState().setCredentials(authScope, creds);

            if(params != null) {
                final NameValuePair [] nvp = new NameValuePair[0];
View Full Code Here

        final PostMethod post = new PostMethod(url);

        URL baseUrl = new URL(HTTP_BASE_URL);
        AuthScope authScope = new AuthScope(baseUrl.getHost(), baseUrl.getPort(), AuthScope.ANY_REALM);
        post.setDoAuthentication(true);
        Credentials oldCredentials = httpClient.getState().getCredentials(authScope);
      try {
      httpClient.getState().setCredentials(authScope, creds);

          if(postParams!=null) {
              final NameValuePair [] nvp = {};
View Full Code Here

        String testUserId = "testUser" + getNextInt();
        List<NameValuePair> postParams = new ArrayList<NameValuePair>();
        postParams.add(new NameValuePair(":name", testUserId));
        postParams.add(new NameValuePair("pwd", "testPwd"));
        postParams.add(new NameValuePair("pwdConfirm", "testPwd"));
    Credentials creds = new UsernamePasswordCredentials("admin", "admin");
    final String msg = "Unexpected status while attempting to create test user at " + postUrl;
        assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, msg);
       
        final String sessionInfoUrl = HTTP_BASE_URL + "/system/sling/info.sessionInfo.json";
        assertAuthenticatedHttpStatus(creds, sessionInfoUrl, HttpServletResponse.SC_OK,
View Full Code Here

        String postUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".update.html";

    List<NameValuePair> postParams = new ArrayList<NameValuePair>();
    postParams.add(new NameValuePair(":member", testUserId));
   
    Credentials creds = new UsernamePasswordCredentials("admin", "admin");
    final String info = "Adding user " + testUserId + " to group via " + postUrl;
    assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, info);
  }
View Full Code Here

        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);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.Credentials

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.