Author: ozizka(a)redhat.com
Date: 2009-07-31 16:24:59 -0400 (Fri, 31 Jul 2009)
New Revision: 641
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/LoginBadPassTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/LoginBadUserTest.java
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
Log:
* Added login failure tests.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-07-30
22:31:56 UTC (rev 640)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-07-31
20:24:59 UTC (rev 641)
@@ -75,6 +75,12 @@
public static final String LOGIN_USERNAME = "admin";
public static final String LOGIN_PASSWORD = "admin";
+
+ public String getLoginUser() { return LOGIN_USERNAME; }
+ public String getLoginPass() { return LOGIN_PASSWORD; }
+
+
+
// Tab Menu IDs
public static final String SUMMARY_TAB = "summaryTab";
@@ -152,7 +158,7 @@
// Always press OK for confirm dialogs
wcSpec.getWebClient().setConfirmHandler(new SimpleConfirmHandler(true));
- wcSpec.setInitialRequestStrategy(new JoprLoginStrategy()); // logs in
+ wcSpec.setInitialRequestStrategy(new JoprLoginStrategy( this.getLoginUser(),
this.getLoginPass())); // logs in
JSFSession jsfSession = new JSFSession(wcSpec);
this.client = jsfSession.getJSFClientSession();
Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/LoginBadPassTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/LoginBadPassTest.java
(rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/LoginBadPassTest.java 2009-07-31
20:24:59 UTC (rev 641)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.jopr.jsfunit;
+
+import java.io.IOException;
+import java.util.Random;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Login test. Makes use of default login in EmbjoprTestCase::setUp()
+ *
+ * @author Ondrej Zizka
+ */
+public class LoginBadPassTest extends EmbjoprTestCase
+{
+
+ public static final String LOGIN_PASSWORD = "wrong-pass";
+ @Override public String getLoginPass() { return LOGIN_PASSWORD; }
+
+ public static final String LOGIN_ERROR_MSG = "log in attempt failed, please try
again";
+
+
+
+
+ /**
+ * @return the suite of tests being tested
+ */
+ public static Test suite() {
+ return new TestSuite( LoginBadPassTest.class );
+ }
+
+
+
+ public void testLoginFailed() throws IOException
+ {
+ ejtt.dumpPage(this.getClass().getSimpleName()+"+testLoginFailed-"+(new
Random().nextInt(100))+".html");
+
+ log.info("Checking the presence of error message: -
'"+LOGIN_ERROR_MSG+"'.");
+ assertTrue( "Page should contain login error message.",
client.getPageAsText().contains(LOGIN_ERROR_MSG) );
+
+ log.info("Checking the absence of the Logout link.");
+ assertFalse( "Page should noc contain \"Logout\" link.",
client.getPageAsText().contains("Logout") );
+
+ log.info("Checking that #{identity.username} is not set:
"+server.getManagedBeanValue("#{identity.username}") );
+ //assertFalse(, server.getManagedBeanValue("#{identity.username}") );
+ }
+
+
+}
\ No newline at end of file
Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/LoginBadUserTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/LoginBadUserTest.java
(rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/LoginBadUserTest.java 2009-07-31
20:24:59 UTC (rev 641)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.jopr.jsfunit;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Login test. Makes use of default login in EmbjoprTestCase::setUp()
+ *
+ * @author Ondrej Zizka
+ */
+public class LoginBadUserTest extends LoginBadPassTest
+{
+
+ public static final String LOGIN_USERNAME = "non-existent-user";
+ @Override public String getLoginUser() { return LOGIN_USERNAME; }
+
+
+
+ /**
+ * @return the suite of tests being tested
+ */
+ public static Test suite() {
+ return new TestSuite( LoginBadUserTest.class );
+ }
+
+
+}
\ No newline at end of file