Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.Credentials


    final List<NameValuePair> postParams = new ArrayList<NameValuePair>();
    postParams.add(new NameValuePair(":name", testUserId));
    postParams.add(new NameValuePair("marker", testUserId));
    postParams.add(new NameValuePair("pwd", "testPwd"));
    postParams.add(new NameValuePair("pwdConfirm", "testPwd"));
    final Credentials creds = new UsernamePasswordCredentials("admin", "admin");
    H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);

    {
          // fetch the user profile json to verify the settings
          final String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".json";
          final String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
          assertNotNull(json);
          final JSONObject jsonObj = new JSONObject(json);
          assertEquals(testUserId, jsonObj.getString("marker"));
          assertFalse(jsonObj.has(":name"));
          assertFalse(jsonObj.has("pwd"));
          assertFalse(jsonObj.has("pwdConfirm"));
    }
   
        {
            // fetch the session info to verify that the user can log in
            final Credentials newUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd");
            final String getUrl = HttpTest.HTTP_BASE_URL + "/system/sling/info.sessionInfo.json";
            final String json = H.getAuthenticatedContent(newUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
            assertNotNull(json);
            final JSONObject jsonObj = new JSONObject(json);
            assertEquals(testUserId, jsonObj.getString("userID"));
View Full Code Here


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

        String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user.create.html";

        String userId = "testUser" + random.nextInt();
    List<NameValuePair> postParams = new ArrayList<NameValuePair>();
    postParams.add(new NameValuePair(":name", userId));
    Credentials creds = new UsernamePasswordCredentials("admin", "admin");
    H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, postParams, null);
  }
View Full Code Here

        String userId = "testUser" + random.nextInt();
    List<NameValuePair> postParams = new ArrayList<NameValuePair>();
    postParams.add(new NameValuePair(":name", userId));
    postParams.add(new NameValuePair("pwd", "testPwd"));
    postParams.add(new NameValuePair("pwdConfirm", "testPwd2"));
    Credentials creds = new UsernamePasswordCredentials("admin", "admin");
    H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, postParams, null);
  }
View Full Code Here

    testUserId = "testUser" + random.nextInt();
    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");
    H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);

    //post the same info again, should fail
    H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, postParams, null);
  }
View Full Code Here

    postParams.add(new NameValuePair("marker", testUserId));
    postParams.add(new NameValuePair("pwd", "testPwd"));
    postParams.add(new NameValuePair("pwdConfirm", "testPwd"));
    postParams.add(new NameValuePair("displayName", "My Test User"));
    postParams.add(new NameValuePair("url", "http://www.apache.org"));
    Credentials creds = new UsernamePasswordCredentials("admin", "admin");
    H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);

    //fetch the user profile json to verify the settings
    String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".json";
    String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
View Full Code Here

    List<NameValuePair> postParams = new ArrayList<NameValuePair>();
    postParams.add(new NameValuePair(":name", testUserId));
    postParams.add(new NameValuePair("marker", testUserId));
    postParams.add(new NameValuePair("pwd", "testPwd"));
    postParams.add(new NameValuePair("pwdConfirm", "testPwd"));
    Credentials creds = new UsernamePasswordCredentials("admin", "admin");
    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 = new JSONObject(json);
    assertNotNull(jsonObj);
View Full Code Here

    List<NameValuePair> postParams = new ArrayList<NameValuePair>();
    postParams.add(new NameValuePair(":name", userId));
    postParams.add(new NameValuePair("pwd", "testPwd"));
    postParams.add(new NameValuePair("pwdConfirm", "testPwd"));

    Credentials creds = new UsernamePasswordCredentials(testUserId, "testPwd");
    final String msg = "Expecting user " + testUserId + " to be able to create another user";
    H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, msg);
  }
View Full Code Here

  @After
  public void cleanup() throws Exception {
    H.tearDown();

    Credentials creds = new UsernamePasswordCredentials("admin", "admin");

    if (testFolderUrl != null) {
      //remove the test user if it exists.
      String postUrl = testFolderUrl;
      List<NameValuePair> postParams = new ArrayList<NameValuePair>();
View Full Code Here

    postParams.add(new NameValuePair("principalId", testUserId));
    postParams.add(new NameValuePair("privilege@jcr:read", "granted"));
    postParams.add(new NameValuePair("privilege@jcr:readAccessControl", "granted"));
    postParams.add(new NameValuePair("privilege@jcr:write", "denied"));
   
    Credentials adminCreds = new UsernamePasswordCredentials("admin", "admin");
    H.assertAuthenticatedPostStatus(adminCreds, postUrl, HttpServletResponse.SC_OK, postParams, null);
   
    String getUrl = testFolderUrl + ".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 = new JSONObject(json);
   
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.