Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2889710EF5 for ; Tue, 5 Nov 2013 14:52:36 +0000 (UTC) Received: (qmail 12904 invoked by uid 500); 5 Nov 2013 14:49:39 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 12748 invoked by uid 500); 5 Nov 2013 14:49:26 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 12696 invoked by uid 99); 5 Nov 2013 14:49:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Nov 2013 14:49:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Nov 2013 14:49:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A603523888FE; Tue, 5 Nov 2013 14:48:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1539015 - /sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java Date: Tue, 05 Nov 2013 14:48:59 -0000 To: commits@sling.apache.org From: bdelacretaz@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131105144859.A603523888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bdelacretaz Date: Tue Nov 5 14:48:59 2013 New Revision: 1539015 URL: http://svn.apache.org/r1539015 Log: SLING-3230 - disable failing tests on Oak for now Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java?rev=1539015&r1=1539014&r2=1539015&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java Tue Nov 5 14:48:59 2013 @@ -16,6 +16,10 @@ */ package org.apache.sling.launchpad.webapp.integrationtest.userManager; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -28,52 +32,67 @@ import org.apache.commons.httpclient.Nam import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.sling.commons.json.JSONException; import org.apache.sling.commons.json.JSONObject; +import org.apache.sling.commons.testing.integration.HttpTest; +import org.apache.sling.commons.testing.junit.categories.JackrabbitOnly; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; /** * Tests for the 'updateAuthorizable' and 'changePassword' Sling Post * Operations on a user resource. */ -public class UpdateUserTest extends UserManagerTestUtil { +public class UpdateUserTest { String testUserId = null; + private final UserManagerTestUtil H = new UserManagerTestUtil(); - @Override - public void tearDown() throws Exception { + @Before + public void setup() throws Exception { + H.setUp(); + } + + @After + public void cleanup() throws Exception { if (testUserId != null) { //remove the test user if it exists. - String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".delete.html"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".delete.html"; List postParams = new ArrayList(); - assertAuthenticatedAdminPostStatus(postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedAdminPostStatus(postUrl, HttpServletResponse.SC_OK, postParams, null); } - super.tearDown(); + H.tearDown(); } + @Test public void testUpdateUser() throws IOException, JSONException { - testUserId = createTestUser(); + testUserId = H.createTestUser(); - String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".update.html"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".update.html"; List postParams = new ArrayList(); 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"); - assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); //fetch the user profile json to verify the settings - String getUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".json"; - assertAuthenticatedHttpStatus(creds, getUrl, HttpServletResponse.SC_OK, null); //make sure the profile request returns some data - String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".json"; + H.assertAuthenticatedHttpStatus(creds, getUrl, HttpServletResponse.SC_OK, null); //make sure the profile request returns some data + String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json); JSONObject jsonObj = new JSONObject(json); assertEquals("My Updated Test User", jsonObj.getString("displayName")); assertEquals("http://www.apache.org/updated", jsonObj.getString("url")); } + @Test + @Category(JackrabbitOnly.class) // TODO: fails on Oak public void testChangeUserPassword() throws IOException { - testUserId = createTestUser(); + testUserId = H.createTestUser(); - String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".changePassword.html"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".changePassword.html"; List postParams = new ArrayList(); postParams.add(new NameValuePair("oldPwd", "testPwd")); @@ -81,13 +100,14 @@ public class UpdateUserTest extends User postParams.add(new NameValuePair("newPwdConfirm", "testNewPwd")); Credentials creds = new UsernamePasswordCredentials(testUserId, "testPwd"); - assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); } + @Test public void testChangeUserPasswordWrongOldPwd() throws IOException { - testUserId = createTestUser(); + testUserId = H.createTestUser(); - String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".changePassword.html"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".changePassword.html"; List postParams = new ArrayList(); postParams.add(new NameValuePair("oldPwd", "wrongTestPwd")); @@ -96,13 +116,14 @@ public class UpdateUserTest extends User //Credentials creds = new UsernamePasswordCredentials(testUserId, "testPwd"); Credentials creds = new UsernamePasswordCredentials("admin", "admin"); - assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, postParams, null); + H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, postParams, null); } + @Test public void testChangeUserPasswordWrongConfirmPwd() throws IOException { - testUserId = createTestUser(); + testUserId = H.createTestUser(); - String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".changePassword.html"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".changePassword.html"; List postParams = new ArrayList(); postParams.add(new NameValuePair("oldPwd", "testPwd")); @@ -111,22 +132,23 @@ public class UpdateUserTest extends User //Credentials creds = new UsernamePasswordCredentials(testUserId, "testPwd"); Credentials creds = new UsernamePasswordCredentials("admin", "admin"); - assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, postParams, null); + H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, postParams, null); } /** * Test for SLING-1677 */ + @Test public void testUpdateUserResponseAsJSON() throws IOException, JSONException { - testUserId = createTestUser(); + testUserId = H.createTestUser(); - String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".update.json"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".update.json"; List postParams = new ArrayList(); 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 = getAuthenticatedPostContent(creds, postUrl, CONTENT_TYPE_JSON, postParams, HttpServletResponse.SC_OK); + 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); @@ -138,76 +160,80 @@ public class UpdateUserTest extends User * Test for SLING-2069 * @throws IOException */ + @Test public void testChangeUserPasswordAsAdministratorWithoutOldPwd() throws IOException { - testUserId = createTestUser(); + testUserId = H.createTestUser(); - String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".changePassword.html"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".changePassword.html"; List postParams = new ArrayList(); postParams.add(new NameValuePair("newPwd", "testNewPwd")); postParams.add(new NameValuePair("newPwdConfirm", "testNewPwd")); Credentials creds = new UsernamePasswordCredentials("admin", "admin"); - assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); } /** * Test for SLING-2069 * @throws IOException */ + @Test + @Category(JackrabbitOnly.class) // TODO: fails on Oak public void testChangeUserPasswordAsUserAdminMemberWithoutOldPwd() throws IOException { - testUserId = createTestUser(); - addUserToUserAdminGroup(testUserId); + testUserId = H.createTestUser(); + H.addUserToUserAdminGroup(testUserId); - String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".changePassword.html"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".changePassword.html"; List postParams = new ArrayList(); postParams.add(new NameValuePair("newPwd", "testNewPwd")); postParams.add(new NameValuePair("newPwdConfirm", "testNewPwd")); Credentials creds = new UsernamePasswordCredentials(testUserId, "testPwd"); - assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); } /** * Test for SLING-2072 * @throws IOException */ + @Test public void testDisableUser() throws IOException { - testUserId = createTestUser(); + testUserId = H.createTestUser(); //login before the user is disabled, so login should work List params = new ArrayList(); params.add(new NameValuePair("j_username", testUserId)); params.add(new NameValuePair("j_password", "testPwd")); params.add(new NameValuePair("j_validate", "true")); - HttpMethod post = assertPostStatus(HTTP_BASE_URL + "/j_security_check", HttpServletResponse.SC_OK, params, null); + HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check", HttpServletResponse.SC_OK, params, null); assertNull(post.getResponseHeader("X-Reason")); - httpClient.getState().clearCredentials(); - httpClient.getState().clearCookies(); + H.getHttpClient().getState().clearCredentials(); + H.getHttpClient().getState().clearCookies(); //update the user to disable it - String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".update.html"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".update.html"; List postParams = new ArrayList(); postParams.add(new NameValuePair(":disabled", "true")); postParams.add(new NameValuePair(":disabledReason", "Just Testing")); - assertAuthenticatedAdminPostStatus(postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedAdminPostStatus(postUrl, HttpServletResponse.SC_OK, postParams, null); //the user is now disabled, so login should fail - post = assertPostStatus(HTTP_BASE_URL + "/j_security_check", HttpServletResponse.SC_FORBIDDEN, params, null); + post = H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check", HttpServletResponse.SC_FORBIDDEN, params, null); assertNotNull(post.getResponseHeader("X-Reason")); - httpClient.getState().clearCredentials(); - httpClient.getState().clearCookies(); + H.getHttpClient().getState().clearCredentials(); + H.getHttpClient().getState().clearCookies(); //enable the user again postParams = new ArrayList(); postParams.add(new NameValuePair(":disabled", "false")); - assertAuthenticatedAdminPostStatus(postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedAdminPostStatus(postUrl, HttpServletResponse.SC_OK, postParams, null); //login after the user is enabled, so login should work - post = assertPostStatus(HTTP_BASE_URL + "/j_security_check", HttpServletResponse.SC_OK, params, null); + post = H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check", HttpServletResponse.SC_OK, params, null); assertNull(post.getResponseHeader("X-Reason")); - httpClient.getState().clearCredentials(); - httpClient.getState().clearCookies(); + H.getHttpClient().getState().clearCredentials(); + H.getHttpClient().getState().clearCookies(); } }