geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r591459 - in /geronimo/server/trunk/testsuite/security-testsuite/test-security/src/test/java/org/apache/geronimo/testsuite/security: TestConsoleSecurity.java TestSecurity.java
Date Fri, 02 Nov 2007 20:59:42 GMT
Author: gawor
Date: Fri Nov  2 13:59:41 2007
New Revision: 591459

URL: http://svn.apache.org/viewvc?rev=591459&view=rev
Log:
added basic console security tests

Added:
    geronimo/server/trunk/testsuite/security-testsuite/test-security/src/test/java/org/apache/geronimo/testsuite/security/TestConsoleSecurity.java
  (with props)
Modified:
    geronimo/server/trunk/testsuite/security-testsuite/test-security/src/test/java/org/apache/geronimo/testsuite/security/TestSecurity.java

Added: geronimo/server/trunk/testsuite/security-testsuite/test-security/src/test/java/org/apache/geronimo/testsuite/security/TestConsoleSecurity.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/security-testsuite/test-security/src/test/java/org/apache/geronimo/testsuite/security/TestConsoleSecurity.java?rev=591459&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/security-testsuite/test-security/src/test/java/org/apache/geronimo/testsuite/security/TestConsoleSecurity.java
(added)
+++ geronimo/server/trunk/testsuite/security-testsuite/test-security/src/test/java/org/apache/geronimo/testsuite/security/TestConsoleSecurity.java
Fri Nov  2 13:59:41 2007
@@ -0,0 +1,83 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.geronimo.testsuite.security;
+
+
+import org.apache.geronimo.testsupport.SeleniumTestSupport;
+import org.testng.annotations.Test;
+
+public class TestConsoleSecurity extends SeleniumTestSupport {
+    
+    @Test
+    public void testLogin() throws Exception {
+        selenium.open("/console");
+        assertFalse(selenium.isTextPresent("Deploy New"));
+        selenium.type("j_username", "system");
+        selenium.type("j_password", "manager");
+        selenium.click("submit");
+        selenium.waitForPageToLoad("30000");
+        assertTrue(selenium.isTextPresent("Deploy New"));
+    }
+
+    @Test
+    public void testBadPasswordLogin() throws Exception {   
+        testFailure("system", "managerr");
+    }
+    
+    @Test
+    public void testBadUser() throws Exception {  
+        testFailure("doesnotexist", "managerr");
+    }
+    
+    @Test
+    public void testNullPasswordLogin() throws Exception {        
+        testFailure("system", null);
+    }
+    
+    @Test
+    public void testNullUserLogin() throws Exception {        
+        testFailure(null, "manager");
+    }
+    
+    @Test
+    public void testNullCredentialsLogin() throws Exception {        
+        testFailure(null, null);
+    }
+    
+    @Test
+    public void testEmptyCredentialsLogin() throws Exception {        
+        testFailure("", "");
+    }
+    
+    private void testFailure(String username, String password) throws Exception {
+        selenium.open("/console");
+        if (username != null) {
+            selenium.type("j_username", username);
+        }
+        if (password != null) {
+            selenium.type("j_password", password);
+        }
+        selenium.click("submit");
+        selenium.waitForPageToLoad("30000");
+        
+        assertTrue(selenium.isTextPresent("Invalid Username and"));
+    }
+    
+}

Propchange: geronimo/server/trunk/testsuite/security-testsuite/test-security/src/test/java/org/apache/geronimo/testsuite/security/TestConsoleSecurity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/trunk/testsuite/security-testsuite/test-security/src/test/java/org/apache/geronimo/testsuite/security/TestSecurity.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/security-testsuite/test-security/src/test/java/org/apache/geronimo/testsuite/security/TestSecurity.java?rev=591459&r1=591458&r2=591459&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/security-testsuite/test-security/src/test/java/org/apache/geronimo/testsuite/security/TestSecurity.java
(original)
+++ geronimo/server/trunk/testsuite/security-testsuite/test-security/src/test/java/org/apache/geronimo/testsuite/security/TestSecurity.java
Fri Nov  2 13:59:41 2007
@@ -23,10 +23,10 @@
 import org.apache.geronimo.testsupport.SeleniumTestSupport;
 import org.testng.annotations.Test;
 
-public class TestSecurity extends SeleniumTestSupport
-{
+public class TestSecurity extends SeleniumTestSupport {
+    
     @Test
-    public void testSecurity() throws Exception {
+    public void testLogin() throws Exception {
         selenium.open("/demo/protect/hello.html");
         selenium.type("j_username", "george");
         selenium.type("j_password", "bone");
@@ -35,5 +35,48 @@
         assertEquals("hello world.", selenium.getText("xpath=/html"));
     }
 
-
+    @Test
+    public void testBadPasswordLogin() throws Exception {   
+        testFailure("george", "bonee");
+    }
+    
+    @Test
+    public void testBadUser() throws Exception {  
+        testFailure("doesnotexist", "bonee");
+    }
+    
+    @Test
+    public void testNullPasswordLogin() throws Exception {        
+        testFailure("george", null);
+    }
+    
+    @Test
+    public void testNullUserLogin() throws Exception {        
+        testFailure(null, "bone");
+    }
+    
+    @Test
+    public void testNullCredentialsLogin() throws Exception {        
+        testFailure(null, null);
+    }
+    
+    @Test
+    public void testEmptyCredentialsLogin() throws Exception {        
+        testFailure("", "");
+    }
+    
+    private void testFailure(String username, String password) throws Exception {
+        selenium.open("/demo/protect/hello.html");
+        if (username != null) {
+            selenium.type("j_username", username);
+        }
+        if (password != null) {
+            selenium.type("j_password", password);
+        }
+        selenium.click("submit");
+        selenium.waitForPageToLoad("30000");
+        
+        assertTrue(selenium.isTextPresent("Authentication ERROR"));
+    }
+    
 }



Mime
View raw message