Author: bdelacretaz
Date: Thu Oct  3 07:15:53 2013
New Revision: 1528734

URL: http://svn.apache.org/r1528734
Log:
SLING-2788 - check /system/sling/info.sessionInfo.json after creating users

Modified:
    
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AbstractAuthenticatedTest.java
    
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java

Modified: 
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AbstractAuthenticatedTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AbstractAuthenticatedTest.java?rev=1528734&r1=1528733&r2=1528734&view=diff
==============================================================================
--- 
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AbstractAuthenticatedTest.java
 (original)
+++ 
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AbstractAuthenticatedTest.java
 Thu Oct  3 07:15:53 2013
@@ -229,6 +229,10 @@ public abstract class AbstractAuthentica
                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, 
+                "session info failed for user " + testUserId);
 
         return testUserId;
     }

Modified: 
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java?rev=1528734&r1=1528733&r2=1528734&view=diff
==============================================================================
--- 
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java
 (original)
+++ 
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java
 Thu Oct  3 07:15:53 2013
@@ -34,8 +34,7 @@ import org.apache.sling.commons.json.JSO
  */
 public class CreateUserTest extends AbstractUserManagerTest {
     private static Random random = new Random(System.currentTimeMillis());
-
-       String testUserId = null;
+    private String testUserId;
 
        @Override
        protected void tearDown() throws Exception {
@@ -57,26 +56,37 @@ public class CreateUserTest extends Abst
                </form>
         */
        public void testCreateUser() throws IOException, JSONException {
+           testUserId = "testUser" + random.nextInt() + 
System.currentTimeMillis();
         String postUrl = HTTP_BASE_URL + 
"/system/userManager/user.create.html";
-
-               testUserId = "testUser" + random.nextInt();
-               List<NameValuePair> postParams = new ArrayList<NameValuePair>();
+               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"));
-               Credentials creds = new UsernamePasswordCredentials("admin", 
"admin");
+               final Credentials creds = new 
UsernamePasswordCredentials("admin", "admin");
                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";
-               String json = getAuthenticatedContent(creds, getUrl, 
CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
-               assertNotNull(json);
-               JSONObject jsonObj = new JSONObject(json);
-               assertEquals(testUserId, jsonObj.getString("marker"));
-               assertFalse(jsonObj.has(":name"));
-               assertFalse(jsonObj.has("pwd"));
-               assertFalse(jsonObj.has("pwdConfirm"));
+               {
+               // fetch the user profile json to verify the settings
+               final String getUrl = HTTP_BASE_URL + 
"/system/userManager/user/" + testUserId + ".json";
+               final String json = getAuthenticatedContent(creds, getUrl, 
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 = HTTP_BASE_URL + 
"/system/sling/info.sessionInfo.json";
+            final String json = getAuthenticatedContent(newUserCreds, getUrl, 
CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+            assertNotNull(json);
+            final JSONObject jsonObj = new JSONObject(json);
+            assertEquals(testUserId, jsonObj.getString("userID"));
+        }
        }
 
        public void testCreateUserMissingUserId() throws IOException {
@@ -216,7 +226,8 @@ public class CreateUserTest extends Abst
                postParams.add(new NameValuePair("pwdConfirm", "testPwd"));
 
                Credentials creds = new UsernamePasswordCredentials(testUserId, 
"testPwd");
-               assertAuthenticatedPostStatus(creds, postUrl, 
HttpServletResponse.SC_OK, postParams, null);
+               final String msg = "Expecting user " + testUserId + " to be 
able to create another user";
+               assertAuthenticatedPostStatus(creds, postUrl, 
HttpServletResponse.SC_OK, postParams, msg);
        }
        
 }


Reply via email to