fix some selenium tests

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1172595 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-09-19 12:41:29 +00:00
parent 39f4b78d4f
commit 98db72a675
6 changed files with 170 additions and 128 deletions

View File

@ -40,7 +40,7 @@
<!-- TODO: review how appropriate the memory settings are - should work with less -->
<cargo.jvm.args>-Xmx512m -XX:MaxPermSize=256m</cargo.jvm.args>
<seleniumPluginVersion>2.0</seleniumPluginVersion>
<selenium-server.version>2.5.0</selenium-server.version>
<selenium-server.version>2.6.0</selenium-server.version>
</properties>
<dependencies>

View File

@ -37,21 +37,25 @@ public class AppearanceTest
@Test( dependsOnMethods = { "testAddAppearanceEmptyValues" } )
public void testAddAppearanceInvalidValues()
{
goToAppearancePage();
clickLinkWithText( "Edit" );
addEditAppearance( "<>~+[ ]'\"", "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"",
"/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"", false );
assertTextPresent(
"Organisation name must only contain alphanumeric characters, white-spaces(' '), equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
assertTextPresent( "You must enter a URL" );
//assertXpathCount( "//tr errorfor='saveAppearance_organisationUrl'", 1 );
assertXpathCount( "//span[@class='errorMessage/text()='You must enter a URL']", 1 );
assertXpathCount( "//span[@class='errorMessage'/text()='You must enter a URL']", 1 );
assertTextPresent( "You must enter a URL for your logo" );
assertXpathCount( "//span[@class='errorMessage/text()='You must enter a URL for your logo']", 1 );
assertXpathCount( "//span[@class='errorMessage'/text()='You must enter a URL for your logo']", 1 );
}
@Test( dependsOnMethods = { "testAddAppearanceInvalidValues" } )
public void testAddAppearanceInvalidOrganisationName()
{
goToAppearancePage();
clickLinkWithText( "Edit" );
addEditAppearance( "<>~+[ ]'\"", "http://www.apache.org/", "http://www.apache.org/images/asf_logo_wide.gifs",
false );
assertTextPresent(
@ -61,15 +65,18 @@ public class AppearanceTest
@Test( dependsOnMethods = { "testAddAppearanceInvalidOrganisationName" } )
public void testAddAppearanceInvalidOrganisationUrl()
{
goToAppearancePage();
addEditAppearance( "The Apache Software Foundation", "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"",
"http://www.apache.org/images/asf_logo_wide.gifs", false );
assertTextPresent( "You must enter a URL" );
assertXpathCount( "//span[@class='errorMessage/text()='You must enter a URL']", 1 );
assertXpathCount( "//span[@class='errorMessage'/text()='You must enter a URL']", 1 );
}
@Test( dependsOnMethods = { "testAddAppearanceInvalidOrganisationUrl" } )
public void testAddAppearanceInvalidOrganisationLogo()
{
goToAppearancePage();
clickLinkWithText( "Edit" );
addEditAppearance( "The Apache Software Foundation", "http://www.apache.org/",
"/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"", false );
assertTextPresent( "You must enter a URL" );
@ -79,6 +86,8 @@ public class AppearanceTest
@Test( dependsOnMethods = { "testAddAppearanceInvalidOrganisationLogo" } )
public void testAddAppearanceValidValues()
{
goToAppearancePage();
clickLinkWithText( "Edit" );
addEditAppearance( "The Apache Software Foundation", "http://www.apache.org/",
"http://www.apache.org/images/asf_logo_wide.gifs", true );
assertTextPresent( "The Apache Software Foundation" );
@ -87,6 +96,8 @@ public class AppearanceTest
@Test( dependsOnMethods = { "testAddAppearanceValidValues" } )
public void testEditAppearance()
{
goToAppearancePage();
clickLinkWithText( "Edit" );
addEditAppearance( "Apache Software Foundation", "http://www.apache.org/",
"http://www.apache.org/images/asf_logo_wide.gifs", true );

View File

@ -71,7 +71,7 @@ public class BrowseTest
clickLinkWithText( "Add" );
addManagedRepository( getProperty( "RELEASES_REPOSITORY" ), "Releases Repository",
new File( getBasedir(), "target/repository/releases" ).getPath(), "",
"Maven 2.x Repository", "0 0 * * * ?", "", "" );
"Maven 2.x Repository", "0 0 * * * ?", "", "", true );
assertTextPresent( "Releases Repository" );
String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );

View File

@ -46,7 +46,8 @@ public class LoginTest
goToLoginPage();
setFieldValue( "loginForm_username", "badUsername" );
getSelenium().click( "loginSubmit" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
//getSelenium().waitForPageToLoad( maxWaitTimeInMs );
waitPage();
assertElementPresent( "//ul[@class=\'errorMessage\']" );
//assertTextPresent( "You have entered an incorrect username and/or password" );
}
@ -58,7 +59,8 @@ public class LoginTest
setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
setFieldValue( "loginForm_password", "badPassword" );
getSelenium().click( "loginSubmit" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
//getSelenium().waitForPageToLoad( maxWaitTimeInMs );
waitPage();
//assertTextPresent( "You have entered an incorrect username and/or password" );
//<ul class="errorMessage"><li><span>
assertElementPresent( "//ul[@class=\'errorMessage\']" );
@ -70,7 +72,8 @@ public class LoginTest
goToLoginPage();
setFieldValue( "loginForm_password", "password" );
getSelenium().click( "loginSubmit" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
//getSelenium().waitForPageToLoad( maxWaitTimeInMs );
waitPage();
//assertTextPresent( "User Name is required" );
assertElementPresent( "//tr[@errorFor=\'loginForm_username\']");
}
@ -81,7 +84,8 @@ public class LoginTest
goToLoginPage();
setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
getSelenium().click( "loginSubmit" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
//getSelenium().waitForPageToLoad( maxWaitTimeInMs );
waitPage();
//assertTextPresent( "You have entered an incorrect username and/or password" );
assertElementPresent( "//ul[@class=\'errorMessage\']" );
}
@ -93,7 +97,8 @@ public class LoginTest
setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
setFieldValue( "loginForm_password", getProperty( "ADMIN_PASSWORD" ) );
getSelenium().click( "loginSubmit" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
//getSelenium().waitForPageToLoad( maxWaitTimeInMs );
waitPage();
//assertTextPresent( "Logout" );
assertElementPresent( "logoutLink" );
//assertTextPresent( "Edit Details" );

View File

@ -31,7 +31,7 @@ public class RepositoryTest
goToRepositoriesPage();
getSelenium().open( "/archiva/admin/addRepository.action" );
addManagedRepository( "managedrepo1", "Managed Repository Sample 1", getRepositoryDir() + "repository/", "",
"Maven 2.x Repository", "0 0 * * * ?", "", "" );
"Maven 2.x Repository", "0 0 * * * ?", "", "", true );
clickButtonWithValue( "Save" );
assertTextPresent( "Managed Repository Sample 1" );
assertRepositoriesPage();
@ -41,12 +41,18 @@ public class RepositoryTest
public void testAddManagedRepoInvalidValues()
{
goToRepositoriesPage();
getSelenium().open( "/archiva/admin/addRepository.action" ); ;
addManagedRepository( "<> \\/~+[ ]'\"", "<>\\~+[]'\"" , "<> ~+[ ]'\"" , "<> ~+[ ]'\"", "Maven 2.x Repository", "", "-1", "101" );
assertTextPresent( "Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
assertTextPresent( "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
assertTextPresent( "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
assertTextPresent( "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
getSelenium().open( "/archiva/admin/addRepository.action" );
;
addManagedRepository( "<> \\/~+[ ]'\"", "<>\\~+[]'\"", "<> ~+[ ]'\"", "<> ~+[ ]'\"", "Maven 2.x Repository", "",
"-1", "101", false );
assertTextPresent(
"Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
assertTextPresent(
"Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
assertTextPresent(
"Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
assertTextPresent(
"Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
assertTextPresent( "Repository Purge By Retention Count needs to be between 1 and 100." );
assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
assertTextPresent( "Invalid cron expression." );
@ -55,42 +61,52 @@ public class RepositoryTest
@Test( dependsOnMethods = { "testAddManagedRepoInvalidValues" } )
public void testAddManagedRepoInvalidIdentifier()
{
addManagedRepository( "<> \\/~+[ ]'\"", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "1" );
assertTextPresent( "Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
addManagedRepository( "<> \\/~+[ ]'\"", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1",
"1", false );
assertTextPresent(
"Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
}
@Test( dependsOnMethods = { "testAddManagedRepoInvalidIdentifier" } )
public void testAddManagedRepoInvalidRepoName()
{
addManagedRepository( "identifier", "<>\\~+[]'\"" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "1" );
assertTextPresent( "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
addManagedRepository( "identifier", "<>\\~+[]'\"", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?",
"1", "1", false );
assertTextPresent(
"Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
}
@Test( dependsOnMethods = { "testAddManagedRepoInvalidRepoName" } )
public void testAddManagedRepoInvalidDirectory()
{
addManagedRepository( "identifier", "name" , "<> ~+[ ]'\"" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "1" );
assertTextPresent( "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
addManagedRepository( "identifier", "name", "<> ~+[ ]'\"", "/.index", "Maven 2.x Repository", "0 0 * * * ?",
"1", "1", false );
assertTextPresent(
"Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
}
@Test( dependsOnMethods = { "testAddManagedRepoInvalidDirectory" } )
public void testAddManagedRepoInvalidIndexDir()
{
addManagedRepository( "identifier", "name" , "/home" , "<> ~+[ ]'\"", "Maven 2.x Repository", "0 0 * * * ?", "1", "1" );
assertTextPresent( "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
addManagedRepository( "identifier", "name", "/home", "<> ~+[ ]'\"", "Maven 2.x Repository", "0 0 * * * ?", "1",
"1", false );
assertTextPresent(
"Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
}
@Test( dependsOnMethods = { "testAddManagedRepoInvalidIndexDir" } )
public void testAddManagedRepoInvalidRetentionCount()
{
addManagedRepository( "identifier", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "101" );
addManagedRepository( "identifier", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1",
"101", true );
assertTextPresent( "Repository Purge By Retention Count needs to be between 1 and 100." );
}
@Test( dependsOnMethods = { "testAddManagedRepoInvalidRetentionCount" } )
public void testAddManagedRepoInvalidDaysOlder()
{
addManagedRepository( "identifier", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "-1", "1" );
addManagedRepository( "identifier", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "-1",
"1", true );
assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
}
@ -98,8 +114,9 @@ public class RepositoryTest
public void testAddManagedRepoBlankValues()
{
goToRepositoriesPage();
getSelenium().open( "/archiva/admin/addRepository.action" ); ;
addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" );
getSelenium().open( "/archiva/admin/addRepository.action" );
addManagedRepository( "", "", "", "", "Maven 2.x Repository", "", "", "", false );
assertTextPresent( "You must enter a repository identifier." );
assertTextPresent( "You must enter a repository name." );
assertTextPresent( "You must enter a directory." );
@ -109,28 +126,30 @@ public class RepositoryTest
@Test( dependsOnMethods = { "testAddManagedRepoBlankValues" } )
public void testAddManagedRepoNoIdentifier()
{
addManagedRepository( "", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
addManagedRepository( "", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "", false );
assertTextPresent( "You must enter a repository identifier." );
}
@Test( dependsOnMethods = { "testAddManagedRepoNoIdentifier" } )
public void testAddManagedRepoNoRepoName()
{
addManagedRepository( "identifier", "", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
addManagedRepository( "identifier", "", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "",
false );
assertTextPresent( "You must enter a repository name." );
}
@Test( dependsOnMethods = { "testAddManagedRepoNoRepoName" } )
public void testAddManagedRepoNoDirectory()
{
addManagedRepository( "identifier", "name", "", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
addManagedRepository( "identifier", "name", "", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "",
false );
assertTextPresent( "You must enter a directory." );
}
@Test( dependsOnMethods = { "testAddManagedRepoNoDirectory" } )
public void testAddManagedRepoNoCron()
{
addManagedRepository( "identifier", "name", "/home", "/.index", "Maven 2.x Repository", "", "", "" );
addManagedRepository( "identifier", "name", "/home", "/.index", "Maven 2.x Repository", "", "", "", true );
assertTextPresent( "Invalid cron expression." );
}
@ -140,7 +159,7 @@ public class RepositoryTest
goToRepositoriesPage();
getSelenium().open( "/archiva/admin/addRepository.action" );
addManagedRepository( "managedrepo", "Managed Repository Sample", getRepositoryDir() + "local-repo/", "",
"Maven 2.x Repository", "0 0 * * * ?", "", "" );
"Maven 2.x Repository", "0 0 * * * ?", "", "", true );
clickButtonWithValue( "Save" );
assertTextPresent( "Managed Repository Sample" );
}
@ -149,9 +168,12 @@ public class RepositoryTest
public void testEditManagedRepoInvalidValues()
{
editManagedRepository( "<>\\~+[]'\"", "<> ~+[ ]'\"", "<> ~+[ ]'\"", "Maven 2.x Repository", "", "-1", "101" );
assertTextPresent( "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
assertTextPresent( "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
assertTextPresent( "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
assertTextPresent(
"Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
assertTextPresent(
"Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
assertTextPresent(
"Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
assertTextPresent( "Repository Purge By Retention Count needs to be between 1 and 100." );
assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
assertTextPresent( "Invalid cron expression." );
@ -161,21 +183,24 @@ public class RepositoryTest
public void testEditManagedRepoInvalidRepoName()
{
editManagedRepository( "<>\\~+[]'\"", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "1" );
assertTextPresent( "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
assertTextPresent(
"Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
}
@Test( dependsOnMethods = { "testEditManagedRepoInvalidRepoName" } )
public void testEditManagedRepoInvalidDirectory()
{
editManagedRepository( "name", "<> ~+[ ]'\"", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "1" );
assertTextPresent( "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
assertTextPresent(
"Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
}
@Test( dependsOnMethods = { "testEditManagedRepoInvalidDirectory" } )
public void testEditManagedRepoInvalidIndexDir()
{
editManagedRepository( "name", "/home", "<> ~+[ ]'\"", "Maven 2.x Repository", "0 0 * * * ?", "1", "1" );
assertTextPresent( "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
assertTextPresent(
"Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
}
@Test( dependsOnMethods = { "testEditManagedRepoInvalidIndexDir" } )
@ -249,7 +274,8 @@ public class RepositoryTest
}
@Test( dependsOnMethods = { "testAddRemoteRepoNullURL" } )
public void testAddProxyConnectorValidValues() throws Exception
public void testAddProxyConnectorValidValues()
throws Exception
{
getSelenium().open( "/archiva/admin/addProxyConnector.action" );
addProxyConnector( "(direct connection)", "internal", "remoterepo" );

View File

@ -160,7 +160,7 @@ public class XSSSecurityTest
getSelenium().open( "/archiva/admin/addRepository.action" );
addManagedRepository( "test\"><script>alert('xss')</script>", "test\"><script>alert('xss')</script>",
"test\"><script>alert('xss')</script>", "test\"><script>alert('xss')</script>",
"Maven 2.x Repository", "", "-1", "101" );
"Maven 2.x Repository", "", "-1", "101", true );
// xss inputs are blocked by validation.
assertTextPresent(
"Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
@ -185,7 +185,7 @@ public class XSSSecurityTest
assertTextPresent(
"Organisation name must only contain alphanumeric characters, white-spaces(' '), equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
assertTextPresent( "You must enter a URL" );
assertXpathCount( "//span[@class='errorMessage' and text()='You must enter a URL']", 2 );
assertXpathCount( "//span[@class='errorMessage'/text()='You must enter a URL']", 2 );
}
public void testEditAppearanceImmunityToCrossSiteScriptingRendering()