Author: vrockai
Date: 2009-06-18 07:33:53 -0400 (Thu, 18 Jun 2009)
New Revision: 13471
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/DashboardsTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java
Log:
[JBPORTAL-2392] - dozen of selenium input validation tests
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-06-17
21:29:16 UTC (rev 13470)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-06-18
11:33:53 UTC (rev 13471)
@@ -1,8 +1,6 @@
package org.jboss.portal.test.selenium;
import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -17,6 +15,11 @@
/** prefix for locator properties = dash. */
public String casePfx = "dash.";
+
+ private final String MSG_WINDOW_NAME_VALID =
getMess(casePfx+"msg.window.name.valid","is an invalid window name");
+ private final String MSG_PAGE_RENAME_VALID =
getMess(casePfx+"msg.page.rename.valid","is an invalid portal object
name");
+ private final String MSG_PAGE_NAME_VALID =
getMess(casePfx+"msg.page.name.valid","is an invalid page name");
+
private final String DIV_PORTET_EDITOR_TITLE = getLoc(casePfx +
"div.portlet.editor.title", "portlet-editor-title");
private final String HAND_R1 = getLoc(casePfx + "hand.r1",
"//html/body/div[2]/div/div/div[2]/div[2]/div/div/div[2]/div/div");
private final String HAND_L1 = getLoc(casePfx + "hand.l1",
"//html/body/div[2]/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr/td[2]/div");
@@ -33,7 +36,7 @@
private final String INP_PAGE_RENAME = getLoc(casePfx + "inp.page.rename",
"//input[contains(@id,'renameForm:newName')]");
private final String INP_WINDOW_NAME = getLoc(casePfx + "inp.window.name",
"//input[contains(@id,'windowForm:windowName')]");
private final String LINK_WEATHER_PORTLET = getLoc(casePfx +
"link.weather.portlet", "link=*WeatherPortlet*");
- private final String LINK_PORTL3 = getLoc(casePfx + "link.portl2",
"link=*WSRP admin portlet*");
+ private final String LINK_PORTL3 = getLoc(casePfx + "link.portl3",
"link=*WSRP admin portlet*");
private final String LINK_PORTL2 = getLoc(casePfx + "link.portl2",
"link=*Who's online portlet*");
private final String LINK_PORTL1 = getLoc(casePfx + "link.portl1",
"link=*Welcome portlet*");
private final String OPT_PORTL2 = getLoc(casePfx + "opt.portl2",
"IdentityUserPortletWindow");
@@ -420,6 +423,12 @@
Assert.assertTrue(selenium.isTextPresent("Gadgets powered by
Google"));
}
+ /**
+ * Testing input validation for page creation. Test navigates to configure
+ * dashboard interface and tries to create a new page on the dashboard with
+ * the XSS string. The XSS string is inputed into the create page input and
+ * after submitting it is asserted that the error message is present.
+ */
@Test(enabled = true)
public void testXssCreatePage() {
selenium.click(LNK_DASHBOARD);
@@ -432,9 +441,17 @@
selenium.type(INP_PAGENAME, XSS_STR1);
clickAndWait(SUB_CREATEPAGE);
- Assert.assertTrue(selenium.isTextPresent("is an invalid page
name"),"Message \""+"is an invalid page name"+"\"
not found.");
+ Assert.assertTrue(selenium.isTextPresent(MSG_PAGE_NAME_VALID),"Message
\""+MSG_PAGE_NAME_VALID+"\" not found.");
}
+ /**
+ * Testing input validation for page renaming. Test navigates to configure
+ * dashboard interface and tries to rename a page on the dashboard with the
+ * XSS string. Firstly new page named "DashXSSToRenamePage" is created. Then
+ * it is tried to be renamed to XSS string by typing it into rename input.
+ * After submitting it is asserted that the validation error message is
+ * present on the screen
+ */
@Test(enabled = true)
public void testXssRenamePage() {
selenium.click(LNK_DASHBOARD);
@@ -467,9 +484,18 @@
selenium.click(SUB_PAGE_RENAME);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid portal object
name"),"Message: \""+"is an invalid portal object
name"+"\" not found");
+ Assert.assertTrue(selenium.isTextPresent(MSG_PAGE_RENAME_VALID),"Message:
\""+MSG_PAGE_RENAME_VALID+"\" not found");
}
+ /**
+ * Testing input validation for window creation. Test navigates to configure
+ * dashboard interface and select previously selected "DashTestPage" page.
+ * Then it clicks on the portlet link defined in property file as
+ * (prefix+)"link.portl3". XSS string is inputted into the window name input
+ * and after adding the portlet to the center region of layout (clicking on
+ * the particular submit) it is asserted that the validation error message
+ * is present on the screen.
+ */
@Test(enabled = true, dependsOnMethods = {"testCreatePage"})
public void testXssWindowName() {
selenium.click(LNK_DASHBOARD);
@@ -486,7 +512,7 @@
selenium.click(SUB_ADDCENTER);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid window name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_WINDOW_NAME_VALID));
}
//
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=143023
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-06-17
21:29:16 UTC (rev 13470)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-06-18
11:33:53 UTC (rev 13471)
@@ -16,13 +16,16 @@
@Test(groups = { "admin_ui" }, enabled = true)
public class IdentityAdminTestCase extends JBossPortalSeleniumTestCase {
- private static final String LNK_MEMBERS = "link=Members";
-
- private static final String LNK_ADMIN = "link=Admin";
-
/** prefix for locator properties */
public String casePfx = "iden.man.";
+ private final String MSG_ROLE_DISPNAME_VALID =
getMess(casePfx+"msg.role.dispname.valid","is an invalid role display
name");
+ private final String MSG_ROLE_NAME_VALID =
getMess(casePfx+"msg.role.name.valid","is an invalid role name");
+ private final String MSG_EDIT_USER_VALID =
getMess(casePfx+"msg.edit.user.valid","is an invalid value");
+
+ private final String LNK_MEMBERS =
getLoc(casePfx+"lnk.members","link=Members");
+ private final String LNK_ADMIN =
getLoc(casePfx+"lnk.admin","link=Admin");
+
private final String INP_USER_SEARCH_PREV = getLoc(casePfx +
"inp.user.search.prev",
"//input[contains(@id,'search-user-form1:prev-page')]");
private final String INP_USER_SEARCH_NEXT = getLoc(casePfx +
"inp.user.search.next",
"//input[contains(@id,'search-user-form1:next-page')]");
@@ -547,7 +550,7 @@
selenium.type(INP_ROLEDISNAME, "diddi");
clickAndWait(SUB_ROLE_CREATE);
- Assert.assertTrue(selenium.isTextPresent("is an invalid role name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_ROLE_NAME_VALID));
openAndWait(ADR_PORTAL);
clickIfVisible(LNK_ADMIN);
@@ -562,7 +565,7 @@
clickAndWait(SUB_ROLE_CREATE);
- Assert.assertTrue(selenium.isTextPresent("is an invalid role display
name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_ROLE_DISPNAME_VALID));
}
@@ -604,7 +607,7 @@
selenium.click(SUB_EDIT_ROLE_SUBMIT);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid role display
name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_ROLE_DISPNAME_VALID));
deleteRole(roleName);
}
@@ -628,46 +631,46 @@
// firstname
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:givenname')]",
XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:givenname')]",
XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// lastname
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:familyname')]",
XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:familyname')]",
XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// location
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:location')]", XSS_STR1,
SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:location')]", XSS_STR1,
SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// skype
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:skype')]", XSS_STR1,
SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:skype')]", XSS_STR1,
SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// icq
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:icq')]", XSS_STR1,
SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:icq')]", XSS_STR1,
SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// aim
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:aim')]", XSS_STR1,
SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:aim')]", XSS_STR1,
SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// msn
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:msnm')]", XSS_STR1,
SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:msnm')]", XSS_STR1,
SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// yahoo
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:yim')]", XSS_STR1,
SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:yim')]", XSS_STR1,
SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// xmmp
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:xmmp')]", XSS_STR1,
SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:xmmp')]", XSS_STR1,
SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// homepage
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:homepage')]", XSS_STR1,
SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:homepage')]", XSS_STR1,
SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// occup
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:occupation')]",
XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:occupation')]",
XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// hobby
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:interests')]",
XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:interests')]",
XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// sign
goToEdit(userName, userMail);
- testInput("//textarea[contains(@id,'profile-form:signature')]",
XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//textarea[contains(@id,'profile-form:signature')]",
XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// extra
goToEdit(userName, userMail);
- testInput("//textarea[contains(@id,'profile-form:extra')]", XSS_STR1,
SUB_EDIT_PROF, "is an invalid value");
+ testInput("//textarea[contains(@id,'profile-form:extra')]", XSS_STR1,
SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
deleteUser(userName, userMail);
}
@@ -732,7 +735,7 @@
private void testInput(String inpLoc, String inpStr, String subLoc, String mes) {
selenium.type(inpLoc, inpStr);
clickAndWait(subLoc);
- Assert.assertTrue(selenium.isTextPresent(mes));
+ Assert.assertTrue(selenium.isTextPresent(mes),"input validation error message is
missing or other than expected.");
}
/**
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-06-17
21:29:16 UTC (rev 13470)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-06-18
11:33:53 UTC (rev 13471)
@@ -13,9 +13,11 @@
@Test(groups = { "login" }, enabled = true)
public class UserLoginTestCase extends JBossPortalSeleniumTestCase {
+
/** prefix for locator properties = user.login. */
public final String casePfx = "user.login.";
+ private final String MSG_LOGIN_WRONGPASS =
getMess(casePfx+"msg,login.wrongpass","The user doesn't exist or the
password is incorrect");
private final String ADR_PORTAL = getLoc(casePfx + "adr.portal",
"/portal");
private final String FRM_MAIN = getLoc(casePfx + "frm.main",
"relative=up");
private final String SUB_CANCEL = getLoc(casePfx + "sub.portal",
"cancel");
@@ -238,8 +240,8 @@
*
* Try to login with user/us2er and check that you are not logged in.
*/
- @Test(enabled = true, description = "xss attack")
- public void testXssAttack() {
+ @Test(enabled = true, description = "xss login")
+ public void testXssLogin() {
final String loginName = "user";
final String loginPass = "us2er";
@@ -257,7 +259,7 @@
selenium.fireEvent(INP_PASSWORD, "keydown");
selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("The user doesn't exist or the
password is incorrect"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_LOGIN_WRONGPASS));
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -273,9 +275,8 @@
selenium.fireEvent(INP_PASSWORD, "keydown");
selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("The user doesn't exist or the
password is incorrect"));
-
- Assert.assertTrue(selenium.isTextPresent("The user doesn't exist or the
password is incorrect "), "\"Logged in as\" message missing.");
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_LOGIN_WRONGPASS), "\"Logged in
as\" message missing.");
}
}
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2009-06-17
21:29:16 UTC (rev 13470)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2009-06-18
11:33:53 UTC (rev 13471)
@@ -18,6 +18,18 @@
/** prefix for locator properties */
public static String casePfx = "test.wsrp.";
+
+ private final String MSG_PROD_SAVED =
getMess(casePfx+"msg.prod.saved","Producer configuration successfully
saved!");
+ private final String MSG_PROP_REGPOL_VALID =
getMess(casePfx+"msg.prod.regpol.valid","is an invalid class nam");
+ private final String MSG_PROP_REGPROP_VALID =
getMess(casePfx+"msg.prod.regprop.valid","is an invalid class nam");
+ private final String MSG_PROD_NAME_VALID
=getMess(casePfx+"msg.prod.name.valid","error");
+ private final String MSG_PROD_LAB_VALID =
getMess(casePfx+"msg.prod.lab.valid","error");
+ private final String MSG_PROD_HINT_VALID
=getMess(casePfx+"msg.prod.hint.valid","error");
+
+ private final String MSG_CONS_REGVAL_VALID =
getMess(casePfx+"msg.cons.regval.valid","An unexpected error
occured");
+ private final String MSG_CONS_EXP_VALID =
getMess(casePfx+"msg.cons.exp.valid","must be a number between");
+ private final String MSG_CONS_ADD_VALID =
getMess(casePfx+"msg.cons.add.valid","Require a well-formed URL");
+ private final String MSG_CONS_NAME_VALID =
getMess(casePfx+"msg.cons.name.valid","is an invalid Consumer name");
private final String INP_CONSUMER_NAME = getLoc(casePfx + "inp.consumer.name",
"//input[contains(@id,'edit-cons-form:id')]");
private final String INP_PRODID = getLoc(casePfx + "inp.prodid",
"//input[contains(@id,'edit-cons-form:id')]");
@@ -92,12 +104,7 @@
// selenium extension
@Test(enabled = true, description = "Creating a standard BEA consumer.")
public void testCreateBeaConsumer() {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
selenium.type(INPUT_CREATECONS, "BEA");
@@ -130,12 +137,7 @@
@Test(enabled = true, dependsOnMethods = { "testCreateBeaConsumer",
"testBeaConsumerDeregister" }, description = "Standard BEA consumer
registering.")
public void testBeaConsumerRegister() {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
int r = findTableRow(WSRP_CONSUMER_TABLE, "BEAreg", 0) - 1;
@@ -162,12 +164,7 @@
public void testBeaConsumerDeregister() {
createConsumer("BEAreg", "100",
"http://wsrp.bea.com:7001/producer/producer?WSDL");
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
@@ -190,13 +187,7 @@
*/
@Test(enabled = true, dependsOnMethods = { "testCreateBeaConsumer",
"testBeaConsumerDeactivate" }, description = "Standard BEA consumer
activating.")
public void testBeaConsumerActivate() {
- selenium.open("/portal/");
-
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
int r = findTableRow(WSRP_CONSUMER_TABLE, "BEAact", 0) - 1;
@@ -222,12 +213,7 @@
createConsumer("BEAact", "100",
"http://wsrp.bea.com:7001/producer/producer?WSDL");
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
@@ -262,12 +248,7 @@
public void testBeaConsumerDelete() {
createConsumer("BEAdel", "100",
"http://wsrp.bea.com:7001/producer/producer?WSDL");
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
@@ -310,12 +291,7 @@
// TODO registration policy properties tests missing
@Test(enabled = true, description = "Basic configuring of WSRP producer.")
public void testConfigureProducer() {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_PRODCONF);
Assert.assertTrue(selenium.isTextPresent("Producer configuration"));
@@ -328,7 +304,7 @@
selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Producer configuration successfully
saved!"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROD_SAVED));
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(ID_LINK_PRODCONF);
@@ -351,12 +327,7 @@
final String name = "renameMe";
final String nameNew = "renameNewMe";
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
@@ -391,19 +362,25 @@
Assert.assertTrue(r > 0, "Renamed consumer not found in table");
}
- /*
- *
+ /**
+ * Tests input validation while managing WSRP consumers. Firstly, the
+ * testcase navigates to WSRP consumers page. It types XSS string into
+ * "Create a consumer named:" input and clicks "Create consumer".
The error
+ * message on the screen is asserted. Then it types a valid name
+ * ("XssBeaConsumer") into the input and clicks on create consumer. On newly
+ * opened page there are three new inputs: producer id, cache expiration and
+ * endpoint configuration. Into each of that inputs the XSS string is
+ * inputed in three steps and after clicking "Refresh and save" in each
+ * step, the presence of validation error message is asserted. Then the
+ * consumer is created by filling in valid data and XSS is typed into newly
+ * opened input "Registration information:". After clicking update
+ * properties, the validation error message is asserted again.
*/
@Test(enabled = true)
public void testXssConsumerManage() {
String beaName = "XssBeaConsumer";
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
@@ -412,7 +389,7 @@
selenium.click(SUBMIT_CREATECONS);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid Consumer name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_CONS_NAME_VALID),"validation error
message missing or other than expected.");
selenium.type(INPUT_CREATECONS, beaName);
@@ -424,23 +401,22 @@
selenium.click(SUBMIT_REFRESHSAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Require a well-formed URL"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_CONS_ADD_VALID),"validation error
message missing or other than expected.");
selenium.type(INPUT_CACHEEXP, XSS_STR1);
selenium.type(INPUT_CONSWSDL,
"http://wsrp.bea.com:7001/producer/producer?WSDL");
selenium.click(SUBMIT_REFRESHSAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("must be a number between"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_CONS_EXP_VALID),"validation error
message missing or other than expected.");
- selenium.setSpeed("5000");
selenium.type(INP_PRODID, XSS_STR1);
selenium.type(INPUT_CACHEEXP, "600");
selenium.type(INPUT_CONSWSDL,
"http://wsrp.bea.com:7001/producer/producer?WSDL");
selenium.click(SUBMIT_REFRESHSAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid Consumer name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_CONS_NAME_VALID),"validation error
message missing or other than expected.");
selenium.type(INP_PRODID, beaName);
selenium.type(INPUT_CACHEEXP, "600");
@@ -452,11 +428,29 @@
selenium.click(SUB_CONS_REGVAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("An unexpected error occured"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_CONS_REGVAL_VALID),"validation error
message missing or other than expected.");
}
- /*
- *
+ private void goToWSRP() {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=WSRP");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+
+ /**
+ * Tests the input validation properties of WSRP producers part of JBP. The
+ * test is navigated into producers part of WSRP interface. The XSS string
+ * is typed in registration policy input and after clicking save, is it
+ * asserted, that the validation error message is present. The XSS string is
+ * typed in "Registration property validator class name" input and after
+ * clicking save, is it asserted, that the validation error message is
+ * present. Valid inputs are saved to three inputs of
+ * "registration properties" and they are saved. Then in three steps each of
+ * this input is filled with the XSS string and after clicking save it is
+ * asserted, that the validation error message is present.
*/
@Test(enabled = true)
public void testXssProducerManage() {
@@ -465,21 +459,15 @@
selenium.type("//input[contains(@id,'producer-form:registrationPolicy')]",
XSS_STR1);
selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid class nam"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROP_REGPOL_VALID),"validation error
message missing or other than expected.");
goToProducers();
selenium.type("//input[contains(@id,'producer-form:validator')]",
XSS_STR1);
selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid class nam"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROP_REGPROP_VALID),"validation error
message missing or other than expected.");
- // properties
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_PRODCONF);
Assert.assertTrue(selenium.isTextPresent("Producer configuration"));
@@ -492,34 +480,43 @@
selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Producer configuration successfully
saved!"));
- clickIfVisible(ID_LINK_CONSCONF);
- clickIfVisible(ID_LINK_PRODCONF);
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROD_SAVED),"validation error message
missing or other than expected.");
+
+ selenium.type(INPUT_PROPNAME, XSS_STR1);
+ selenium.type(INPUT_PROPLABEL, "testProp label");
+ selenium.type(INPUT_PROPHINT, "tetsPropHint");
- Assert.assertEquals("testProp", selenium.getValue(INPUT_PROPNAME));
- Assert.assertEquals("testProp label", selenium.getValue(INPUT_PROPLABEL));
- Assert.assertEquals("tetsPropHint", selenium.getValue(INPUT_PROPHINT));
- }
+ selenium.click(SUB_PROD_SAVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROD_NAME_VALID),"validation error
message missing or other than expected.");
+
+ selenium.type(INPUT_PROPNAME, "testProp");
+ selenium.type(INPUT_PROPLABEL, XSS_STR1);
+ selenium.type(INPUT_PROPHINT, "tetsPropHint");
- private void goToProducers() {
- selenium.open("/portal/");
+ selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROD_LAB_VALID),"validation error
message missing or other than expected.");
+
+ selenium.type(INPUT_PROPNAME, "testProp");
+ selenium.type(INPUT_PROPLABEL, "testProp label");
+ selenium.type(INPUT_PROPHINT, XSS_STR1);
+
+ selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROD_HINT_VALID),"validation error
message missing or other than expected.");
+
+ }
+ private void goToProducers() {
+ goToWSRP();
+
clickIfVisible(ID_LINK_PRODCONF);
Assert.assertTrue(selenium.isTextPresent("Producer configuration"));
}
private void createConsumer(String name, String timeout, String address) {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
selenium.type(INPUT_CREATECONS, name);
selenium.click(SUBMIT_CREATECONS);
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java 2009-06-17
21:29:16 UTC (rev 13470)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java 2009-06-18
11:33:53 UTC (rev 13471)
@@ -17,9 +17,17 @@
/** prefix for locator properties = cms.dir.*/
public final String casePfx = "cms.dir.";
+
+ private final String MSG_INV_DESC = getMess(casePfx+"msg.inv.desc","A
value below is invalid");
+ private final String MSG_INV_NAME =
getMess(casePfx+"msg.inv.name","Folder Name is invalid");
+ private final String LAB_ACT_CREATE_FOLDER = getLoc(casePfx+"","Create
Folder");
+ private final String INP_DIR_CANCEL = getLoc(casePfx+"","cancel");
+ private final String INP_DIR_SUB = getLoc(casePfx+"","submit");
+ private final String INP_DIR_DESC =
getLoc(casePfx+"","newcollectiondescription");
+ private final String INP_DIR_NAME =
getLoc(casePfx+"","newcollectionname");
private final String SEL_CMS_ACTION = getLoc(casePfx + "sel.cms.action",
"//div[@id='center']/div/div/div[1]/div/select");
private final String ADR_CMS_INTERFACE = getLoc(casePfx + "adr.cms.interface",
"/portal/auth/portal/admin/CMS");
-
+
private final String defaultDirName = "default";
private final String tempDirName = "tempDir";
private final String copyDirName = "copySrc";
@@ -51,43 +59,37 @@
// canceling of creating
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
selenium.open(ADR_CMS_INTERFACE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent(tempDirName), "Test folder is already
present.");
- selenium.select(SEL_CMS_ACTION, "label=Create Folder");
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("newcollectionname", tempDirName);
- selenium.type("newcollectiondescription", "test folder");
- selenium.click("cancel");
+ selenium.type(INP_DIR_NAME, tempDirName);
+ selenium.type(INP_DIR_DESC, "test folder");
+ selenium.click(INP_DIR_CANCEL);
// really creating
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
selenium.open(ADR_CMS_INTERFACE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent(tempDirName), "Test folder is already
present.");
- selenium.select(SEL_CMS_ACTION, "label=Create Folder");
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("newcollectionname", tempDirName);
- selenium.type("newcollectiondescription", "test folder");
- selenium.click("submit");
+ selenium.type(INP_DIR_NAME, tempDirName);
+ selenium.type(INP_DIR_DESC, "test folder");
+ selenium.click(INP_DIR_SUB);
// assuring that the directory is created
@@ -101,6 +103,64 @@
}
/**
+ * Testing input validation for inputs in directory creation. Test navigates
+ * to create new directory interface. Xss string is filled into directory
+ * name and valid string is filled into directory description input. After
+ * submit it is asserted, that error message about invalid name is present.
+ * Valid string is filled into directory name and XSS string is filled into
+ * directory description input. After submit it is asserted, that error
+ * message about invalid description is present.
+ */
+ @Test(enabled = true, description = "Xss directory creation.")
+ public void testXssCreateDirectory() {
+
+ // XSS name
+
+ selenium.open(ADR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ goToCms();
+
+ selenium.open(ADR_CMS_INTERFACE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertFalse(selenium.isTextPresent(tempDirName), "Test folder is already
present.");
+
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+
+ selenium.type(INP_DIR_NAME, XSS_STR1);
+ selenium.type(INP_DIR_DESC, "test folder");
+ selenium.click(INP_DIR_SUB);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_INV_NAME), "Input validation for name
is missing.");
+ // XSS description
+
+ selenium.click(INP_DIR_CANCEL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+ selenium.type(INP_DIR_NAME, tempDirName);
+ selenium.type(INP_DIR_DESC, XSS_STR1);
+ selenium.click(INP_DIR_SUB);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_INV_DESC), "Input validation for
description is missing.");
+ }
+
+ private void goToCms() {
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=CMS");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+
+
+ /**
* Deletes a directory.
*
* With action selector an action to delete a directory is chosen. The directory had to
be deleted was created with {@link CMSDirectoryTestCase#testCreateDirectory()}.
@@ -112,10 +172,7 @@
// firstly cancel the delete process
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
Assert.assertTrue(selenium.isElementPresent("link=" + tempDirName));
selenium.select(takeAction(tempDirName) + "/select",
"label=Delete");
@@ -127,16 +184,13 @@
Assert.assertTrue(selenium.isTextPresent("Confirm Deletion of /" +
tempDirName));
Assert.assertTrue(selenium.isTextPresent("WARNING! You will not be able to undo
these change!"));
Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this
resource?"));
- selenium.click("cancel");
+ selenium.click(INP_DIR_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
// really deleting
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
Assert.assertTrue(selenium.isElementPresent("link=" + tempDirName));
selenium.select(takeAction(tempDirName) + "/select",
"label=Delete");
@@ -148,16 +202,13 @@
Assert.assertTrue(selenium.isTextPresent("Confirm Deletion of /" +
tempDirName));
Assert.assertTrue(selenium.isTextPresent("WARNING! You will not be able to undo
these change!"));
Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this
resource?"));
- selenium.click("submit");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
// assuring that the deletition was processed
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
Assert.assertFalse(selenium.isElementPresent("link=" + tempDirName));
}
@@ -170,22 +221,19 @@
*/
@Test(enabled = true, dependsOnMethods = "testCreateDirectory", description =
"Copying of directory.")
public void testCopyDirectory() {
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
- selenium.select(SEL_CMS_ACTION, "label=Create Folder");
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("newcollectionname"));
- Assert.assertTrue(selenium.isElementPresent("newcollectiondescription"));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_NAME));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_DESC));
Assert.assertEquals("Confirm Directory Creation",
selenium.getText("//div[@id='center']/div/h3"));
- selenium.type("newcollectionname", copyDirName);
- selenium.type("newcollectiondescription", "source folder for
copy");
- selenium.click("submit");
+ selenium.type(INP_DIR_NAME, copyDirName);
+ selenium.type(INP_DIR_DESC, "source folder for copy");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals(copyDirName,
selenium.getText("//div[@id='center']/div/div/ul/li[3]"));
@@ -198,7 +246,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=" + defaultDirName);
- selenium.click("submit");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals("copySrc",
selenium.getText("//div[@id='center']/div/div/ul/li[5]"));
Assert.assertTrue(selenium.isElementPresent("link=" + defaultDirName));
@@ -221,22 +269,19 @@
public void testCopyCancelDirectory() {
String copyCancelDirName = "L" + "copyLDirName" +
"Cancel";
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
- selenium.select(SEL_CMS_ACTION, "label=Create Folder");
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("newcollectionname"));
- Assert.assertTrue(selenium.isElementPresent("newcollectiondescription"));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_NAME));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_DESC));
Assert.assertEquals("Confirm Directory Creation",
selenium.getText("//div[@id='center']/div/h3"));
- selenium.type("newcollectionname", copyCancelDirName);
- selenium.type("newcollectiondescription", "source folder for
copy");
- selenium.click("submit");
+ selenium.type(INP_DIR_NAME, copyCancelDirName);
+ selenium.type(INP_DIR_DESC, "source folder for copy");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Home");
@@ -247,7 +292,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=" + defaultDirName);
- selenium.click("cancel");
+ selenium.click(INP_DIR_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isElementPresent("link=" + copyCancelDirName));
@@ -266,23 +311,19 @@
*/
@Test(enabled = true, dependsOnMethods = "testCreateDirectory", description =
"Moving a directory.")
public void testMoveDirectory() {
- // selenium.setSpeed("3000");
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
- selenium.select(SEL_CMS_ACTION, "label=Create Folder");
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("newcollectionname"));
- Assert.assertTrue(selenium.isElementPresent("newcollectiondescription"));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_NAME));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_DESC));
Assert.assertEquals("Confirm Directory Creation",
selenium.getText("//div[@id='center']/div/h3"));
- selenium.type("newcollectionname", moveDirName);
- selenium.type("newcollectiondescription", "source folder for
move");
- selenium.click("submit");
+ selenium.type(INP_DIR_NAME, moveDirName);
+ selenium.type(INP_DIR_DESC, "source folder for move");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals(moveDirName,
selenium.getText("//div[@id='center']/div/div/ul/li[3]"));
@@ -297,7 +338,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=" + defaultDirName);
- selenium.click("submit");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals(moveDirName,
selenium.getText("//div[@id='center']/div/div/ul/li[5]"));
@@ -321,22 +362,19 @@
public void testMoveCancelDirectory() {
String moveCancelDirName = "X" + "moveXDirName" +
"Cancel";
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
- selenium.select(SEL_CMS_ACTION, "label=Create Folder");
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("newcollectionname"));
- Assert.assertTrue(selenium.isElementPresent("newcollectiondescription"));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_NAME));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_DESC));
Assert.assertEquals("Confirm Directory Creation",
selenium.getText("//div[@id='center']/div/h3"));
- selenium.type("newcollectionname", moveCancelDirName);
- selenium.type("newcollectiondescription", "source folder for
move");
- selenium.click("submit");
+ selenium.type(INP_DIR_NAME, moveCancelDirName);
+ selenium.type(INP_DIR_DESC, "source folder for move");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Home");
@@ -347,7 +385,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=" + defaultDirName);
- selenium.click("cancel");
+ selenium.click(INP_DIR_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java 2009-06-17
21:29:16 UTC (rev 13470)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java 2009-06-18
11:33:53 UTC (rev 13471)
@@ -19,6 +19,16 @@
/** prefix for locator properties = cms.file. */
private final String casePfx = "cms.file.";
+ private final String MSG_VAL_INVALID_FILENAME =
getMess("msg.val.invalid.filename","A value below is invalid");
+ private final String MSG_VAL_INVALID_DESC =
getMess("msg.val.invalid.desc","A value below is invalid");
+ private final String MSG_VAL_INVALID_TITLE =
getMess("msg.val.invalid.title","A value below is invalid");
+ private final String SEL_ACTION = getLoc(casePfx +
"sel.action","//div[@id='center']/div/div/div[1]/div/select");
+ private final String INP_FC_SAVE = getLoc(casePfx +
"inp.fc.save","save");
+ private final String INP_FC_LANGUAGE = getLoc(casePfx +
"inp.fc.language","language");
+ private final String INP_FC_TITLE = getLoc(casePfx +
"inp.fc.title","title");
+ private final String INP_FC_DESC = getLoc(casePfx +
"inp.fc.desc","description");
+ private final String INP_FC_FILENAME = getLoc(casePfx +
"inp.fc.filename","filename");
+
private final String TBL_CMS_FILEVER = getLoc(casePfx + "tbl.cms.filever",
"//div[@id='center']/div/div/table");
public final String TBL_CMS_FILE = getLoc(casePfx + "tbl.cms.file",
"//div[@id='center']/div/div/div[3]/table");
public final String TBL_FILE_PENDING = getLoc(casePfx + "tbl.file.pending",
"//div[@id='center']/div/div/table[2]");
@@ -53,7 +63,6 @@
Assert.assertTrue(selenium.isElementPresent("link=private"));
Assert.assertTrue(selenium.isElementPresent("link=index.html"));
Assert.assertTrue(selenium.isElementPresent("link=project.html"));
- // Assert.assertTrue(selenium.isElementPresent("link=support.html"));
selenium.click("link=index.html");
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isElementPresent("link=text/html"));
@@ -136,14 +145,14 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[1]/div/select",
"label=Create File");
+ selenium.select(SEL_ACTION, "label=Create File");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("filename", "newFile");
- selenium.type("description", "newFile description");
- selenium.type("title", "newFile title");
- selenium.select("language", "label=Czech");
- selenium.click("save");
+ selenium.type(INP_FC_FILENAME, "newFile");
+ selenium.type(INP_FC_DESC, "newFile description");
+ selenium.type(INP_FC_TITLE, "newFile title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
/*
* Assert.assertTrue(selenium.isElementPresent(TBL_FILE_PENDING));
@@ -169,9 +178,58 @@
}
/**
- * Editing of a file. File name "file2edit" is created and then edited.
Nothing is changed, but the file is saved again. It is asserted, that the version
- * got incremented.
+ * Tests input validation in file creation interface. Test navigates to file
+ * creation interface. It inputs XSS string into filename input and valid
+ * string to others inputs. After clicking saved it is asserted that error
+ * message about non valid name is present. Then it inputs XSS string into
+ * file description input and valid string to others inputs. After clicking
+ * saved it is asserted that error message about non valid description is
+ * present. Then it inputs XSS string into file title input and valid string
+ * to others inputs. After clicking saved it is asserted that error message
+ * about non valid title is present.
*/
+ @Test(enabled = true, description = "Simple file creation input validation.")
+ public void testXssCreateFile() {
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=CMS");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_ACTION, "label=Create File");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+
+ selenium.type(INP_FC_FILENAME, XSS_STR1);
+ selenium.type(INP_FC_DESC, "newFile description");
+ selenium.type(INP_FC_TITLE, "newFile title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_VAL_INVALID_FILENAME), "Input
validation for filename is missing.");
+
+ selenium.type(INP_FC_FILENAME, "newFile");
+ selenium.type(INP_FC_DESC, XSS_STR1);
+ selenium.type(INP_FC_TITLE, "newFile title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_VAL_INVALID_DESC), "Input validation
for file description is missing.");
+
+ selenium.type(INP_FC_FILENAME, "newFile");
+ selenium.type(INP_FC_DESC, "newFile description");
+ selenium.type(INP_FC_TITLE, XSS_STR1);
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_VAL_INVALID_TITLE), "Input validation
for file title is missing.");
+
+ }
+
+ /**
+ * Editing of a file. File name "file2edit" is created and then edited.
+ * Nothing is changed, but the file is saved again. It is asserted, that the
+ * version got incremented.
+ */
@Test(enabled = true, description = "Editing of a file.")
public void testEditFile() {
@@ -179,14 +237,14 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[1]/div/select",
"label=Create File");
+ selenium.select(SEL_ACTION, "label=Create File");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("filename", "file2edit");
- selenium.type("description", "file2edit description");
- selenium.type("title", "file2edit title");
- selenium.select("language", "label=Czech");
- selenium.click("save");
+ selenium.type(INP_FC_FILENAME, "file2edit");
+ selenium.type(INP_FC_DESC, "file2edit description");
+ selenium.type(INP_FC_TITLE, "file2edit title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
int row = findTableRow(TBL_CMS_FILEVER, "1.0", 2) + 1;
@@ -199,7 +257,7 @@
selenium.click("link=text/plain");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("save");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("1.1"));
Assert.assertTrue(selenium.isElementPresent("//div[@id='center']/div/div/table/tbody/tr[5]/td[3]/img"));
@@ -211,8 +269,10 @@
}
/**
- * Creation of an existing file. The file named "existingFile" is created.
Then the system tries to create the same file again.
- * It is asserted that instead of creating a new instance of such a file, only its
version is updated.
+ * Creation of an existing file. The file named "existingFile" is created.
+ * Then the system tries to create the same file again. It is asserted that
+ * instead of creating a new instance of such a file, only its version is
+ * updated.
*/
@Test(enabled = true, dependsOnMethods = "testDeleteFile", description =
"Creation of an existing file.")
public void testCreateExistingFile() {
@@ -224,14 +284,14 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[1]/div/select",
"label=Create File");
+ selenium.select(SEL_ACTION, "label=Create File");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("filename", "existingFile");
- selenium.type("description", "existingFile description");
- selenium.type("title", "existingFile title");
- selenium.select("language", "label=Czech");
- selenium.click("save");
+ selenium.type(INP_FC_FILENAME, "existingFile");
+ selenium.type(INP_FC_DESC, "existingFile description");
+ selenium.type(INP_FC_TITLE, "existingFile title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals("Czech", selenium.getText("link=Czech"));
Assert.assertEquals("text/plain",
selenium.getText("link=text/plain"));
@@ -246,8 +306,10 @@
}
/**
- * File creation and moving to default directory. File named "fileToMove" is
created in the root directory. Then the file is moved into the default directory.
- * At the end it is asserted, that file is appearing in the "default"
directory, but it's not existing in the root directory.
+ * File creation and moving to default directory. File named "fileToMove" is
+ * created in the root directory. Then the file is moved into the default
+ * directory. At the end it is asserted, that file is appearing in the
+ * "default" directory, but it's not existing in the root directory.
*/
@Test(enabled = true, description = "File creation and moving to default
directory.")
public void testMoveFile() {
@@ -255,14 +317,14 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[1]/div/select",
"label=Create File");
+ selenium.select(SEL_ACTION, "label=Create File");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("filename", "fileToMove");
- selenium.type("description", "fileToMove description");
- selenium.type("title", "fileToMove title");
- selenium.select("language", "label=Czech");
- selenium.click("save");
+ selenium.type(INP_FC_FILENAME, "fileToMove");
+ selenium.type(INP_FC_DESC, "fileToMove description");
+ selenium.type(INP_FC_TITLE, "fileToMove title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals("Czech", selenium.getText("link=Czech"));
Assert.assertEquals("text/plain",
selenium.getText("link=text/plain"));
@@ -294,8 +356,10 @@
}
/**
- * File creation and copying to default directory. File named "file2copy" is
created in the root directory. Then the file is copied into the default directory.
- * At the end it is asserted, that file is appearing in the both of "default"
and the root directory.
+ * File creation and copying to default directory. File named "file2copy" is
+ * created in the root directory. Then the file is copied into the default
+ * directory. At the end it is asserted, that file is appearing in the both
+ * of "default" and the root directory.
*/
@Test(enabled = true, description = "File creation and copying to default
directory.")
public void testCopyFile() {
@@ -303,14 +367,14 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[1]/div/select",
"label=Create File");
+ selenium.select(SEL_ACTION, "label=Create File");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("filename", "file2copy");
- selenium.type("description", "file2copy description");
- selenium.type("title", "file2copy title");
- selenium.select("language", "label=Czech");
- selenium.click("save");
+ selenium.type(INP_FC_FILENAME, "file2copy");
+ selenium.type(INP_FC_DESC, "file2copy description");
+ selenium.type(INP_FC_TITLE, "file2copy title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
int row = findTableRow(TBL_CMS_FILEVER, "1.0", 2) + 1;
@@ -406,14 +470,14 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[1]/div/select",
"label=Create File");
+ selenium.select(SEL_ACTION, "label=Create File");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("filename", name);
- selenium.type("description", name + " description");
- selenium.type("title", "existingFile title");
- selenium.select("language", "label=Czech");
- selenium.click("save");
+ selenium.type(INP_FC_FILENAME, name);
+ selenium.type(INP_FC_DESC, name + " description");
+ selenium.type(INP_FC_TITLE, "existingFile title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals("Czech", selenium.getText("link=Czech"));
Assert.assertEquals("text/plain",
selenium.getText("link=text/plain"));
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-06-17
21:29:16 UTC (rev 13470)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-06-18
11:33:53 UTC (rev 13471)
@@ -18,9 +18,15 @@
// TODO - adding of simple portlet - more portlet types
@Test(groups = { "admin_portal" }, enabled = true, description = "Partal
administrating.")
public class AdminPortalTestCase extends JBossPortalSeleniumTestCase {
-
/** prefix for locator properties = portal.admin. */
public final String casePfx = "portal.admin.";
+
+ private final String MSG_PORTAL_ERR_VALID =
getMess(casePfx+"msg.portal.err.valid","is an invalid property
path");
+ private final String MSG_PAGE_ERR_VALID =
getMess(casePfx+"msg.page.err.valid","is an invalid property path");
+ private final String MSG_PROP_VAL_VALID =
getMess(casePfx+"msg.prop.val.valid","is an invalid property value");
+ private final String MSG_PROP_NAME_VALID =
getMess(casePfx+"msg.prop.name.valid","is an invalid property name");
+ private final String MSG_WINDOW_NAME_VALID =
getMess(casePfx+"msg.window.name.valid","is an invalid window name");
+ private final String MSG_PAGE_NAME_VALID =
getMess(casePfx+"msg.page.name.valid","is an invalid page name");
private final String SUB_SEC_SUBMIT = getLoc(casePfx + "sub.sec.submit",
"//input[contains(@id,'common-edit-security-form:update')]");
private final String SUB_SEC_CANCEL = getLoc(casePfx + "sub.sec.cancel",
"//input[contains(@id,'common-edit-security-form:cancel')]");
@@ -617,13 +623,7 @@
createPortal(portalName);
createPage(portalName, pageName);
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
clickIfVisible(LINK_PORTALS_ID);
clickIfVisible(LINK_PORTAL_HOME);
@@ -956,14 +956,7 @@
createPortal(portalName);
createPage(portalName, pageName);
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- // add
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
clickIfVisible(LINK_PORTALS_ID);
clickIfVisible(LINK_PORTAL_HOME);
int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
@@ -1070,15 +1063,16 @@
}
+ /**
+ * Test input validation for portal create input. Tests navigates to portal
+ * admin interface. The XSS is typed into the create portal input and after
+ * submitting it is asserted that validation error message is present on the
+ * screen.
+ */
@Test(enabled = true)
public void testXssPortalCreate() {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
+
clickIfVisible(LINK_PORTALS_ID);
selenium.type(INPUT_PORTALNAME, XSS_STR1);
@@ -1088,18 +1082,30 @@
Assert.assertTrue(selenium.isTextPresent("is an invalid portal name"));
}
+
+ private void goToPortalAdmin() {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ }
+
+ /**
+ * Test input validation for page create input. Tests navigates to portal
+ * admin interface, creates a portal name "XssPortal" and clicks on it. The
+ * XSS is typed into the create page input and after submitting it is
+ * asserted that validation error message is present on the screen.
+ */
@Test(enabled = true)
public void testXssPageCreate() {
final String portalName = "XssPortal";
createPortal(portalName);
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
clickIfVisible(LINK_PORTALS_ID);
int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
@@ -1111,9 +1117,17 @@
selenium.click(INPUT_SUBMIT_PAGECREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid page name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PAGE_NAME_VALID));
}
+ /**
+ * Test input validation for window create input. Tests navigates to portal
+ * admin interface, creates a portal name "XssPortal" and clicks on it. On
+ * the actual page new page named "XssPage" is created and it is clicked on
+ * it. The "who's online" portlet link is clicked and the XSS is typed
into
+ * the create window input. After submitting (adding to center) it is
+ * asserted that validation error message is present on the screen.
+ */
@Test(enabled = true)
public void testXssWindowCreate() {
final String portalName = "XssPortal";
@@ -1122,13 +1136,7 @@
createPortal(portalName);
createPage(portalName, pageName);
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
clickIfVisible(LINK_PORTALS_ID);
clickIfVisible(LINK_PORTAL_HOME);
@@ -1150,17 +1158,31 @@
selenium.click(SUB_LAYOUT_ADD_CENTER);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid window name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_WINDOW_NAME_VALID));
}
+ /**
+ * Test input validation for many inputs in properties interface of specific
+ * portal. New portal named "XssPropertiesPortal" is created and the test
+ * navigates to its properties page. Firstly the XSS string is written into
+ * the custom property input (creating new property), after clicking on
+ * related submit button, it is asserted, that validation error message is
+ * present on the screen. Then a property with valid name "XssValuesProp" is
+ * created, and the XSS string is typed into its value input. After clicking
+ * on related submit button, it is asserted, that validation error message
+ * is present on the screen. At last the the first redirection input is
+ * filled with XSS string and after clicking on related submit button, it is
+ * asserted, that validation error message is present on the screen. The
+ * same is done for the second redirection input.
+ */
@Test(enabled = true)
public void testXssPortalProperties() {
final String portalName = "XssPropertiesPortal";
createPortal(portalName);
- // then property it
+ // then click on its properties button
selenium.click("link=Admin");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -1178,8 +1200,20 @@
selenium.click(SUB_PP_PROPADD);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid property name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROP_NAME_VALID));
+ selenium.type(INP_PP_PROPNAME, "XssValuesProp");
+ selenium.click(SUB_PP_PROPADD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ r = findTableRow(TBL_PP_PROPS, "XssValuesProp", 0) - 1;
+
+ selenium.type(MessageFormat.format(INP_PP_PROP_VAL, r), XSS_STR1);
+ selenium.click(SUB_PP_PROPVAL_UPDATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROP_VAL_VALID));
+
// redirection
check(CHK_PP_RES_CHECK, false);
@@ -1187,25 +1221,19 @@
selenium.type(INP_PP_RES_INPUT, XSS_STR1);
selenium.click(SUB_PP_ERROR_FORM_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid property path"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PORTAL_ERR_VALID));
check(CHK_PPA_RES_CHECK, false);
waitFor(AJAX_LOAD);
selenium.type(INP_PPA_RES_SELECT, XSS_STR1);
selenium.click(SUB_PPA_FORM_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid property path"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PAGE_ERR_VALID));
}
private void createPortal(String name) {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
clickIfVisible(LINK_PORTALS_ID);
selenium.type(INPUT_PORTALNAME, name);
@@ -1214,12 +1242,7 @@
}
private void createPage(String portalName, String pageName) {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
clickIfVisible(LINK_PORTALS_ID);
int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/DashboardsTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/DashboardsTestCase.java 2009-06-17
21:29:16 UTC (rev 13470)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/DashboardsTestCase.java 2009-06-18
11:33:53 UTC (rev 13471)
@@ -15,10 +15,15 @@
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
public class DashboardsTestCase extends JBossPortalSeleniumTestCase {
-
+
/** prefix for locator properties = portal.dash. */
public final String casePfx = "portal.dash.";
+ private final String MSG_PROP_UPDATE_VALID =
getMess(casePfx+"msg.prop.update.valid","is an invalid property
value");
+ private final String MSG_PROP_ADD_VALID =
getMess(casePfx+"msg.prop.add.valid","is an invalid property name");
+ private final String MSG_PORTAL_ERR_VALID =
getMess(casePfx+"msg.portal.err.valid","is an invalid property
path");
+ private final String MSG_PAGE_ERR_VALID =
getMess(casePfx+"msg.page.err.valid","is an invalid property path");
+
private final String T_DH_SUB_UPDATE = getLoc(casePfx + "t.dh.sub.update",
"//form[contains(@id,'common-edit-theme-form')]/input[@type='submit']");
private final String T_DH_SEL_RENDERSET = getLoc(casePfx +
"t.dh.sel.renderset",
"//select[contains(@id,'common-edit-theme-form:renderSet')]");
private final String T_DH_SEL_THEME = getLoc(casePfx + "t.dh.sel.theme",
"//select[contains(@id,'common-edit-theme-form:theme')]");
@@ -76,14 +81,21 @@
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent(propName));
}
-
+
+ /**
+ * Testing the input for adding a property for validation. Test navigates to
+ * portal admin dashboard configuration interface. It types the XSS to
+ * property name input. After clicking on relevant submit button it is
+ * asserted that relevant message about non valid input is present on the
+ * screen.
+ */
@Test(enabled = true)
public void testXssPropAdd() {
selenium.type(INPUT_PROP_NAME, XSS_STR1);
selenium.click(SUBMIT_ADD_PROP);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid property name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROP_ADD_VALID));
}
/**
@@ -109,14 +121,19 @@
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals(selenium.getValue(MessageFormat.format(T_PROPS_INPUT_VALUE, r -
1)), value, "Updated value not found.");
- Assert.assertTrue(selenium.isTextPresent("is an invalid property value"));
}
-
+
+ /**
+ * Tests input validation for property value input. Test navigates to
+ * dashboards configuration in portal admin. It creates a new property named
+ * "XssStrProp". Then it tries to add new value to it - XSS string. After
+ * pressing the relevant update button, it is asserted, that the input
+ * validation message is present.
+ */
@Test(enabled = true)
public void testXssPropUpdate() {
final String propName = "XssStrProp";
-
Assert.assertFalse(selenium.isTextPresent(propName));
selenium.type(INPUT_PROP_NAME, propName);
selenium.click(SUBMIT_ADD_PROP);
@@ -129,7 +146,7 @@
selenium.click(SUBMIT_UPDATE_VALUE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROP_UPDATE_VALID));
}
/**
@@ -144,14 +161,12 @@
Assert.assertFalse(selenium.isTextPresent(propName));
selenium.type(INPUT_PROP_NAME, propName);
selenium.click(SUBMIT_ADD_PROP);
- System.out.println("WATCH OUT!");
- selenium.setSpeed("6000");
+
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent(propName));
int r = findTableRow(TABLE_PROPS, propName, 0);
-
- System.out.println(MessageFormat.format(T_PROPS_LINK_DEL, r - 1));
+
selenium.click(MessageFormat.format(T_PROPS_LINK_DEL, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -169,24 +184,39 @@
// TODO - no assertions done
@Test(enabled = true)
public void testPortalError() {
- selenium.select(T_PO_SEL_ACCESS, "label=Redirect to the specified
resource");
+ selenium.select(T_PO_SEL_ACCESS, "label="+"Redirect to the specified
resource");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select(T_PO_SEL_UNAVAIL, "label=Redirect to the specified
resource");
+ selenium.select(T_PO_SEL_UNAVAIL, "label="+"Redirect to the specified
resource");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select(T_PO_SEL_PNF, "label=Redirect to the specified resource");
+ selenium.select(T_PO_SEL_PNF, "label="+"Redirect to the specified
resource");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.type(T_PO_INP_PAGEADD, "/WEB-INF/jsp/error/portalX.jsp");
selenium.click(T_PO_SUB_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
+
+ logoutIfPossible();
+ login("admin", "admin");
+ goToDash();
+
+ Assert.assertEquals(selenium.getSelectedLabel(T_PO_SEL_ACCESS),"Redirect to the
specified resource");
+ Assert.assertEquals(selenium.getSelectedLabel(T_PO_SEL_UNAVAIL),"Redirect to the
specified resource");
+ Assert.assertEquals(selenium.getSelectedLabel(T_PO_SEL_PNF),"Redirect to the
specified resource");
+ Assert.assertEquals(selenium.getValue(T_PO_INP_PAGEADD),"/WEB-INF/jsp/error/portalX.jsp");
}
+ /**
+ * Testing input validation for portal error redirection. The input for error
+ * redirection for portals is filled with XSS string and after pressing the
+ * relevant submit button, the presence of correct validation error message
+ * is asserted.
+ */
@Test(enabled = true)
public void testXssPortalError() {
selenium.type(T_PO_INP_PAGEADD, XSS_STR1);
selenium.click(T_PO_SUB_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid property path"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PORTAL_ERR_VALID));
}
/**
@@ -197,42 +227,77 @@
// TODO - no assertions done
@Test(enabled = true)
public void testPageError() {
- selenium.select(T_PA_SEL_ACCESS, "label=Display the default error message");
+ selenium.select(T_PA_SEL_ACCESS, "label="+"Display the default error
message");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select(T_PA_SEL_CONTROL, "label=Redirect to the specified
resource");
+ selenium.select(T_PA_SEL_CONTROL, "label="+"Redirect to the specified
resource");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select(T_PA_SEL_ERROR, "label=Remove the resource from page");
+ selenium.select(T_PA_SEL_ERROR, "label="+"Remove the resource from
page");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select(T_PA_SEL_INTERN, "label=Display the default error message");
+ selenium.select(T_PA_SEL_INTERN, "label="+"Display the default error
message");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select(T_PA_SEL_PNF, "label=Redirect to the specified resource");
+ selenium.select(T_PA_SEL_PNF, "label="+"Redirect to the specified
resource");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.type(T_PA_INP_PAGEADD, "/WEB-INF/jsp/error/pageY.jsp");
selenium.click(T_PA_SUB_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
+
+ logoutIfPossible();
+ login("admin", "admin");
+ goToDash();
+
+ Assert.assertEquals(selenium.getSelectedLabel(T_PA_SEL_ACCESS),"Display the
default error message");
+ Assert.assertEquals(selenium.getSelectedLabel(T_PA_SEL_CONTROL),"Redirect to the
specified resource");
+ Assert.assertEquals(selenium.getSelectedLabel(T_PA_SEL_ERROR),"Remove the resource
from page");
+ Assert.assertEquals(selenium.getSelectedLabel(T_PA_SEL_INTERN),"Display the
default error message");
+ Assert.assertEquals(selenium.getSelectedLabel(T_PA_SEL_PNF),"Redirect to the
specified resource");
+ Assert.assertEquals(selenium.getValue(T_PA_INP_PAGEADD),"/WEB-INF/jsp/error/pageY.jsp");
}
+ /**
+ * Testing input validation for page error redirection. The input for error
+ * redirection for pages is filled with XSS string and after pressing the
+ * relevant submit button, the presence of correct validation error message
+ * is asserted.
+ */
@Test(enabled = true)
public void testXssPageError() {
selenium.type(T_PA_INP_PAGEADD, XSS_STR1);
selenium.click(T_PA_SUB_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid property path"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PAGE_ERR_VALID));
}
/**
* Testing of dashboard theme. The layout, theme and renderset are changed,
* but no assertion is done.
*/
- // TODO - no assertions done
@Test(enabled = true)
public void testDashboardTheme() {
-
safeSelect(T_DH_SEL_LAYOUT, "1column");
- safeSelect(T_DH_SEL_RENDERSET, "default");
- safeSelect(T_DH_SEL_THEME, "nphalanx");
+ safeSelect(T_DH_SEL_THEME, "maple");
+ safeSelect(T_DH_SEL_RENDERSET, "default");
clickAndWait(T_DH_SUB_UPDATE);
+
+ logoutIfPossible();
+ login("admin","admin");
+ goToDash();
+
+ Assert.assertEquals(selenium.getSelectedLabel(T_DH_SEL_LAYOUT),"1column");
+ Assert.assertEquals(selenium.getSelectedLabel(T_DH_SEL_THEME),"maple");
+ Assert.assertEquals(selenium.getSelectedLabel(T_DH_SEL_RENDERSET),"default");
+
+
+ //TODO reconcile if restoring the default properties is needed
+ /*
+ logoutIfPossible();
+ login("admin","admin");
+ goToDash();
+
+ Assert.assertEquals(selenium.getSelectedLabel(T_DH_SEL_LAYOUT),"1column");
+ Assert.assertEquals(selenium.getSelectedLabel(T_DH_SEL_RENDERSET),"default");
+ Assert.assertEquals(selenium.getSelectedLabel(T_DH_SEL_THEME),"maple");
+ */
}
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java 2009-06-17
21:29:16 UTC (rev 13470)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java 2009-06-18
11:33:53 UTC (rev 13471)
@@ -311,6 +311,7 @@
goToProperties();
// add original drag and drop
+ selenium.setSpeed("5000");
selectIfNotSelected(SEL_PREDEF_PROP, "Drag and drop");
selenium.click(SUB_POR_PROPERTY);
selenium.waitForPageToLoad(PAGE_LOAD);
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java 2009-06-17
21:29:16 UTC (rev 13470)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java 2009-06-18
11:33:53 UTC (rev 13471)
@@ -13,9 +13,11 @@
*/
public class PortletDefinitionsTestCase extends JBossPortalSeleniumTestCase{
+
/** prefix for locator properties = portal.port.def.*/
public final String casePfx = "portal.port.def.";
+ private final String MSG_INS_NAME_VALID =
getMess(casePfx+"msg.ins.name.valid","is an invalid instance name");
private final String T_LINK_PREF =
getLoc(casePfx+"t.link.pref","//a[contains(@id,''def-list:portlet-pref-{0}'')]");
private final String SUBMIT_CREATE_INST =
getLoc(casePfx+"submit.create.inst","//input[contains(@name,'add_instance_form:j_id19')]");
private final String INPUT_INSTANCE_NAME =
getLoc(casePfx+"input.instance.name","//input[contains(@id,'add_instance_form:instanceId')]");
@@ -105,7 +107,7 @@
selenium.type(INPUT_INSTANCE_NAME, XSS_STR1);
selenium.click(SUBMIT_CREATE_INST);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid instance name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_INS_NAME_VALID));
}
/**
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java 2009-06-17
21:29:16 UTC (rev 13470)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java 2009-06-18
11:33:53 UTC (rev 13471)
@@ -21,6 +21,9 @@
/** prefix for locator properties = portal.port.ins. */
public final String casePfx = "portal.port.ins.";
+ private final String MSG_PI_PROP_APPEND_VALID =
getMess(casePfx+"msg.pi.prop.append.valid","is an invalid instance
name");
+ private final String MSG_PI_PROP_UPDATE_VALID =
getMess(casePfx+"msg.pi.prop.update.valid","is an invalid instance
name");
+ private final String MSG_INV_DIS_NAME = getMess(casePfx+"","is an invalid
display name");
private final String TAB_PORTLET_INSTANCES = getLoc(casePfx +
"tab.portlet.instances",
"//table[contains(@id,'instancesTable2')]");
private final String UL_PAGINATOR = getLoc(casePfx + "ul.paginator",
"//ul[@class='pagination property-container']");
private final String SUBMIT_SECURITY_UPDATE = getLoc(casePfx +
"submit.security.update",
"//input[contains(@id,'common-edit-security-form:update')]");
@@ -91,7 +94,14 @@
clickAndWait(SUBMIT_MODIFY_NAME);
Assert.assertTrue(findTableRow(TABLE_DISPNAMES, name, 1) >= 0);
}
-
+
+ /**
+ * Test input validation for portlet instance name. Test navigates into
+ * portlet instance of counter portlet. It selects "english" as a language
+ * for the name to be added and types XSS string to the name input. After
+ * pressing the relevant submit button it is asserted that relevant error
+ * message about non valid input is present.
+ */
@Test(enabled = true)
public void testXssAddName() {
int r = traversePortlets(NAME_COUNTPORT, 0);
@@ -99,11 +109,10 @@
safeSelect(SELECT_LANGUAGE, "English");
-
selenium.type(INPUT_NAME, XSS_STR1);
clickAndWait(SUBMIT_MODIFY_NAME);
- Assert.assertTrue(selenium.isTextPresent("is an invalid display name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_INV_DIS_NAME));
}
/**
@@ -558,22 +567,30 @@
selenium.waitForPageToLoad(PAGE_LOAD);
}
-
+
+ /**
+ * Testing input validation for portlet instance properties. It navigates to
+ * preferences interface for CurrentUsersPortletInstance portlet instance.
+ * Then it clicks on "guestNumber" property and two new inputs appears on
+ * the screen. XSS string is typed into the "Edit existing values" and after
+ * pressing the relevant submit button, it is asserted, that the validation
+ * error message is present. XSS string is typed into the "Append a value "
+ * and after pressing the relevant submit button, it is asserted, that the
+ * validation error message is present.
+ */
@Test(enabled = true)
public void testXssPreferences() {
int r = traversePortlets(NAME_COUNTPORT, 0);
clickAndWait(MessageFormat.format(LNK_PREF_BUTTON, r));
- // selenium.click(LINK_CURUSER_PREFERENCES);
-
+
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(SUBMIT_PREF_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
r = traversePortlets(NAME_COUNTPORT, 0);
clickAndWait(MessageFormat.format(LNK_PREF_BUTTON, r));
-
- selenium.waitForPageToLoad(PAGE_LOAD);
+
Assert.assertTrue(findTableRow(TABLE_PREF_KEY, "guestNumber", 0) >= 0);
selenium.click(LINK_PREF_GUESTNUM);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -585,12 +602,12 @@
selenium.type(INPUT_PREF_APPEND, XSS_STR1);
selenium.click(INPUT_PREF_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid instance name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PI_PROP_APPEND_VALID), "validation
message wrong or missing.");
selenium.type(INPUT_PREF_NEWVAL, XSS_STR1);
selenium.click(SUBMIT_PREF_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid instance name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PI_PROP_UPDATE_VALID), "validation
message wrong or missing.");
}
/**