<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.8</version>
+ <version>5.14.9</version>
<scope>test</scope>
- <classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>commons-io</groupId>
</dependencies>
<build>
- <testSourceDirectory>src/test/testng</testSourceDirectory>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <properties>
+ <systemPropertyVariables>
+ <MAX_WAIT_TIME_IN_MS>60000</MAX_WAIT_TIME_IN_MS>
+ <!-- Exclude on all browsers but Firefox, as it is the only one that Selenium supports file uploads on -->
+ <excludegroups>${excluded.groups}</excludegroups>
<!--
Use this instead of suiteXmlFiles so that we can add the exclusion, as it is only accepted without suiteXmlFiles
-->
- <property>
- <name>listener</name>
- <value>org.apache.archiva.web.test.listener.CaptureScreenShotsListener</value>
- </property>
- <property>
- <name>excludegroups</name>
- <!-- Exclude on all browsers but Firefox, as it is the only one that Selenium supports file uploads on -->
- <value>${excluded.groups}</value>
- </property>
- </properties>
+ <listener>org.apache.archiva.web.test.listener.CaptureScreenShotsListener</listener>
+ </systemPropertyVariables>
</configuration>
<executions>
<execution>
<goal>test</goal>
</goals>
<configuration>
- <systemProperties>
- <property>
- <name>browser</name>
- <value>${selenium.browser}</value>
- </property>
- <property>
- <name>baseUrl</name>
- <value>${baseUrl}</value>
- </property>
- </systemProperties>
+ <systemPropertyVariables>
+ <browser>${selenium.browser}</browser>
+ <baseUrl>${baseUrl}</baseUrl>
+ </systemPropertyVariables>
</configuration>
</execution>
</executions>
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractArchivaTest;
+import org.testng.annotations.Test;
+
+@Test(groups = { "appearance" }, dependsOnGroups = "login", sequential = true)
+public class AppearanceTest
+ extends AbstractArchivaTest
+{
+ public void testAddAppearanceEmptyValues()
+ {
+ goToAppearancePage();
+ clickLinkWithText( "Edit" );
+ addEditAppearance( "", "", "" );
+ assertTextPresent( "You must enter a name" );
+ }
+
+ @Test(dependsOnMethods = { "testAddAppearanceEmptyValues" })
+ public void testAddAppearanceInvalidValues()
+ {
+ addEditAppearance( "<>~+[ ]'\"", "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"",
+ "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"" );
+ 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 );
+ }
+
+ @Test(dependsOnMethods = { "testAddAppearanceInvalidValues" })
+ public void testAddAppearanceInvalidOrganisationName()
+ {
+ addEditAppearance( "<>~+[ ]'\"", "http://www.apache.org/", "http://www.apache.org/images/asf_logo_wide.gifs" );
+ 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(-)." );
+ }
+
+ @Test(dependsOnMethods = { "testAddAppearanceInvalidOrganisationName" })
+ public void testAddAppearanceInvalidOrganisationUrl()
+ {
+ addEditAppearance( "The Apache Software Foundation", "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"",
+ "http://www.apache.org/images/asf_logo_wide.gifs" );
+ assertTextPresent( "You must enter a URL" );
+ assertXpathCount( "//span[@class='errorMessage' and text()='You must enter a URL']", 1 );
+ }
+
+ @Test(dependsOnMethods = { "testAddAppearanceInvalidOrganisationUrl" })
+ public void testAddAppearanceInvalidOrganisationLogo()
+ {
+ addEditAppearance( "The Apache Software Foundation", "http://www.apache.org/",
+ "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"" );
+ assertTextPresent( "You must enter a URL" );
+ assertXpathCount( "//span[@class='errorMessage' and text()='You must enter a URL']", 1 );
+ }
+
+ @Test(dependsOnMethods = { "testAddAppearanceInvalidOrganisationLogo" })
+ public void testAddAppearanceValidValues()
+ {
+ addEditAppearance( "The Apache Software Foundation", "http://www.apache.org/",
+ "http://www.apache.org/images/asf_logo_wide.gifs" );
+ assertTextPresent( "The Apache Software Foundation" );
+ }
+
+ @Test(dependsOnMethods = { "testAddAppearanceValidValues" })
+ public void testEditAppearance()
+ {
+ clickLinkWithText( "Edit" );
+ addEditAppearance( "Apache Software Foundation", "http://www.apache.org/",
+ "http://www.apache.org/images/asf_logo_wide.gifs" );
+ assertTextPresent( "Apache Software Foundation" );
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractArchivaTest;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+@Test( groups = { "about" }, alwaysRun = true )
+public class ArchivaAdminTest
+ extends AbstractArchivaTest
+{
+
+ @Override
+ @AfterTest
+ public void close()
+ throws Exception
+ {
+ super.close();
+ }
+
+ @Override
+ @BeforeSuite
+ public void open()
+ throws Exception
+ {
+ super.open();
+ }
+
+ @BeforeTest
+ @Parameters( { "baseUrl", "browser", "seleniumHost", "seleniumPort" } )
+ public void initializeArchiva( String baseUrl, String browser, @Optional( "localhost" ) String seleniumHost, @Optional( "4444" ) int seleniumPort ) throws Exception
+ {
+ super.open( baseUrl, browser, seleniumHost, seleniumPort );
+ getSelenium().open( baseUrl );
+ String title = getSelenium().getTitle();
+ if ( title.endsWith( "Create Admin User" ) )
+ {
+ assertCreateAdmin();
+ String fullname = getProperty( "ADMIN_FULLNAME" );
+ String username = getProperty( "ADMIN_USERNAME" );
+ String mail = getProperty( "ADMIN_EMAIL" );
+ String password = getProperty( "ADMIN_PASSWORD" );
+ submitAdminData( fullname, mail, password );
+ assertUserLoggedIn( username );
+ submit();
+ clickLinkWithText( "Logout" );
+ }
+ }
+
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractArtifactManagementTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "artifactmanagement" }, dependsOnGroups = "login" )
+public class ArtifactManagementTest
+ extends AbstractArtifactManagementTest
+{
+
+
+ public void testAddArtifactNullValues()
+ {
+ goToAddArtifactPage();
+ clickButtonWithValue( "Submit" );
+ assertTextPresent( "Please add a file to upload." );
+ assertTextPresent( "Invalid version." );
+ assertTextPresent( "You must enter a groupId." );
+ assertTextPresent( "You must enter an artifactId." );
+ assertTextPresent( "You must enter a version" );
+ assertTextPresent( "You must enter a packaging" );
+ }
+
+ @Test(dependsOnMethods = { "testAddArtifactNullValues" } )
+ public void testAddArtifactNoGroupId()
+ {
+ addArtifact( " " , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
+ assertTextPresent( "You must enter a groupId." );
+ }
+
+ @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
+ public void testAddArtifactNoArtifactId()
+ {
+
+ addArtifact( getGroupId() , " ", getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
+ assertTextPresent( "You must enter an artifactId." );
+ }
+
+ @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
+ public void testAddArtifactNoVersion()
+ {
+ addArtifact( getGroupId() , getArtifactId(), " ", getPackaging() , getArtifactFilePath(), getRepositoryId() );
+ assertTextPresent( "You must enter a version." );
+ }
+
+ @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
+ public void testAddArtifactInvalidVersion()
+ {
+ addArtifact( getGroupId() , getArtifactId(), "asdf", getPackaging() , getArtifactFilePath(), getRepositoryId() );
+ assertTextPresent( "Invalid version." );
+ }
+
+ @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
+ public void testAddArtifactNoPackaging()
+ {
+ addArtifact( getGroupId() , getArtifactId(), getVersion(), " " , getArtifactFilePath(), getRepositoryId() );
+ assertTextPresent( "You must enter a packaging." );
+ }
+
+ @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
+ public void testAddArtifactNoFilePath()
+ {
+ addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , " ", getRepositoryId() );
+ assertTextPresent( "Please add a file to upload." );
+ }
+
+ @Test(groups = "requiresUpload")
+ public void testAddArtifactValidValues()
+ {
+ addArtifact( getGroupId() , "testAddArtifactValidValues", getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
+ assertTextPresent( "Artifact 'test:testAddArtifactValidValues:1.0' was successfully deployed to repository 'internal'" );
+ }
+
+ //MRM-747
+ @Test(groups = "requiresUpload")
+ public void testAddArtifactBlockRedeployments()
+ {
+ addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
+ assertTextPresent( "Overwriting released artifacts in repository '" + getRepositoryId() + "' is not allowed." );
+ }
+
+ @Test(groups = "requiresUpload")
+ public void testDeleteArtifact()
+ {
+ //prep
+ String groupId = getProperty( "GROUPID1" );
+ String artifactId = getProperty( "ARTIFACTID1" );
+ String version = getProperty( "VERSION1" );
+ String packaging = getProperty( "PACKAGING1" );
+ String repositoryId = getProperty( "REPOSITORYID1" );
+ // TODO: do this differently as it only works in Firefox's chrome mode
+ addArtifact( groupId , artifactId, version, packaging , getArtifactFilePath(), repositoryId );
+ assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deployed to repository 'internal'" );
+
+ deleteArtifact( "delete", "delete", "1.0", "internal");
+ assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" );
+ }
+
+ public void testDeleteArtifactNoGroupId()
+ {
+ deleteArtifact( " ", "delete", "1.0", "internal");
+ assertTextPresent( "You must enter a groupId." );
+ }
+
+ public void testDeleteArtifactNoArtifactId()
+ {
+ deleteArtifact( "delete", " ", "1.0", "internal");
+ assertTextPresent( "You must enter an artifactId." );
+ }
+
+ public void testDeleteArtifactNoVersion()
+ {
+ deleteArtifact( "delete", "delete", " ", "internal");
+ assertTextPresent( "Invalid version." );
+ assertTextPresent( "You must enter a version." );
+ }
+
+ public void testDeleteArtifactInvalidVersion()
+ {
+ deleteArtifact( "delete", "delete", "asdf", "internal");
+ assertTextPresent( "Invalid version." );
+ }
+
+ // HTML select should have the proper value, else it will cause a selenium error: Option with label 'customValue' not found
+ public void testDeleteArtifactInvalidValues()
+ {
+ deleteArtifact( "<> \\/~+[ ]'\"", "<> \\/~+[ ]'\"", "<>", "internal");
+ assertTextPresent( "Invalid version." );
+ assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ }
+
+ public void testDeleteArtifactInvalidGroupId()
+ {
+ deleteArtifact( "<> \\/~+[ ]'\"", "delete", "1.0", "internal");
+ assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ }
+
+ public void testDeleteArtifactInvalidArtifactId()
+ {
+ deleteArtifact( "delete", "<> \\/~+[ ]'\"", "1.0", "internal");
+ assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ }
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractArchivaTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "auditlogsreport" }, dependsOnGroups = {"login", "artifactmanagement", "userroles"} )
+public class AuditLogsReportTest
+ extends AbstractArchivaTest
+{
+ private void goToAuditLogReports()
+ {
+ getSelenium().open( "/archiva/report/queryAuditLogReport.action" );
+ }
+
+ private void assertAuditLogsReportPage()
+ {
+ assertPage( "Apache Archiva \\ Audit Log Report" );
+ assertTextPresent( "Audit Log Report" );
+
+ assertElementPresent( "repository" );
+ assertElementPresent( "groupId" );
+ assertElementPresent( "artifactId" );
+ assertElementPresent( "startDate" );
+ assertElementPresent( "endDate" );
+ assertElementPresent( "rowCount" );
+ assertButtonWithValuePresent( "View Audit Log" );
+ }
+
+ @Test
+ public void testAuditLogsReport()
+ {
+ goToAuditLogReports();
+ assertAuditLogsReportPage();
+ assertTextPresent( "Latest Events" );
+ }
+
+ @Test
+ public void testViewAuditLogsNoDataFound()
+ {
+ goToAuditLogReports();
+ assertAuditLogsReportPage();
+
+ setFieldValue( "groupId", "non.existing" );
+ submit();
+
+ assertPage( "Apache Archiva \\ Audit Log Report" );
+ assertTextPresent( "Results" );
+ assertTextPresent( "No audit logs found." );
+ }
+
+ // TODO: add test for adding via WebDAV
+ @Test (groups = "requiresUpload")
+ public void testViewAuditLogsDataFound()
+ {
+ goToAuditLogReports();
+ assertAuditLogsReportPage();
+
+ selectValue( "repository", "internal" );
+ setFieldValue( "groupId", "test" );
+ submit();
+
+ assertAuditLogsReportPage();
+ assertTextPresent( "Results" );
+ assertTextNotPresent( "No audit logs found." );
+ assertTextPresent( "testAddArtifactValidValues-1.0.jar" );
+ assertTextPresent( "Uploaded File" );
+ assertTextPresent( "internal" );
+ assertTextPresent( "admin" );
+ }
+
+ // TODO: add test for adding via WebDAV
+ @Test ( groups = "requiresUpload")
+ public void testViewAuditLogsOnlyArtifactIdIsSpecified()
+ {
+ goToAuditLogReports();
+ assertAuditLogsReportPage();
+
+ selectValue( "repository", "internal" );
+ setFieldValue( "artifactId", "test" );
+ submit();
+
+ assertAuditLogsReportPage();
+ assertTextPresent( "Results" );
+ assertTextNotPresent( "No audit logs found." );
+ assertTextPresent( "testAddArtifactValidValues-1.0.jar" );
+ assertTextPresent( "Uploaded File" );
+ assertTextPresent( "internal" );
+ assertTextPresent( "admin" );
+ }
+
+ // TODO: add test for adding via WebDAV
+ @Test (groups = "requiresUpload")
+ public void testViewAuditLogsForAllRepositories()
+ {
+ goToAuditLogReports();
+ assertAuditLogsReportPage();
+
+ selectValue( "repository", "all" );
+ submit();
+
+ assertAuditLogsReportPage();
+ assertTextPresent( "Results" );
+ assertTextNotPresent( "No audit logs found." );
+ assertTextPresent( "testAddArtifactValidValues-1.0.jar" );
+ assertTextPresent( "Uploaded File" );
+ assertTextPresent( "internal" );
+ assertTextPresent( "admin" );
+ }
+
+ @Test (groups = "requiresUpload")
+ public void testViewAuditLogsViewAuditEventsForManageableRepositoriesOnly()
+ {
+ String groupId = getProperty( "SNAPSHOT_GROUPID" );
+ String artifactId = getProperty( "SNAPSHOT_ARTIFACTID" );
+ String version = getProperty( "SNAPSHOT_VERSION" );
+ String repo = getProperty( "SNAPSHOT_REPOSITORYID" );
+ String packaging = getProperty( "SNAPSHOT_PACKAGING" );
+
+ addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repo );
+ assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + version +
+ "' was successfully deployed to repository '" + repo + "'" );
+
+ clickLinkWithText( "Logout" );
+
+ login( getProperty( "REPOMANAGER_INTERNAL_USERNAME" ), getUserRoleNewPassword() );
+
+ goToAuditLogReports();
+ assertAuditLogsReportPage();
+
+ selectValue( "repository", "all" );
+ submit();
+
+ assertAuditLogsReportPage();
+ assertTextPresent( "Results" );
+ assertTextNotPresent( "No audit logs found." );
+ assertTextPresent( "testAddArtifactValidValues-1.0.jar" );
+ assertTextPresent( "Uploaded File" );
+ assertTextPresent( "internal" );
+ assertTextPresent( "admin" );
+
+ assertTextNotPresent( artifactId + "-" + version + "." + packaging );
+ clickLinkWithText( "Logout" );
+ login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
+ }
+
+ @Test ( groups = "requiresUpload")
+ public void testViewAuditLogsReportForGroupId()
+ {
+ String groupId = getProperty("AUDITLOG_GROUPID");
+ String artifactId = getProperty("ARTIFACTID");
+ String version = getProperty("VERSION");
+ String packaging = getProperty("PACKAGING");
+ String repositoryId = getProperty("REPOSITORYID");
+ String expectedArtifact = getProperty("AUDITLOG_EXPECTED_ARTIFACT");
+
+ addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repositoryId );
+
+ goToAuditLogReports();
+
+ selectValue( "repository", repositoryId );
+ setFieldValue( "groupId", groupId );
+ submit();
+
+ assertAuditLogsReportPage();
+ assertTextPresent( expectedArtifact );
+ assertTextPresent( repositoryId );
+ }
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import org.apache.archiva.web.test.parent.AbstractBrowseTest;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+@Test( groups = { "browse" }, dependsOnGroups = {"login","artifactmanagement"} )
+public class BrowseTest
+ extends AbstractBrowseTest
+{
+
+ public void testBrowseArtifact()
+ {
+ goToBrowsePage();
+ assertBrowsePage();
+ }
+
+ @Test
+ public void testClickArtifactFromBrowse()
+ {
+ goToBrowsePage();
+ assertBrowsePage();
+ clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
+ assertPage( "Apache Archiva \\ Browse Repository" );
+ assertTextPresent( "Artifacts" );
+ }
+
+ // MRM-1278
+ @Test(groups = {"requiresUpload"})
+ public void testCorrectRepositoryInBrowse()
+ {
+ String releasesRepo = getProperty( "RELEASES_REPOSITORY" );
+
+ // create releases repository first
+ goToRepositoriesPage();
+ clickLinkWithText( "Add" );
+ addManagedRepository( getProperty( "RELEASES_REPOSITORY" ), "Releases Repository",
+ new File( getBasedir(), "target/repository/releases" ).getPath(), "", "Maven 2.x Repository",
+ "0 0 * * * ?", "", "" );
+ assertTextPresent( "Releases Repository" );
+
+ String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
+
+ String path = "src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
+ // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
+ // upload a snapshot artifact to repository 'releases'
+ addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", path, releasesRepo );
+ assertTextPresent( "Artifact 'archiva:archiva-webapp:1.0-SNAPSHOT' was successfully deployed to repository '" + releasesRepo + "'" );
+
+ goToBrowsePage();
+ assertBrowsePage();
+ assertGroupsPage( "archiva/" );
+ assertArtifactsPage( "archiva-webapp/" );
+ assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" );
+
+ // upload a snapshot artifact to repository 'snapshots'
+ addArtifact( "continuum", "continuum-core", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
+ assertTextPresent( "Artifact 'continuum:continuum-core:1.0-SNAPSHOT' was successfully deployed to repository '" + snapshotsRepo + "'" );
+
+ goToBrowsePage();
+ assertBrowsePage();
+ assertGroupsPage( "continuum/" );
+ assertArtifactsPage( "continuum-core/" );
+ assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "continuum", "continuum-core", "1.0-SNAPSHOT", "jar" );
+ }
+
+ // MRM-1353
+ @Test( groups = { "requiresUpload" } )
+ public void testBuildNumberOfSnapshotArtifact()
+ {
+ String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
+
+ String path = "src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
+ // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
+ // upload a snapshot artifact to repository 'releases'
+ addArtifact( "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
+ assertTextPresent( "Artifact 'archiva:archiva-multiple-artifacts:1.0-SNAPSHOT' was successfully deployed to repository '"
+ + snapshotsRepo + "'" );
+
+ goToBrowsePage();
+ assertBrowsePage();
+ assertGroupsPage( "archiva/" );
+ assertArtifactsPage( "archiva-multiple-artifacts/" );
+ assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
+
+
+ addArtifact( "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
+ assertTextPresent( "Artifact 'archiva:archiva-multiple-artifacts:1.0-SNAPSHOT' was successfully deployed to repository '"
+ + snapshotsRepo + "'" );
+
+ goToBrowsePage();
+ assertBrowsePage();
+ assertGroupsPage( "archiva/" );
+ assertArtifactsPage( "archiva-multiple-artifacts/" );
+ assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
+
+ String firstSnapshotVersion = getText( "//div[@id='tabArea']/table[@class='infoTable']/tbody/tr[6]/td/a[1]" );
+ Assert.assertTrue( firstSnapshotVersion.endsWith( "-1" ) );
+
+ String secondSnapshotVersion = getText( "//div[@id='tabArea']/table[@class='infoTable']/tbody/tr[6]/td/a[2]" );
+ Assert.assertTrue( secondSnapshotVersion.endsWith( "-2" ) );
+ }
+
+ private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId,
+ String artifactInfoArtifactId, String artifactInfoVersion, String artifactInfoPackaging )
+ {
+ clickLinkWithText( version );
+ assertPage( "Apache Archiva \\ Browse Repository" );
+ assertTextPresent( artifactInfoRepositoryId );
+ assertTextPresent( artifactInfoGroupId );
+ assertTextPresent( artifactInfoArtifactId );
+ assertTextPresent( artifactInfoVersion );
+ assertTextPresent( artifactInfoPackaging );
+ }
+
+ private void assertArtifactsPage( String artifactId )
+ {
+ clickLinkWithText( artifactId );
+ assertPage( "Apache Archiva \\ Browse Repository" );
+ assertTextPresent( "Versions" );
+ }
+
+ private void assertGroupsPage( String groupId )
+ {
+ clickLinkWithText( groupId );
+ assertPage( "Apache Archiva \\ Browse Repository" );
+ assertTextPresent( "Artifacts" );
+ }
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractArchivaTest;
+import org.testng.annotations.Test;
+
+/**
+ * Test all actions affected with CSRF security issue.
+ */
+@Test( groups = { "csrf" }, dependsOnGroups = "login", sequential = true )
+public class CSRFSecurityTest
+ extends AbstractArchivaTest
+{
+ public void testCSRFDeleteRepository()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/admin/deleteRepository.action?repoid=test&method%3AdeleteContents=Delete+Configuration+and+Contents" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testCSRFDeleteArtifact()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/deleteArtifact!doDelete.action?groupId=1&artifactId=1&version=1&repositoryId=snapshots" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testCSRFAddRepositoryGroup()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/admin/addRepositoryGroup.action?repositoryGroup.id=csrfgrp" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testCSRFDeleteRepositoryGroup()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/admin/deleteRepositoryGroup.action?repoGroupId=test&method%3Adelete=Confirm" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testCSRFDisableProxyConnector()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/admin/disableProxyConnector!disable.action?target=maven2-repository.dev.java.net&source=internal" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testCSRFDeleteProxyConnector()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/admin/deleteProxyConnector!delete.action?target=maven2-repository.dev.java.net&source=snapshots" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testCSRFDeleteLegacyArtifactPath()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/admin/deleteLegacyArtifactPath.action?path=jaxen%2Fjars%2Fjaxen-1.0-FCS-full.jar" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testCSRFSaveNetworkProxy()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/admin/saveNetworkProxy.action?mode=add&proxy.id=ntwrk&proxy.protocol=http&" +
+ "proxy.host=test&proxy.port=8080&proxy.username=&proxy.password=" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testCSRFDeleteNetworkProxy()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/admin/deleteNetworkProxy!delete.action?proxyid=myproxy" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testCSRFAddFileTypePattern()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/admin/repositoryScanning!addFiletypePattern.action?pattern=**%2F*.rum&fileTypeId=artifacts" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testCSRFRemoveFileTypePattern()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/admin/repositoryScanning!removeFiletypePattern.action?pattern=**%2F*.rum&fileTypeId=artifacts" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testCSRFUpdateKnownConsumers()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/admin/repositoryScanning!updateKnownConsumers.action?enabledKnownContentConsumers=auto-remove&" +
+ "enabledKnownContentConsumers=auto-rename&enabledKnownContentConsumers=create-missing-checksums&" +
+ "enabledKnownContentConsumers=index-content&enabledKnownContentConsumers=metadata-updater&" +
+ "enabledKnownContentConsumers=repository-purge&enabledKnownContentConsumers=update-db-artifact&" +
+ "enabledKnownContentConsumers=validate-checksums" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testCSRFUpdateUnprocessedConsumers()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/admin/database!updateUnprocessedConsumers.action?enabledUnprocessedConsumers=update-db-project" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testCSRFUpdateCleanupConsumers()
+ {
+ getSelenium().open( baseUrl );
+ getSelenium().open( baseUrl + "/admin/database!updateCleanupConsumers.action?enabledCleanupConsumers=not-present-remove-db-artifact&" +
+ "enabledCleanupConsumers=not-present-remove-db-project&enabledCleanupConsumers=not-present-remove-indexed" );
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "database" }, dependsOnGroups = "login", sequential = true )
+public class DatabaseTest
+ extends AbstractRepositoryTest
+{
+ public void testUpdateCron_NullValue()
+ {
+ goToDatabasePage();
+ setFieldValue( "database_cron" , "");
+ clickButtonWithValue( "Update Cron" );
+ assertTextPresent( "Invalid cron expression value(s)" );
+ assertTextPresent( "You must enter a cron expression." );
+ }
+
+ @Test (dependsOnMethods = { "testUpdateCron_NullValue" } )
+ public void testUpdateCron_InvalidValue()
+ {
+ setFieldValue( "database_cron" , "asdf" );
+ clickButtonWithValue( "Update Cron" );
+ assertTextPresent( "Invalid cron expression value(s)" );
+ }
+
+ @Test (dependsOnMethods = { "testUpdateCron_InvalidValue" } )
+ public void testUpdateCron_ValidValue()
+ {
+ setFieldValue( "database_cron" , "0 0 * * * ?" );
+ clickButtonWithValue( "Update Cron" );
+ assertPage( "Apache Archiva \\ Administration - Database" );
+ }
+
+ @Test (dependsOnMethods = { "testUpdateCron_ValidValue" } )
+ public void testUpdateConsumersUnprocessedArtifactsScanning_UnsetAll()
+ {
+ getSelenium().uncheck( "enabledUnprocessedConsumers" );
+ clickSubmitWithLocator( "//input[@id='database_0' and @value='Update Consumers']" );
+
+ assertPage( "Apache Archiva \\ Administration - Database" );
+ }
+
+ @Test (dependsOnMethods = { "testUpdateConsumersUnprocessedArtifactsScanning_UnsetAll" } )
+ public void testUpdateConsumersUnprocessedArtifactsScanning()
+ {
+ checkField( "enabledUnprocessedConsumers" );
+ clickSubmitWithLocator( "//input[@id='database_0' and @value='Update Consumers']" );
+ assertPage( "Apache Archiva \\ Administration - Database" );
+ }
+
+ @Test (dependsOnMethods = { "testUpdateConsumersUnprocessedArtifactsScanning" } )
+ public void testUpdateConsumersArtifactCleanupScanning_UnsetAll()
+ {
+ getSelenium().uncheck( "enabledCleanupConsumers" );
+ getSelenium().uncheck( "//input[@name='enabledCleanupConsumers' and @value='not-present-remove-db-project']" );
+ getSelenium().uncheck( "//input[@name='enabledCleanupConsumers' and @value='not-present-remove-indexed']" );
+ clickSubmitWithLocator( "//form[@id='database']/table/tbody/tr[5]/td/input" );
+ assertPage( "Apache Archiva \\ Administration - Database" );
+ }
+
+ @Test (dependsOnMethods = { "testUpdateConsumersArtifactCleanupScanning_UnsetAll" } )
+ public void testUpdateConsumersArtifactCleanupScanning()
+ {
+ checkField( "enabledCleanupConsumers" );
+ clickSubmitWithLocator( "//form[@id='database']/table/tbody/tr[5]/td/input" );
+ assertPage( "Apache Archiva \\ Administration - Database" );
+ }
+
+ @Test (dependsOnMethods = { "testUpdateConsumersArtifactCleanupScanning" } )
+ public void testUpdateDatabaseNow()
+ {
+ clickButtonWithValue( "Update Database Now" );
+ assertPage( "Apache Archiva \\ Administration - Database" );
+ }
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractArchivaTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "findartifact" }, dependsOnGroups = "login", sequential = true )
+public class FindArtifactTest
+ extends AbstractArchivaTest
+{
+ public void testFindArtifactNullValues()
+ {
+ goToFindArtifactPage();
+ clickButtonWithValue( "Search" );
+ assertTextPresent( "You must select a file, or enter the checksum. If the file was given and you receive this message, there may have been an error generating the checksum." );
+ }
+
+ public void testFindArtifactUsingChecksum()
+ {
+ goToFindArtifactPage();
+ setFieldValue( "checksumSearch_q" , "8e896baea663a45d7bd2737f8e464481" );
+ clickButtonWithValue( "Search" );
+ assertTextPresent( "No results found" );
+ }
+
+ // TODO: test using file upload on Firefox versions that support getAsBinary (ie, no applet)
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractArtifactManagementTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "legacysupport" }, dependsOnGroups = "login", sequential = true )
+public class LegacySupportTest
+ extends AbstractArtifactManagementTest
+{
+ public void testAddLegacyArtifact_NullValues()
+ {
+ goToLegacySupportPage();
+ clickLinkWithText( "Add" );
+ addLegacyArtifactPath( "" , "" , "" , "" , "" , "");
+ assertTextPresent( "You must enter a legacy path." );
+ assertTextPresent( "You must enter a groupId." );
+ assertTextPresent( "You must enter an artifactId." );
+ assertTextPresent( "You must enter a version." );
+ assertTextPresent( "You must enter a type." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_NullValues" })
+ public void testAddLegacyArtifact_NullLegacyPath()
+ {
+ addLegacyArtifactPath( "" , "test" , "test" , "1.0-SNAPSHOT" , "testing" , "jar");
+ assertTextPresent( "You must enter a legacy path." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_NullLegacyPath" })
+ public void testAddLegacyArtifact_NullGroupId()
+ {
+ addLegacyArtifactPath( "test" , "" , "test" , "1.0-SNAPSHOT" , "testing" , "jar");
+ assertTextPresent( "You must enter a groupId." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_NullGroupId" })
+ public void testAddLegacyArtifact_NullArtifactId()
+ {
+ addLegacyArtifactPath( "test" , "test" , "" , "1.0-SNAPSHOT" , "testing" , "jar");
+ assertTextPresent( "You must enter an artifactId." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_NullArtifactId" })
+ public void testAddLegacyArtifact_NullVersion()
+ {
+ addLegacyArtifactPath( "test" , "test" , "test" , "" , "testing" , "jar");
+ assertTextPresent( "You must enter a version." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_NullVersion" })
+ public void testAddLegacyArtifact_NullType()
+ {
+ addLegacyArtifactPath( "test" , "test" , "test" , "1.0-SNAPSHOT" , "testing" , "");
+ assertTextPresent( "You must enter a type." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_NullType" })
+ public void testAddLegacyArtifact_InvalidValues()
+ {
+ addLegacyArtifactPath( "<> ~+[ ]'\"" , "<> \\/~+[ ]'\"" , "<> \\/~+[ ]'\"" , "<> \\/~+[ ]'\"" , "<> \\/~+[ ]'\"" , "<> \\/~+[ ]'\"");
+ assertTextPresent( "Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_InvalidValues" })
+ public void testAddLegacyArtifact_InvalidLegacyPath()
+ {
+ addLegacyArtifactPath( "<> ~+[ ]'\"" , "test" , "test" , "1.0-SNAPSHOT" , "testing" , "jar");
+ assertTextPresent( "Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_InvalidLegacyPath" })
+ public void testAddLegacyArtifact_InvalidGroupId()
+ {
+ addLegacyArtifactPath( "test" , "<> \\/~+[ ]'\"" , "test" , "1.0-SNAPSHOT" , "testing" , "jar");
+ assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_InvalidGroupId" })
+ public void testAddLegacyArtifact_InvalidArtifactId()
+ {
+ addLegacyArtifactPath( "test" , "test" , "<> \\/~+[ ]'\"" , "1.0-SNAPSHOT" , "testing" , "jar");
+ assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_InvalidArtifactId" })
+ public void testAddLegacyArtifact_InvalidVersion()
+ {
+ addLegacyArtifactPath( "test" , "test" , "test" , "<> \\/~+[ ]'\"" , "testing" , "jar");
+ assertTextPresent( "Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_InvalidVersion" })
+ public void testAddLegacyArtifact_InvalidType()
+ {
+ addLegacyArtifactPath( "test" , "test" , "test" , "1.0-SNAPSHOT" , "testing" , "<> \\/~+[ ]'\"");
+ assertTextPresent( "Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_InvalidType" })
+ public void testAddLegacyArtifact_InvalidClassifier()
+ {
+ addLegacyArtifactPath( "test" , "test" , "test" , "1.0-SNAPSHOT" , "<> \\/~+[ ]'\"" , "jar");
+ assertTextPresent( "Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ }
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractArchivaTest;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/*
+ * Bug in TestNG. TESTNG-285: @Test(sequential=true) works incorrectly for classes with inheritance
+ * http://code.google.com/p/testng/source/browse/trunk/CHANGES.txt
+ * Waiting 5.9 release. It's comming soon.
+ */
+/**
+ * Based on LoginTest of Emmanuel Venisse test.
+ *
+ * @author José Morales Martínez
+ * @version $Id$
+ */
+
+@Test ( groups = { "login" }, dependsOnGroups = "about")
+public class LoginTest
+ extends AbstractArchivaTest
+{
+ public void testWithBadUsername()
+ {
+ goToLoginPage();
+ getSelenium().type( "loginForm_username", "badUsername" );
+ getSelenium().click( "loginForm__login" );
+ getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+ assertTextPresent( "You have entered an incorrect username and/or password" );
+ }
+
+ @Test( dependsOnMethods = { "testWithBadUsername" }, alwaysRun = true )
+ public void testWithBadPassword()
+ {
+ goToLoginPage();
+ getSelenium().type( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
+ getSelenium().type( "loginForm_password", "badPassword" );
+ getSelenium().click( "loginForm__login" );
+ getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+ assertTextPresent( "You have entered an incorrect username and/or password" );
+ }
+
+ @Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true )
+ public void testWithEmptyUsername()
+ {
+ goToLoginPage();
+ getSelenium().type( "loginForm_password", "password" );
+ getSelenium().click( "loginForm__login" );
+ getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+ assertTextPresent( "User Name is required" );
+ }
+
+ @Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true )
+ public void testWithEmptyPassword()
+ {
+ goToLoginPage();
+ getSelenium().type( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
+ getSelenium().click( "loginForm__login" );
+ getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+ assertTextPresent( "You have entered an incorrect username and/or password" );
+ }
+
+ @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun = true )
+ public void testWithCorrectUsernamePassword()
+ {
+ goToLoginPage();
+ getSelenium().type( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
+ getSelenium().type( "loginForm_password", getProperty( "ADMIN_PASSWORD" ) );
+ getSelenium().click( "loginForm__login" );
+ getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+ assertTextPresent( "Edit Details" );
+ assertTextPresent( "Logout" );
+ assertTextPresent( getProperty( "ADMIN_USERNAME" ) );
+ }
+
+ @BeforeTest
+ public void open()
+ throws Exception
+ {
+ super.open();
+ }
+
+ @Override
+ @AfterTest
+ public void close()
+ throws Exception
+ {
+ super.close();
+ }
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "networkproxies" }, dependsOnGroups = {"login","virtualrepository"})
+public class NetworkProxiesTest
+ extends AbstractRepositoryTest
+{
+ @Test
+ public void testAddNetworkProxyNullValues()
+ {
+ goToNetworkProxiesPage();
+ addNetworkProxy( "", "", "", "", "", "");
+ assertTextPresent( "You must enter an identifier." );
+ assertTextPresent( "You must enter a protocol." );
+ assertTextPresent( "You must enter a host." );
+ }
+
+ @Test (dependsOnMethods = { "testAddNetworkProxyNullValues" } )
+ public void testAddNetworkProxyNullIdentifier()
+ {
+ goToNetworkProxiesPage();
+ addNetworkProxy( "", "http", "localhost", "8080", "", "");
+ assertTextPresent( "You must enter an identifier." );
+ }
+
+ @Test (dependsOnMethods = { "testAddNetworkProxyNullIdentifier" } )
+ public void testAddNetworkProxyNullProtocol()
+ {
+ goToNetworkProxiesPage();
+ addNetworkProxy( "testing123", "", "localhost", "8080", "", "");
+ assertTextPresent( "You must enter a protocol." );
+ }
+
+ @Test (dependsOnMethods = { "testAddNetworkProxyNullProtocol" } )
+ public void testAddNetworkProxiesNullHostname()
+ {
+ goToNetworkProxiesPage();
+ addNetworkProxy( "testing123", "http", "", "8080", "", "");
+ assertTextPresent( "You must enter a host." );
+ }
+
+ @Test (dependsOnMethods = { "testAddNetworkProxiesNullHostname" } )
+ public void testAddNetworkProxiesInvalidValues()
+ {
+ goToNetworkProxiesPage();
+ addNetworkProxy( "<> \\/~+[ ]'\"", "<> ~+[ ]'\"", "<> ~+[ ]'\"", "0", "<> ~+[ ]'\"", "");
+ assertTextPresent( "Proxy id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Protocol must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), dots(.), colons(:), and dashes(-)." );
+ assertTextPresent( "Host must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
+ assertTextPresent( "Port needs to be larger than 1" );
+ assertTextPresent( "Username must only contain alphanumeric characters, at's(@), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
+ }
+
+ @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidValues" } )
+ public void testAddNetworkProxiesInvalidIdentifier()
+ {
+ goToNetworkProxiesPage();
+ addNetworkProxy( "<> \\/~+[ ]'\"", "http", "localhost", "8080", "", "");
+ assertTextPresent( "Proxy id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ }
+
+ @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidIdentifier" } )
+ public void testAddNetworkProxiesInvalidProtocol()
+ {
+ goToNetworkProxiesPage();
+ addNetworkProxy( "testing123", "<> ~+[ ]'\"", "localhost", "8080", "", "");
+ assertTextPresent( "Protocol must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), dots(.), colons(:), and dashes(-)." );
+ }
+
+ @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidProtocol" } )
+ public void testAddNetworkProxiesInvalidHostname()
+ {
+ goToNetworkProxiesPage();
+ addNetworkProxy( "testing123", "http", "<> ~+[ ]'\"", "8080", "", "");
+ assertTextPresent( "Host must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
+ }
+
+ @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidHostname" } )
+ public void testAddNetworkProxiesInvalidPort()
+ {
+ goToNetworkProxiesPage();
+ addNetworkProxy( "testing123", "http", "localhost", "0", "", "");
+ assertTextPresent( "Port needs to be larger than 1" );
+ }
+
+ @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidPort" } )
+ public void testAddNetworkProxiesInvalidUsername()
+ {
+ goToNetworkProxiesPage();
+ addNetworkProxy( "testing123", "http", "localhost", "8080", "<> ~+[ ]'\"", "");
+ assertTextPresent( "Username must only contain alphanumeric characters, at's(@), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
+ }
+
+ @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidUsername" } )
+ public void testAddNetworkProxiesValidValues()
+ {
+ goToNetworkProxiesPage();
+ addNetworkProxy( "testing123", "http", "localhost", "8080", "", "");
+ assertPage( "Apache Archiva \\ Administration - Network Proxies" );
+ assertTextPresent( "testing123" );
+ }
+
+ @Test (dependsOnMethods = { "testAddNetworkProxiesValidValues" } )
+ public void testEditNetworkProxy()
+ {
+ editNetworkProxies( "proxy.host", "localhost" );
+ assertPage( "Apache Archiva \\ Administration - Network Proxies" );
+ assertTextPresent( "localhost" );
+ }
+
+ @Test (dependsOnMethods = { "testEditNetworkProxy" } )
+ public void testDeleteNetworkProxy()
+ {
+ deleteNetworkProxy();
+ assertPage( "Apache Archiva \\ Administration - Network Proxies" );
+ assertTextPresent( "There are no network proxies configured yet." );
+ }
+
+ @Test (dependsOnMethods = { "testDeleteNetworkProxy" } )
+ public void testAddNetworkProxyAfterDelete()
+ {
+ addNetworkProxy( "testing123", "http", "localhost", "8080", "", "");
+ assertPage( "Apache Archiva \\ Administration - Network Proxies" );
+ assertTextPresent( "testing123" );
+ }
+
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractArtifactReportsTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "reports" }, dependsOnGroups = "login")
+public class ReportsTest
+ extends AbstractArtifactReportsTest
+{
+ //TODO Tests for repository with defects
+
+ public void testRepoStatisticsWithoutRepoCompared()
+ {
+ goToReportsPage();
+ clickButtonWithValue( "View Statistics" );
+ assertTextPresent( "Please select a repository (or repositories) from the list." );
+ }
+
+ @Test(dependsOnMethods = { "testRepoStatisticsWithoutRepoCompared" } )
+ public void testRepositoryStatisticsWithoutDate()
+ {
+ String repositoryName = getProperty( "REPOSITORY_NAME" ) ;
+ compareRepositories( "label=" + repositoryName, "", "" );
+ //TODO
+ //assertTextPresent( "Statistics Report" );
+ }
+
+ @Test(dependsOnMethods = { "testRepoStatisticsWithoutRepoCompared" } )
+ public void testRepositoryStatisticsEndEarlierThanStart()
+ {
+ String repositoryName = getProperty( "REPOSITORY_NAME" ) ;
+ String startDate = getProperty( "END_DATE" );
+ String endDate = getProperty( "START_DATE" );
+ compareRepositories( "label=" + repositoryName, startDate, endDate );
+ //assertTextPresent( "Statistics for Repository '" + repositoryName + "'" );
+ assertPage( "Apache Archiva \\ Reports" );
+ assertTextPresent( "Start Date must be earlier than the End Date" );
+ }
+
+ public void testRepositoryStatistics()
+ {
+ String repositoryName = getProperty( "REPOSITORY_NAME" ) ;
+ String startDate = getProperty( "START_DATE" );
+ String endDate = getProperty( "END_DATE" );
+ compareRepositories( "label=" + repositoryName, startDate, endDate );
+ //assertTextPresent( "Statistics for Repository '" + repositoryName + "'" );
+ //assertPage( "Apache Archiva \\ Reports" );
+ //assertTextPresent( "Statistics Report" );
+ }
+
+ /* @Test( dependsOnMethods = { "testRepositoryStatistics" } )
+ public void testRepositoriesStatisticComparisonReport()
+ {
+ //goToReportsPage();
+ clickButtonWithValue( "-->>" , false );
+ clickButtonWithValue( "View Statistics" );
+ assertTextPresent( "Statistics Report" );
+ }
+
+ public void testRepositoryHealthWithoutDefect()
+ {
+ goToReportsPage();
+ String groupId = getProperty( "ARTIFACT_GROUPID" );
+ getSelenium().type( "generateReport_groupId" , groupId );
+ clickButtonWithValue( "Show Report" );
+ assertPage( "Apache Archiva \\ Reports" );
+ assertTextPresent( "The operation generated an empty report." );
+ }
+
+ public void testRepositoryHealthWithoutGroupId()
+ {
+ goToReportsPage();
+ clickButtonWithValue( "Show Report" );
+ assertPage( "Apache Archiva \\ Reports" );
+ assertTextPresent( "The operation generated an empty report." );
+
+ //TODO As of the creation of the tests, GroupId is not a required field in showing the reports of repository health. GroupId should be required I think.
+ }*/
+
+
+
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+
+@Test( groups = { "reposcan" }, dependsOnGroups = "login", sequential = true )
+public class RepositoryScanningTest
+ extends AbstractRepositoryTest
+{
+ public void testAddArtifactFileType_NullValue()
+ {
+ goToRepositoryScanningPage();
+ clickAddIcon( "newpattern_0" );
+ assertTextPresent( "Unable to process blank pattern." );
+ }
+
+ @Test (dependsOnMethods = { "testAddArtifactFileType_NullValue" } )
+ public void testAddArtifactFileType()
+ {
+ setFieldValue( "newpattern_0" , "**/*.dll" );
+ clickAddIcon( "newpattern_0" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "**/*.dll" );
+ }
+
+ @Test (dependsOnMethods = { "testAddArtifactFileType" } )
+ public void testAddArtifactFileType_ExistingValue()
+ {
+ setFieldValue( "newpattern_0" , "**/*.zip" );
+ clickAddIcon( "newpattern_0" );
+ Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.zip\" to filetype artifacts as it already exists." );
+ }
+
+ @Test (dependsOnMethods = { "testAddArtifactFileType_ExistingValue" } )
+ public void testDeleteArtifactFileType()
+ {
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "**/*.dll" );
+ clickDeleteIcon( "**/*.dll" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "" );
+ }
+
+ @Test (dependsOnMethods = { "testDeleteArtifactFileType" } )
+ public void testAddAutoRemove_NullValue()
+ {
+ setFieldValue( "newpattern_1" , "" );
+ clickAddIcon( "newpattern_1" );
+ assertTextPresent( "Unable to process blank pattern." );
+ }
+
+ @Test (dependsOnMethods = { "testAddAutoRemove_NullValue" } )
+ public void testAddAutoRemove_ExistingValue()
+ {
+ setFieldValue( "newpattern_1" , "**/*-" );
+ clickAddIcon( "newpattern_1" );
+ Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." );
+ }
+
+ @Test (dependsOnMethods = { "testAddAutoRemove_ExistingValue" } )
+ public void testAddAutoRemove()
+ {
+ setFieldValue( "newpattern_1" , "**/*.test" );
+ clickAddIcon( "newpattern_1" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "**/*.test" );
+ }
+
+ @Test (dependsOnMethods = { "testAddAutoRemove" } )
+ public void testDeleteAutoRemove()
+ {
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "**/*.test" );
+ clickDeleteIcon( "**/*.test" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "" );
+ }
+
+ @Test (dependsOnMethods = { "testDeleteAutoRemove" } )
+ public void testAddIgnoredArtifacts_NullValue()
+ {
+ setFieldValue( "newpattern_2" , "" );
+ clickAddIcon( "newpattern_2" );
+ Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." );
+ }
+
+ @Test (dependsOnMethods = { "testAddIgnoredArtifacts_NullValue" } )
+ public void testAddIgnoredArtifacts_ExistingValue()
+ {
+ setFieldValue( "newpattern_2" , "**/*.sh" );
+ clickAddIcon( "newpattern_2" );
+ Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." );
+ }
+
+ @Test (dependsOnMethods = { "testAddIgnoredArtifacts_ExistingValue" } )
+ public void testAddIgnoredArtifacts()
+ {
+ setFieldValue( "newpattern_2" , "**/*.log" );
+ clickAddIcon( "newpattern_2" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "**/*.log" );
+ }
+
+ @Test (dependsOnMethods = { "testAddIgnoredArtifacts" } )
+ public void testDeleteIgnoredArtifacts()
+ {
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "**/*.log" );
+ clickDeleteIcon( "**/*.log" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "" );
+ }
+
+ //
+ @Test (dependsOnMethods = { "testDeleteIgnoredArtifacts" } )
+ public void testAddIndexableContent_NullValue()
+ {
+ setFieldValue( "newpattern_3" , "" );
+ clickAddIcon( "newpattern_3" );
+ Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." );
+ }
+
+ @Test (dependsOnMethods = { "testAddIndexableContent_NullValue" } )
+ public void testAddIndexableContent_ExistingValue()
+ {
+ setFieldValue( "newpattern_3" , "**/*.xml" );
+ clickAddIcon( "newpattern_3" );
+ Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." );
+ }
+
+ @Test (dependsOnMethods = { "testAddIndexableContent_ExistingValue" } )
+ public void testAddIndexableContent()
+ {
+ setFieldValue( "newpattern_3" , "**/*.html" );
+ clickAddIcon( "newpattern_3" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "**/*.html" );
+ }
+
+ @Test (dependsOnMethods = { "testAddIndexableContent" } )
+ public void testDeleteIndexableContent()
+ {
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "**/*.html" );
+ clickDeleteIcon( "**/*.html" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "" );
+ }
+
+ @Test (dependsOnMethods = { "testDeleteIndexableContent" } )
+ public void testUpdateConsumers()
+ {
+ checkField( "enabledKnownContentConsumers" );
+ checkField( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
+ clickButtonWithValue( "Update Consumers" );
+ assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
+ }
+
+ @Test (dependsOnMethods = { "testUpdateConsumers" } )
+ public void testUpdateConsumers_UnsetAll()
+ {
+ getSelenium().uncheck( "enabledKnownContentConsumers" );
+ getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
+ getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='create-missing-checksums']" );
+ getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='index-content']" );
+ getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='metadata-updater']" );
+ getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='repository-purge']" );
+ getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='update-db-artifact']" );
+ getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='validate-checksums']" );
+ clickButtonWithValue( "Update Consumers" );
+
+ assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
+ }
+
+ private void clickAddIcon( String fieldId )
+ {
+ String xPath = "//preceding::td/input[@id='" + fieldId + "']//following::td/a/img";
+ clickLinkWithLocator( xPath );
+ }
+
+ private void clickDeleteIcon( String pattern )
+ {
+ String xPath = "//preceding::td/code[contains(text(),'" + pattern + "')]//following::td/a/img";
+ clickLinkWithLocator( xPath );
+ }
+
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "repository" }, dependsOnGroups = "login", sequential = true )
+public class RepositoryTest
+ extends AbstractRepositoryTest
+{
+ public void testAddManagedRepoValidValues()
+ {
+ goToRepositoriesPage();
+ getSelenium().open( "/archiva/admin/addRepository.action" );
+ addManagedRepository( "managedrepo1", "Managed Repository Sample 1" , getRepositoryDir() + "repository/" , "", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
+ clickButtonWithValue( "Save" );
+ assertTextPresent( "Managed Repository Sample 1" );
+ assertRepositoriesPage();
+ }
+
+ @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } )
+ 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(-)." );
+ 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." );
+ }
+
+ @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(-)." );
+ }
+
+ @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(-)." );
+ }
+
+ @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(-)." );
+ }
+
+ @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(-)." );
+ }
+
+ @Test(dependsOnMethods = { "testAddManagedRepoInvalidIndexDir" } )
+ public void testAddManagedRepoInvalidRetentionCount()
+ {
+ addManagedRepository( "identifier", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "101" );
+ 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" );
+ assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
+ }
+
+ @Test(dependsOnMethods = { "testAddManagedRepoInvalidDaysOlder" } )
+ public void testAddManagedRepoBlankValues()
+ {
+ goToRepositoriesPage();
+ getSelenium().open( "/archiva/admin/addRepository.action" ); ;
+ addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" );
+ assertTextPresent( "You must enter a repository identifier." );
+ assertTextPresent( "You must enter a repository name." );
+ assertTextPresent( "You must enter a directory." );
+ assertTextPresent( "Invalid cron expression." );
+ }
+
+ @Test(dependsOnMethods = { "testAddManagedRepoBlankValues" } )
+ public void testAddManagedRepoNoIdentifier()
+ {
+ addManagedRepository( "", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
+ assertTextPresent( "You must enter a repository identifier." );
+ }
+
+ @Test(dependsOnMethods = { "testAddManagedRepoNoIdentifier" } )
+ public void testAddManagedRepoNoRepoName()
+ {
+ addManagedRepository( "identifier", "" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
+ assertTextPresent( "You must enter a repository name." );
+ }
+
+ @Test(dependsOnMethods = { "testAddManagedRepoNoRepoName" } )
+ public void testAddManagedRepoNoDirectory()
+ {
+ addManagedRepository( "identifier", "name" , "" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
+ assertTextPresent( "You must enter a directory." );
+ }
+
+ @Test(dependsOnMethods = { "testAddManagedRepoNoDirectory" } )
+ public void testAddManagedRepoNoCron()
+ {
+ addManagedRepository( "identifier", "name" , "/home" , "/.index", "Maven 2.x Repository", "", "", "" );
+ assertTextPresent( "Invalid cron expression." );
+ }
+
+ @Test(dependsOnMethods = { "testAddManagedRepoNoCron" } )
+ public void testAddManagedRepoForEdit()
+ {
+ goToRepositoriesPage();
+ clickLinkWithText( "Add" );
+ addManagedRepository( "managedrepo", "Managed Repository Sample" , getRepositoryDir() + "local-repo/", "", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
+ clickButtonWithValue( "Save" );
+ assertTextPresent( "Managed Repository Sample" );
+ }
+
+ @Test(dependsOnMethods = { "testAddManagedRepoForEdit" } )
+ 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( "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." );
+ }
+
+ @Test(dependsOnMethods = { "testEditManagedRepoInvalidValues" } )
+ 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(-)." );
+ }
+
+ @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(-)." );
+ }
+
+ @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(-)." );
+ }
+
+ @Test(dependsOnMethods = { "testEditManagedRepoInvalidIndexDir" } )
+ public void testEditManagedRepoInvalidCron()
+ {
+ editManagedRepository("name" , "/home" , "/.index", "Maven 2.x Repository", "", "1", "1");
+ assertTextPresent( "Invalid cron expression." );
+ }
+
+ @Test(dependsOnMethods = { "testEditManagedRepoInvalidCron" } )
+ public void testEditManagedRepoInvalidRetentionCount()
+ {
+ editManagedRepository("name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "101");
+ assertTextPresent( "Repository Purge By Retention Count needs to be between 1 and 100." );
+ }
+
+ @Test(dependsOnMethods = { "testEditManagedRepoInvalidRetentionCount" } )
+ public void testEditManagedRepoInvalidDaysOlder()
+ {
+ editManagedRepository("name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "-1", "1");
+ assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
+ }
+
+ //TODO
+ @Test(dependsOnMethods = { "testEditManagedRepoInvalidDaysOlder" } )
+ public void testEditManagedRepo()
+ {
+ editManagedRepository( "repository.name" , "Managed Repo" );
+ assertTextPresent( "Managed Repository Sample" );
+ }
+
+ //TODO
+ @Test(dependsOnMethods = { "testEditManagedRepo" } )
+ public void testDeleteManageRepo()
+ {
+ deleteManagedRepository();
+ //assertTextNotPresent( "managedrepo" );
+ }
+
+ @Test(dependsOnMethods = { "testAddRemoteRepoValidValues" } )
+ public void testAddRemoteRepoNullValues()
+ {
+ getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
+ addRemoteRepository( "" , "" , "" , "" , "" , "" , "Maven 2.x Repository" );
+ assertTextPresent( "You must enter a repository identifier." );
+ assertTextPresent( "You must enter a repository name." );
+ assertTextPresent( "You must enter a url." );
+ }
+
+ @Test(dependsOnMethods = { "testAddRemoteRepoNullValues" } )
+ public void testAddRemoteRepositoryNullIdentifier()
+ {
+ addRemoteRepository( "" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
+ assertTextPresent( "You must enter a repository identifier." );
+ }
+
+ @Test(dependsOnMethods = { "testAddRemoteRepositoryNullIdentifier" } )
+ public void testAddRemoteRepoNullName()
+ {
+ addRemoteRepository( "remoterepo" , "" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
+ assertTextPresent( "You must enter a repository name." );
+ }
+
+ @Test(dependsOnMethods = { "testAddRemoteRepoNullName" } )
+ public void testAddRemoteRepoNullURL()
+ {
+ addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "" , "" , "" , "" , "Maven 2.x Repository" );
+ assertTextPresent( "You must enter a url." );
+ }
+
+ @Test(dependsOnMethods = { "testDeleteManageRepo" } )
+ public void testAddRemoteRepoValidValues()
+ {
+ getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
+ addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
+ assertTextPresent( "Remote Repository Sample" );
+ }
+
+ // *** BUNDLED REPOSITORY TEST ***
+
+ @Test ( dependsOnMethods = { "testWithCorrectUsernamePassword" }, alwaysRun = true )
+ public void testBundledRepository()
+ {
+ String repo1 = baseUrl + "repository/internal/";
+ String repo2 = baseUrl + "repository/snapshots/";
+
+ assertRepositoryAccess( repo1 );
+ assertRepositoryAccess( repo2 );
+
+ getSelenium().open( "/archiva" );
+ }
+
+ private void assertRepositoryAccess( String repo )
+ {
+ getSelenium().open( "/archiva" );
+ goToRepositoriesPage();
+ assertLinkPresent( repo );
+ clickLinkWithText( repo );
+ assertPage( "Collection: /" );
+ assertTextPresent( "Collection: /" );
+ }
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import org.apache.archiva.web.test.parent.AbstractSearchTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "search" }, dependsOnGroups = "login" )
+public class SearchTest
+ extends AbstractSearchTest
+{
+
+ public void testSearchNonExistingArtifact()
+ throws Exception
+ {
+ searchForArtifact( getProperty( "SEARCH_BAD_ARTIFACT" ) );
+ assertTextPresent( "No results found" );
+ }
+
+ public void testSearchExistingArtifact()
+ {
+ searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
+ assertTextPresent( "Results" );
+ assertTextPresent( "Hits: 1 to 1 of 1" );
+ assertLinkPresent( "test" );
+ }
+
+ public void testViewSearchedArtifact()
+ {
+ searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
+ clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) );
+ assertPage( "Apache Archiva \\ Browse Repository" );
+ assertTextPresent( getProperty( "ARTIFACT_ARTIFACTID" ) );
+ clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
+ assertPage( "Apache Archiva \\ Browse Repository" );
+ }
+
+ public void testSearchNonExistingArtifactInAdvancedSearch()
+ {
+ searchForArtifactAdvancedSearch( null, getProperty( "SEARCH_BAD_ARTIFACT"), null, null, null, null );
+ assertTextPresent( "No results found" );
+ }
+
+ public void testSearchNoSearchCriteriaSpecifiedInAdvancedSearch()
+ {
+ searchForArtifactAdvancedSearch( null, null, null, null, null, null );
+ assertTextPresent( "Advanced Search - At least one search criteria must be provided." );
+ }
+
+ public void testSearchExistingArtifactUsingAdvancedSearchArtifactId()
+ {
+ searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, getProperty( "REPOSITORYID" ), null, null );
+ assertTextPresent( "Results" );
+ assertTextPresent( "Hits: 1 to 1 of 1" );
+ assertLinkPresent( "test" );
+ }
+
+ public void testSearchExistingArtifactUsingAdvancedSearchGroupId()
+ {
+ searchForArtifactAdvancedSearch( getProperty( "GROUPID" ), null, null, getProperty( "REPOSITORYID" ), null, null );
+ assertTextPresent( "Results" );
+ assertTextPresent( "Hits: 1 to 1 of 1" );
+ assertLinkPresent( "test" );
+ }
+
+ public void testSearchExistingArtifactUsingAdvancedSearchNotInRepository()
+ {
+ searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, "snapshots", null, null );
+ assertTextPresent( "No results found" );
+ assertTextNotPresent( "Results" );
+ assertTextNotPresent( "Hits: 1 to 1 of 1" );
+ assertLinkNotPresent( "test" );
+ }
+}
+
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractArchivaTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "userroles" }, dependsOnGroups = "login")
+public class UserRolesTest
+ extends AbstractArchivaTest
+{
+
+ public void testBasicAddDeleteUser()
+ {
+ username = getProperty( "GUEST_USERNAME" );
+ fullname = getProperty( "GUEST_FULLNAME" );
+
+ createUser( username, fullname, getUserEmail(), getUserRolePassword(), true);
+ deleteUser( username, fullname, getUserEmail() );
+ logout();
+ login( getAdminUsername() , getAdminPassword() );
+ }
+
+ @Test (dependsOnMethods = { "testBasicAddDeleteUser" } )
+ public void testUserWithGuestRole()
+ {
+ username = getProperty("GUEST_USERNAME");
+ fullname = getProperty("GUEST_FULLNAME");
+
+ createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
+ clickLinkWithText( username );
+ clickLinkWithText( "Edit Roles" );
+ checkUserRoleWithValue( fullname );
+ clickButtonWithValue( "Submit" );
+
+ logout();
+ login(username, getUserRolePassword());
+ changePassword( getUserRolePassword(), getUserRoleNewPassword());
+
+ // this section will be removed if issue from redback after changing password will be fixed.
+ getSelenium().goBack();
+ logout();
+ //assertTextPresent("You are already logged in.");
+
+ login(username, getUserRoleNewPassword());
+ assertLeftNavMenuWithRole( fullname );
+ logout();
+ login( getAdminUsername() , getAdminPassword() );
+ }
+
+ @Test (dependsOnMethods = { "testUserWithGuestRole" } )
+ public void testUserWithRegisteredUserRole()
+ {
+ username = getProperty("REGISTERED_USERNAME");
+ fullname = getProperty("REGISTERED_FULLNAME");
+
+ createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
+ clickLinkWithText( username );
+ clickLinkWithText( "Edit Roles" );
+ checkUserRoleWithValue( fullname );
+ clickButtonWithValue( "Submit" );
+
+ logout();
+ login(username, getUserRolePassword());
+ changePassword( getUserRolePassword(), getUserRoleNewPassword());
+
+ // this section will be removed if issue from redback after changing password will be fixed.
+ getSelenium().goBack();
+ logout();
+ //assertTextPresent("You are already logged in.");
+
+ login(username, getUserRoleNewPassword());
+ assertLeftNavMenuWithRole( fullname );
+ logout();
+ login( getAdminUsername() , getAdminPassword() );
+ }
+
+ @Test (dependsOnMethods = { "testUserWithRegisteredUserRole" } )
+ public void testUserWithSysAdminUserRole()
+ {
+ username = getProperty("SYSAD_USERNAME");
+ fullname = getProperty("SYSAD_FULLNAME");
+
+ createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
+ clickLinkWithText( username );
+ clickLinkWithText( "Edit Roles" );
+ checkUserRoleWithValue( fullname );
+ clickButtonWithValue( "Submit" );
+
+ logout();
+ login(username, getUserRolePassword());
+ changePassword( getUserRolePassword(), getUserRoleNewPassword());
+
+ // this section will be removed if issue from redback after changing password will be fixed.
+ getSelenium().goBack();
+ logout();
+ //assertTextPresent("You are already logged in.");
+
+ login(username, getUserRoleNewPassword());
+ assertLeftNavMenuWithRole( fullname );
+ logout();
+ login( getAdminUsername() , getAdminPassword() );
+ }
+
+ @Test (dependsOnMethods = { "testUserWithSysAdminUserRole" } )
+ public void testUserWithUserAdminUserRole()
+ {
+ username = getProperty("USERADMIN_USERNAME");
+ fullname = getProperty("USERADMIN_FULLNAME");
+
+ createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
+ clickLinkWithText( username );
+ clickLinkWithText( "Edit Roles" );
+ checkUserRoleWithValue( fullname );
+ clickButtonWithValue( "Submit" );
+
+ logout();
+ login(username, getUserRolePassword());
+ changePassword( getUserRolePassword(), getUserRoleNewPassword());
+
+ // this section will be removed if issue from redback after changing password will be fixed.
+ getSelenium().goBack();
+ logout();
+ //assertTextPresent("You are already logged in.");
+
+ login(username, getUserRoleNewPassword());
+ assertLeftNavMenuWithRole( fullname );
+ logout();
+ login( getAdminUsername() , getAdminPassword() );
+ }
+
+ @Test (dependsOnMethods = { "testUserWithUserAdminUserRole" } )
+ public void testUserWithGlobalRepoManagerRole()
+ {
+ username = getProperty("GLOBALREPOMANAGER_USERNAME");
+ fullname = getProperty("GLOBALREPOMANAGER_FULLNAME");
+
+ createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
+ clickLinkWithText( username );
+ clickLinkWithText( "Edit Roles" );
+ checkUserRoleWithValue( fullname );
+ clickButtonWithValue( "Submit" );
+
+ logout();
+ login(username, getUserRolePassword());
+ changePassword( getUserRolePassword(), getUserRoleNewPassword());
+
+ // this section will be removed if issue from redback after changing password will be fixed.
+ getSelenium().goBack();
+ logout();
+ //assertTextPresent("You are already logged in.");
+
+ login(username, getUserRoleNewPassword());
+ assertLeftNavMenuWithRole( fullname );
+ logout();
+ login( getAdminUsername() , getAdminPassword() );
+ }
+
+ @Test (dependsOnMethods = { "testUserWithGlobalRepoManagerRole" } )
+ public void testUserWithGlobalRepoObserverRole()
+ {
+ username = getProperty("GLOBALREPOOBSERVER_USERNAME");
+ fullname = getProperty("GLOBALREPOOBSERVER_FULLNAME");
+
+ createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
+ clickLinkWithText( username );
+ clickLinkWithText( "Edit Roles" );
+ checkUserRoleWithValue( fullname );
+ clickButtonWithValue( "Submit" );
+
+ logout();
+ login(username, getUserRolePassword());
+ changePassword( getUserRolePassword(), getUserRoleNewPassword());
+
+ // this section will be removed if issue from redback after changing password will be fixed.
+ getSelenium().goBack();
+ logout();
+ //assertTextPresent("You are already logged in.");
+
+ login(username, getUserRoleNewPassword());
+ assertLeftNavMenuWithRole( fullname );
+ logout();
+ login( getAdminUsername() , getAdminPassword() );
+ }
+
+ @Test (dependsOnMethods = { "testUserWithGlobalRepoObserverRole" } )
+ public void testUserWithRepoManagerInternalRole()
+ {
+ username = getProperty("REPOMANAGER_INTERNAL_USERNAME");
+ fullname = getProperty("REPOMANAGER_INTERNAL_FULLNAME");
+
+ createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
+ clickLinkWithText( username );
+ clickLinkWithText( "Edit Roles" );
+ checkResourceRoleWithValue( fullname );
+ clickButtonWithValue( "Submit" );
+
+ logout();
+ login(username, getUserRolePassword());
+ changePassword( getUserRolePassword(), getUserRoleNewPassword());
+
+ // this section will be removed if issue from redback after changing password will be fixed.
+ getSelenium().goBack();
+ logout();
+ //assertTextPresent("You are already logged in.");
+
+ login(username, getUserRoleNewPassword());
+ assertLeftNavMenuWithRole( fullname );
+ logout();
+ login( getAdminUsername() , getAdminPassword() );
+ }
+
+ /*@Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
+ public void testUserWithRepoManagerSnapshotsRole()
+ {
+ username = getProperty("REPOMANAGER_SNAPSHOTS_USERNAME");
+ fullname = getProperty("REPOMANAGER_SNAPSHOTS_FULLNAME");
+
+ createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
+ clickLinkWithText( username );
+ clickLinkWithText( "Edit Roles" );
+ checkResourceRoleWithValue( fullname );
+ clickButtonWithValue( "Submit" );
+
+ clickLinkWithText("Logout");
+ login(username, getUserRolePassword());
+ changePassword( getUserRolePassword(), getUserRoleNewPassword());
+
+ // this section will be removed if issue from redback after changing password will be fixed.
+ getSelenium().goBack();
+ clickLinkWithText("Logout");
+ //assertTextPresent("You are already logged in.");
+
+ login(username, getUserRoleNewPassword());
+ assertLeftNavMenuWithRole( fullname );
+ clickLinkWithText("Logout");
+ login( getAdminUsername() , getAdminPassword() );
+ }*/
+
+ @Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
+ public void testUserWithRepoObserverInternalRole()
+ {
+ username = getProperty( "REPOOBSERVER_INTERNAL_USERNAME" );
+ fullname = getProperty( "REPOOBSERVER_INTERNAL_FULLNAME" );
+
+ createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
+ clickLinkWithText( username );
+ clickLinkWithText( "Edit Roles" );
+ checkResourceRoleWithValue( fullname );
+ clickButtonWithValue( "Submit" );
+
+ logout();
+ login(username, getUserRolePassword());
+ changePassword( getUserRolePassword(), getUserRoleNewPassword());
+
+ // this section will be removed if issue from redback after changing password will be fixed.
+ getSelenium().goBack();
+ logout();
+ //assertTextPresent("You are already logged in.");
+
+ login(username, getUserRoleNewPassword());
+ assertLeftNavMenuWithRole( fullname );
+ logout();
+ login( getAdminUsername() , getAdminPassword() );
+ }
+
+ /*@Test (dependsOnMethods = { "testUserWithRepoObserverInternalRole" } )
+ public void testUserWithRepoObserverSnapshotsRole()
+ {
+ username = getProperty( "REPOOBSERVER_SNAPSHOTS_USERNAME" );
+ fullname = getProperty( "REPOOBSERVER_SNAPSHOTS_FULLNAME" );
+
+ createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
+ clickLinkWithText( username );
+ clickLinkWithText( "Edit Roles" );
+ checkResourceRoleWithValue( fullname );
+ clickButtonWithValue( "Submit" );
+
+ clickLinkWithText("Logout");
+ login(username, getUserRolePassword());
+ changePassword( getUserRolePassword(), getUserRoleNewPassword());
+
+ // this section will be removed if issue from redback after changing password will be fixed.
+ getSelenium().goBack();
+ clickLinkWithText("Logout");
+ //assertTextPresent("You are already logged in.");
+
+ login(username, getUserRoleNewPassword());
+ assertLeftNavMenuWithRole( fullname );
+ clickLinkWithText("Logout");
+ login( getAdminUsername() , getAdminPassword() );
+ }*/
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+
+@Test( groups = { "virtualrepository" }, dependsOnGroups = "login")
+public class VirtualRepositoryTest
+ extends AbstractRepositoryTest
+{
+ public void testAddRepositoryGroupNullValue()
+ {
+ addRepositoryGroup( " " );
+ assertTextPresent( "Identifier field is required." );
+ }
+
+ @Test
+ public void testAddRepositoryGroupValidValue()
+ {
+ addRepositoryGroup( "testing" );
+ //assertAddedRepositoryLink( "testing" );
+ Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[1]/p[1]" ), "testing" );
+ }
+
+ @Test(dependsOnMethods = { "testAddRepositoryGroupValidValue" } )
+ public void testAddRepositoryToRepositoryGroup()
+ {
+ addRepositoryToRepositoryGroup( "testing", "internal" );
+ Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[3]/div[2]/p[1]" ), "internal" );
+ //clickLinkWithXPath( "/html/body/div[4]/div/div/div[2]/div/div/p[2]/a" );
+ //getSelenium().goBack();
+ }
+
+ @Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } )
+ public void testDeleteRepositoryOfRepositoryGroup()
+ {
+ goToRepositoryGroupsPage();
+ deleteRepositoryInRepositoryGroups();
+ assertTextPresent( "Repository Groups" );
+ assertTextNotPresent( "No Repository Groups Defined." );
+ Assert.assertFalse( getSelenium().isElementPresent( "//div[@id='contentArea']/div[2]/div/div[3]/div[2]/p[1]" ) );
+ }
+
+ @Test(dependsOnMethods = { "testDeleteRepositoryOfRepositoryGroup" } )
+ public void testDeleteRepositoryGroup()
+ {
+ assertRepositoryGroupsPage();
+ deleteRepositoryGroup( "testing" );
+ assertTextPresent( "No Repository Groups Defined." );
+ }
+
+ /*@Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } )
+ public void testCheckRepositoryGroup()
+ {
+ clickLinkWithXPath( "/html/body/div[4]/div/div/div[2]/div/div/p[2]/a" );
+ getSelenium().goBack();
+ }*/
+}
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Utility class for creating xpath expressions
+ */
+public class XPathExpressionUtil
+{
+ public static final String CONTAINS = "contains";
+
+ public static final String AND = " and ";
+
+ public static final String CURRENT_NODE = "./";
+
+ public static final String PARENT_NODE = "../";
+
+ public static final String GRANDPARENT_NODE = "../../";
+
+ public static final String ELEMENT_ANY_LEVEL = "//";
+
+ public static final String TABLE_COLUMN = "td";
+
+ public static final String TABLE_ROW = "tr";
+
+ public static final String START_NODE_TEST = "[";
+
+ public static final String END_NODE_TEST = "]";
+
+ public static final String ANCHOR = "a";
+
+ public static final String IMG = "img";
+
+ public static final String LIST = "ul";
+
+ public static final String LINE = "li";
+
+ public static String getList( String[] values )
+ {
+ String xpathExpression = "";
+
+ if ( values.length > 0 )
+ {
+ xpathExpression += ELEMENT_ANY_LEVEL;
+ xpathExpression += LIST;
+ xpathExpression += START_NODE_TEST;
+
+ for (int nIndex = 0; nIndex < values.length; nIndex++ )
+ {
+ xpathExpression += ( ( nIndex > 0 ) ? AND : "" );
+ xpathExpression += contains( LINE + position( nIndex + 1 ), values[nIndex] );
+ }
+
+ xpathExpression += END_NODE_TEST;
+ }
+
+ return xpathExpression;
+ }
+
+ /**
+ * expression for acquiring an element in one of the table columns
+ *
+ * @param element the node element
+ * @param elementIndex column index of the element, used for skipping
+ * @param columnValues the values to be matched in each column, element column is included
+ * @return
+ */
+ public static String getColumnElement( String element, int elementIndex, String[] columnValues )
+ {
+ return getColumnElement( element, elementIndex, null, columnValues );
+ }
+
+ /**
+ * expression for acquiring an element in one of the table columns
+ *
+ * @param element the node element
+ * @param elementIndex column index of the element, used for skipping
+ * @param elementValue the matched element value
+ * @param columnValues the values to be matched in each column, element column is included
+ * @return
+ */
+ public static String getColumnElement( String element, int elementIndex, String elementValue,
+ String[] columnValues )
+ {
+ return getColumnElement( element, elementIndex, elementValue, "TEXT", columnValues );
+ }
+
+ /**
+ * expression for acquiring an element in one of the table columns
+ *
+ * @param element the node element
+ * @param elementIndex column index of the element, used for skipping
+ * @param imageName the matched image name
+ * @param columnValues the values to be matched in each column, element column is included
+ * @return
+ */
+ public static String getImgColumnElement( String element, int elementIndex, String imageName,
+ String[] columnValues )
+ {
+ return getColumnElement( element, elementIndex, imageName, IMG, columnValues );
+ }
+
+ /**
+ * expression for acquiring an element in one of the table columns
+ *
+ * @param element the node element
+ * @param elementIndex column index of the element, used for skipping
+ * @param imageName the matched image name
+ * @param columnValues the values to be matched in each column, element column is included
+ * @return
+ */
+ private static String getColumnElement( String element, int elementIndex, String elementValue,
+ String elementValueType, String[] columnValues )
+ {
+ String xpathExpression = null;
+
+ if ( ( columnValues != null ) && ( columnValues.length > 0 ) )
+ {
+ xpathExpression = ELEMENT_ANY_LEVEL + element;
+ xpathExpression += START_NODE_TEST;
+
+ if ( elementValue != null )
+ {
+ if ( "TEXT".equals( elementValueType ) )
+ {
+ xpathExpression += contains( elementValue );
+ xpathExpression += ( columnValues.length > 0 ) ? AND : "";
+ }
+ }
+
+ // we are two levels below the table row element ( tr/td/<element> )
+ xpathExpression += matchColumns( GRANDPARENT_NODE, columnValues, elementIndex );
+
+ xpathExpression += END_NODE_TEST;
+ }
+
+ if ( IMG.equals( elementValueType ) )
+ {
+ xpathExpression += "/img[contains(@src, '" + elementValue + "')]";
+ }
+
+ return xpathExpression;
+ }
+
+ /**
+ * expression for acquiring the table row that matches all column values with the same order
+ * as the list
+ *
+ * @param columnValues the matched list of columnValues
+ * @return
+ */
+ public static String getTableRow( String[] columnValues )
+ {
+ String xpathExpression = null;
+
+ if ( ( columnValues != null ) && ( columnValues.length > 0 ) )
+ {
+ xpathExpression = new String( ELEMENT_ANY_LEVEL + TABLE_ROW + START_NODE_TEST );
+ xpathExpression += matchColumns( columnValues );
+ xpathExpression += END_NODE_TEST;
+ }
+
+ return xpathExpression;
+ }
+
+ private static String matchColumns( String[] columnValues )
+ {
+ return matchColumns( columnValues, -1 );
+ }
+
+ private static String matchColumns( String[] columnValues, int skipIndex )
+ {
+ return matchColumns( null, columnValues, skipIndex );
+ }
+
+ private static String matchColumns( String parent, String[] columnValues, int skipIndex )
+ {
+ String xpathExpression = "";
+
+ for ( int nIndex = 0; nIndex < columnValues.length; nIndex++ )
+ {
+ if ( ( skipIndex != nIndex ) || ( skipIndex == -1 ) )
+ {
+ // prepend "and" if index > 0
+ xpathExpression += ( ( nIndex > 0 ) ? AND : "" );
+ xpathExpression += contains( parent, TABLE_COLUMN + position( nIndex + 1 ), columnValues[nIndex] );
+ }
+ }
+
+ return xpathExpression;
+ }
+
+ private static String position( int nIndex )
+ {
+ return new String( "[" + nIndex + "]" );
+ }
+
+ private static String contains( String parent, String element, String matchedString )
+ {
+ String finalElement = ( parent != null ) ? parent : "";
+ finalElement += element;
+
+ return contains( finalElement, matchedString );
+ }
+
+ private static String contains( String matchedString )
+ {
+ return contains( ".", matchedString );
+ }
+
+ private static String contains( String axis, String matchedString )
+ {
+ return new String( CONTAINS + "(" + axis + "," + "'" + matchedString + "')" );
+ }
+
+ private static String equals( String parent, String element, String matchedString )
+ {
+ String finalElement = ( parent != null ) ? parent : "";
+ finalElement += element;
+
+ return equals( finalElement, matchedString );
+ }
+
+ private static String equals( String axis, String matchedString )
+ {
+ return new String( axis + "==" + "'" + matchedString + "'" );
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.apache.archiva.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.testng.annotations.Test;
+import org.apache.archiva.web.test.parent.AbstractArchivaTest;
+
+/**
+ * Test all actions affected with XSS security issue.
+ */
+@Test( groups = { "xss" }, dependsOnGroups = "login", sequential = true )
+public class XSSSecurityTest
+ extends AbstractArchivaTest
+{
+ public void testDeleteArtifactImmunityToURLCrossSiteScripting()
+ {
+ getSelenium().open( "/archiva/deleteArtifact!doDelete.action?groupId=\"/>1<script>alert('xss')</script>&artifactId=\"/>1<script>alert('xss')</script>&version=\"/>1<script>alert('xss')</script>&repositoryId=\"/>1<script>alert('xss')</script>");
+ assertDeleteArtifactPage();
+ assertTextPresent( "Invalid version." );
+ assertTextPresent( "User is not authorized to delete artifacts in repository '\"/>1<script>alert('xss')</script>'." );
+ assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Repository id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertElementValue("//input[@id='deleteArtifact_groupId']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='deleteArtifact_artifactId']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='deleteArtifact_version']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//select[@id='deleteArtifact_repositoryId']", "internal");
+ }
+
+ public void testDeleteArtifactImmunityToEncodedURLCrossSiteScripting()
+ {
+ getSelenium().open( "/archiva/deleteArtifact!doDelete.action?groupId=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&artifactId=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&version=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&repositoryId=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E");
+ assertDeleteArtifactPage();
+ assertTextPresent( "Invalid version." );
+ assertTextPresent( "User is not authorized to delete artifacts in repository '\"/>1<script>alert('xss')</script>'." );
+ assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Repository id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertElementValue("//input[@id='deleteArtifact_groupId']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='deleteArtifact_artifactId']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='deleteArtifact_version']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//select[@id='deleteArtifact_repositoryId']", "internal");
+ }
+
+ public void testEditAppearanceImmunityToURLCrossSiteScripting()
+ {
+ getSelenium().open( "/archiva/admin/configureAppearance.action?organisationName=<script>alert('xss')</script>&organisationUrl=<script>alert('xss')</script>&organisationLogo=<script>alert('xss')</script>");
+ assertAppearancePage();
+ assertXpathCount("//td[text()=\"<script>alert('xss')</script>\"]", 1);
+ assertXpathCount("//code[text()=\"<script>alert('xss')</script>\"]", 2);
+
+ }
+
+ public void testEditAppearanceImmunityToEncodedURLCrossSiteScripting()
+ {
+ getSelenium().open( "/archiva/admin/configureAppearance.action?organisationName=%3Cscript%3Ealert('xss')%3C%2Fscript%3E&organisationUrl=%3Cscript%3Ealert('xss')%3C%2Fscript%3E&organisationLogo=%3Cscript%3Ealert('xss')%3C%2Fscript%3E");
+ assertAppearancePage();
+ assertXpathCount("//td[text()=\"<script>alert('xss')</script>\"]", 1);
+ assertXpathCount("//code[text()=\"<script>alert('xss')</script>\"]", 2);
+ }
+
+ public void testAddLegacyArtifactImmunityToURLCrossSiteScripting()
+ {
+ getSelenium().open( "/archiva/admin/addLegacyArtifactPath!commit.action?legacyArtifactPath.path=\"/>1<script>alert('xss')</script>&groupId=\"/>1<script>alert('xss')</script>&artifactId=\"/>1<script>alert('xss')</script>&version=\"/>1<script>alert('xss')</script>&classifier=\"/>1<script>alert('xss')</script>&type=\"/>1<script>alert('xss')</script>");
+ assertAddLegacyArtifactPathPage();
+ assertTextPresent( "Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertElementValue("//input[@id='addLegacyArtifactPath_legacyArtifactPath_path']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='addLegacyArtifactPath_artifactId']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='addLegacyArtifactPath_version']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='addLegacyArtifactPath_groupId']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='addLegacyArtifactPath_classifier']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='addLegacyArtifactPath_type']", "\"/>1<script>alert('xss')</script>");
+ }
+
+ public void testAddLegacyArtifactImmunityToEncodedURLCrossSiteScripting()
+ {
+ getSelenium().open( "/archiva/admin/addLegacyArtifactPath!commit.action?legacyArtifactPath.path=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&groupId=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&artifactId=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&version=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&classifier=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&type=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E");
+ assertAddLegacyArtifactPathPage();
+ assertTextPresent( "Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertElementValue("//input[@id='addLegacyArtifactPath_legacyArtifactPath_path']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='addLegacyArtifactPath_artifactId']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='addLegacyArtifactPath_version']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='addLegacyArtifactPath_groupId']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='addLegacyArtifactPath_classifier']", "\"/>1<script>alert('xss')</script>");
+ assertElementValue("//input[@id='addLegacyArtifactPath_type']", "\"/>1<script>alert('xss')</script>");
+ }
+
+ public void testDeleteNetworkProxyImmunityToURLCrossSiteScripting()
+ {
+ getSelenium().open( "/archiva/admin/deleteNetworkProxy!confirm.action?proxyid=\"/>1<script>alert('xss')</script>");
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testDeleteNetworkProxyImmunityToEncodedURLCrossSiteScripting()
+ {
+ getSelenium().open( "/archiva/admin/deleteNetworkProxy!confirm.action?proxyid=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E");
+ assertTextPresent( "Security Alert - Invalid Token Found" );
+ assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
+ }
+
+ public void testAddManagedRepositoryImmunityToInputFieldCrossSiteScripting()
+ {
+ goToRepositoriesPage();
+ 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" );
+ // xss inputs are blocked by validation.
+ 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." );
+ }
+
+ public void testEditAppearanceImmunityToInputFieldCrossSiteScripting()
+ {
+ goToAppearancePage();
+ clickLinkWithText( "Edit" );
+ addEditAppearance( "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>" );
+ // xss inputs are blocked by validation.
+ 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);
+ }
+
+ public void testEditAppearanceImmunityToCrossSiteScriptingRendering()
+ {
+ goToAppearancePage();
+ clickLinkWithText( "Edit" );
+ addEditAppearance( "xss" , "http://\">test<script>alert(\"xss\")</script>" , "http://\">test<script>alert(\"xss\")</script>" );
+ // escaped html/url prevents cross-site scripting exploits
+ assertXpathCount("//td[text()=\"xss\"]", 1);
+ assertXpathCount("//code[text()='http://\">test<script>alert(\"xss\")</script>']", 2);
+ }
+
+ public void testAddLegacyArtifactPathImmunityToInputFieldCrossSiteScripting()
+ {
+ goToLegacySupportPage();
+ clickLinkWithText( "Add" );
+ addLegacyArtifactPath( "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>");
+ // xss inputs are blocked by validation.
+ assertTextPresent( "Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ }
+
+ public void testAddNetworkProxyImmunityToInputFieldCrossSiteScripting()
+ {
+ goToNetworkProxiesPage();
+ addNetworkProxy( "test<script>alert('xss')</script>", "test<script>alert('xss')</script>", "test<script>alert('xss')</script>", "test<script>alert('xss')</script>", "test<script>alert('xss')</script>", "");
+ // xss inputs are blocked by validation.
+ assertTextPresent( "Proxy id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+ assertTextPresent( "Protocol must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), dots(.), colons(:), and dashes(-)." );
+ assertTextPresent( "Host must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
+ assertTextPresent( "Invalid field value for field \"proxy.port\"." );
+ assertTextPresent( "Username must only contain alphanumeric characters, at's(@), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.apache.archiva.web.test.listener;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.regex.Pattern;
+
+import org.apache.archiva.web.test.parent.AbstractSeleniumTest;
+import org.apache.commons.io.FileUtils;
+import org.testng.ITestResult;
+import org.testng.TestListenerAdapter;
+import com.thoughtworks.selenium.Selenium;
+
+public class CaptureScreenShotsListener
+ extends TestListenerAdapter
+{
+ @Override
+ public void onTestSkipped( ITestResult tr )
+ {
+ System.out.println( "Test " + tr.getName() + " -> Skipped" );
+ super.onTestSkipped( tr );
+ }
+
+ @Override
+ public void onTestFailure( ITestResult tr )
+ {
+ captureError( tr );
+ System.out.println( "Test " + tr.getName() + " -> Failed" );
+ super.onTestFailure( tr );
+ }
+
+ @Override
+ public void onTestSuccess( ITestResult tr )
+ {
+ System.out.println( "Test " + tr.getName() + " -> Success" );
+ super.onTestFailure( tr );
+ }
+
+ private void captureError( ITestResult tr )
+ {
+ SimpleDateFormat sdf = new SimpleDateFormat( "yyyy.MM.dd-HH_mm_ss" );
+ String time = sdf.format( new Date() );
+ File targetPath = new File( "target", "screenshots" );
+ StackTraceElement stackTrace[] = tr.getThrowable().getStackTrace();
+ String cName = tr.getTestClass().getName();
+ int index = getStackTraceIndexOfCallingClass( cName, stackTrace );
+ String methodName = stackTrace[index].getMethodName();
+ int lNumber = stackTrace[index].getLineNumber();
+ String lineNumber = Integer.toString( lNumber );
+ String className = cName.substring( cName.lastIndexOf( '.' ) + 1 );
+ targetPath.mkdirs();
+ Selenium selenium = AbstractSeleniumTest.getSelenium();
+ String fileBaseName = methodName + "_" + className + ".java_" + lineNumber + "-" + time;
+ try
+ {
+ selenium.windowMaximize();
+ File fileName = new File( targetPath, fileBaseName + ".png" );
+ selenium.captureEntirePageScreenshot( fileName.getAbsolutePath(), "background=#FFFFFF" );
+ }
+ catch ( RuntimeException e )
+ {
+ System.out.println( "Error when take screenshot for test " + tr.getName() + ": " + e.getMessage() );
+ try
+ {
+ File fileName = new File( targetPath, fileBaseName + ".html" );
+ FileUtils.writeStringToFile( fileName, selenium ==null? "nothing" : selenium.getHtmlSource() );
+ }
+ catch ( IOException ioe )
+ {
+ System.out.println( ioe.getMessage() );
+ }
+ }
+ }
+
+ private int getStackTraceIndexOfCallingClass( String nameOfClass, StackTraceElement[] stackTrace )
+ {
+ boolean match = false;
+ int i = 0;
+ do
+ {
+ String className = stackTrace[i].getClassName();
+ match = Pattern.matches( nameOfClass, className );
+ i++;
+ // avoid AIOOBE
+ if ( i >= stackTrace.length )
+ {
+ return 0;
+ }
+ }
+ while ( match == false );
+ i--;
+ return i;
+ }
+}
--- /dev/null
+package org.apache.archiva.web.test.parent;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.archiva.web.test.XPathExpressionUtil;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public abstract class AbstractArchivaTest
+ extends AbstractSeleniumTest
+{
+ protected String username;
+
+ protected String fullname;
+
+ public String getUserEmail()
+ {
+ String email = getProperty( "USERROLE_EMAIL" );
+ return email;
+ }
+
+ public String getUserRolePassword()
+ {
+ String password = getProperty( "USERROLE_PASSWORD" );
+ return password;
+ }
+
+ public String getUserRoleNewPassword()
+ {
+ String password_new = getProperty( "NEW_USERROLE_PASSWORD" );
+ return password_new;
+ }
+
+ public String getBasedir()
+ {
+ String basedir = System.getProperty( "basedir" );
+
+ if ( basedir == null )
+ {
+ basedir = new File( "" ).getAbsolutePath();
+ }
+
+ return basedir;
+ }
+
+ public String getAdminUsername()
+ {
+ String adminUsername = getProperty( "ADMIN_USERNAME" );
+ return adminUsername;
+ }
+
+ public String getAdminPassword()
+ {
+ String adminPassword = getProperty( "ADMIN_PASSWORD" );
+ return adminPassword;
+ }
+
+ public void assertCreateAdmin()
+ {
+ assertPage( "Apache Archiva \\ Create Admin User" );
+ assertTextPresent( "Username" );
+ assertFieldValue( "admin", "user.username" );
+ assertTextPresent( "Full Name*" );
+ assertElementPresent( "user.fullName" );
+ assertTextPresent( "Email Address*" );
+ assertElementPresent( "user.email" );
+ assertTextPresent( "Password*" );
+ assertElementPresent( "user.password" );
+ assertTextPresent( "Confirm Password*" );
+ assertElementPresent( "user.confirmPassword" );
+ assertButtonWithValuePresent( "Create Admin" );
+ }
+
+ public void submitAdminData( String fullname, String email, String password )
+ {
+ setFieldValue( "user.fullName", fullname );
+ setFieldValue( "user.email", email );
+ setFieldValue( "user.password", password );
+ setFieldValue( "user.confirmPassword", password );
+ submit();
+ }
+
+ //Go to Login Page
+ public void goToLoginPage()
+ {
+ getSelenium().open( baseUrl );
+ clickLinkWithText( "Login" );
+ assertLoginPage();
+ }
+
+ public void submitUserData( String username, String password, boolean rememberme, boolean success )
+ {
+
+ setFieldValue( "username", username );
+ setFieldValue( "password", password );
+ if ( rememberme )
+ {
+ checkField( "rememberMe" );
+ }
+
+ submit();
+ if ( success )
+ {
+ assertUserLoggedIn( username );
+ }
+ else
+ {
+ assertLoginPage();
+ }
+ }
+
+ public void assertLoginPage()
+ {
+ assertPage( "Apache Archiva \\ Login Page" );
+ assertTextPresent( "Login" );
+ assertTextPresent( "Register" );
+ assertTextPresent( "Username" );
+ assertElementPresent( "username" );
+ assertTextPresent( "Password" );
+ assertElementPresent( "password" );
+ assertTextPresent( "Remember Me" );
+ assertElementPresent( "rememberMe" );
+ assertButtonWithValuePresent( "Login" );
+ assertButtonWithValuePresent( "Cancel" );
+ assertTextPresent( "Need an Account? Register!" );
+ assertTextPresent( "Forgot your Password? Request a password reset." );
+ }
+
+ //User Management
+ public void goToUserManagementPage()
+ {
+ getSelenium().open( "/archiva/security/userlist.action" );
+ assertUserManagementPage();
+ }
+
+ public void assertUserManagementPage()
+ {
+ assertPage( "Apache Archiva \\ [Admin] User List" );
+ assertTextPresent( "[Admin] List of Users in Role: Any" );
+ assertTextPresent( "Navigation" );
+ assertImgWithAlt( "First" );
+ assertImgWithAlt( "Prev" );
+ assertImgWithAlt( "Next" );
+ assertImgWithAlt( "Last" );
+ assertTextPresent( "Display Rows" );
+ assertTextPresent( "Username" );
+ assertTextPresent( "Full Name" );
+ assertTextPresent( "Email" );
+ assertTextPresent( "Permanent" );
+ assertTextPresent( "Validated" );
+ assertTextPresent( "Locked" );
+ assertTextPresent( "Tasks" );
+ assertTextPresent( "Tools" );
+ assertTextPresent( "Tasks" );
+ assertTextPresent( "The following tools are available for administrators to manipulate the user list." );
+ assertButtonWithValuePresent( "Create New User" );
+ assertButtonWithValuePresent( "Show Users In Role" );
+ assertElementPresent( "roleName" );
+ assertTextPresent( "Reports" );
+ assertTextPresent( "Name" );
+ assertTextPresent( "Types" );
+ assertTextPresent( "User List" );
+ assertTextPresent( "Roles Matrix" );
+ }
+
+/* //User Role
+ public void goToUserRolesPage()
+ {
+ clickLinkWithText( "User Roles" );
+ assertUserRolesPage();
+ }*/
+
+ public void assertUserRolesPage()
+ {
+ assertPage( "Apache Archiva \\ [Admin] User Edit" );
+ assertTextPresent( "[Admin] User Roles" );
+ assertTextPresent( "Username" );
+ assertTextPresent( "Full Name" );
+ String userRoles =
+ "Guest,Registered User,System Administrator,User Administrator,Global Repository Observer,Global Repository Manager,Repository Observer,Repository Manager,internal";
+ String[] arrayRole = userRoles.split( "," );
+ for ( String userroles : arrayRole )
+ {
+ assertTextPresent( userroles );
+ }
+ }
+
+ public void assertDeleteUserPage( String username )
+ {
+ assertPage( "Apache Archiva \\ [Admin] User Delete" ); //TODO
+ assertTextPresent( "[Admin] User Delete" );
+ assertTextPresent( "The following user will be deleted:" );
+ assertTextPresent( "Username: " + username );
+ assertButtonWithValuePresent( "Delete User" );
+ }
+
+ public void createUser( String userName, String fullName, String email, String password, boolean valid )
+ {
+ createUser( userName, fullName, email, password, password, valid );
+ }
+
+ private void createUser( String userName, String fullName, String emailAd, String password, String confirmPassword,
+ boolean valid )
+ {
+ //login( getAdminUsername() , getAdminPassword() );
+ getSelenium().open( "/archiva/security/userlist.action" );
+ clickButtonWithValue( "Create New User" );
+ assertCreateUserPage();
+ setFieldValue( "user.username", userName );
+ setFieldValue( "user.fullName", fullName );
+ setFieldValue( "user.email", emailAd );
+ setFieldValue( "user.password", password );
+ setFieldValue( "user.confirmPassword", confirmPassword );
+ submit();
+
+ assertUserRolesPage();
+ clickButtonWithValue( "Submit" );
+
+ if ( valid )
+ {
+ String[] columnValues = { userName, fullName, emailAd };
+ assertElementPresent( XPathExpressionUtil.getTableRow( columnValues ) );
+ }
+ else
+ {
+ assertCreateUserPage();
+ }
+ }
+
+ public void deleteUser( String userName, String fullName, String emailAdd )
+ {
+ deleteUser( userName, fullName, emailAdd, false, false );
+ }
+
+ public void deleteUser( String userName, String fullName, String emailAd, boolean validated, boolean locked )
+ {
+ String[] columnValues = { userName, fullName, emailAd };
+ //clickLinkWithText( "userlist" );
+ clickLinkWithXPath( "//table[@id='ec_table']/tbody[2]/tr[3]/td[7]/a/img" );
+ assertDeleteUserPage( userName );
+ submit();
+ assertElementNotPresent( XPathExpressionUtil.getTableRow( columnValues ) );
+ }
+
+ public void login( String username, String password )
+ {
+ login( username, password, true, "Login Page" );
+ }
+
+ public void login( String username, String password, boolean valid, String assertReturnPage )
+ {
+ if ( isLinkPresent( "Login" ) )
+ {
+ goToLoginPage();
+
+ submitLoginPage( username, password, false, valid, assertReturnPage );
+ }
+ if ( valid )
+ {
+ assertUserLoggedIn( username );
+ }
+ }
+
+ public void submitLoginPage( String username, String password )
+ {
+ submitLoginPage( username, password, false, true, "Login Page" );
+ }
+
+ public void submitLoginPage( String username, String password, boolean validUsernamePassword )
+ {
+ submitLoginPage( username, password, false, validUsernamePassword, "Login Page" );
+ }
+
+ public void submitLoginPage( String username, String password, boolean rememberMe, boolean validUsernamePassword,
+ String assertReturnPage )
+ {
+ assertLoginPage();
+ setFieldValue( "username", username );
+ setFieldValue( "password", password );
+ if ( rememberMe )
+ {
+ checkField( "rememberMe" );
+ }
+ clickButtonWithValue( "Login" );
+
+ if ( validUsernamePassword )
+ {
+ assertUserLoggedIn( username );
+ }
+ else
+ {
+ if ( "Login Page".equals( assertReturnPage ) )
+ {
+ assertLoginPage();
+ }
+ else
+ {
+ assertPage( assertReturnPage );
+ }
+ }
+ }
+
+ protected void assertUserLoggedIn( String username )
+ {
+ assertTextPresent( "Current User:" );
+ assertTextPresent( username );
+ assertLinkPresent( "Edit Details" );
+ assertLinkPresent( "Logout" );
+ assertTextNotPresent( "Login" );
+ }
+
+ // User Roles
+ public void assertUserRoleCheckBoxPresent( String value )
+ {
+ getSelenium().isElementPresent(
+ "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value
+ + "']" );
+ }
+
+ public void assertResourceRolesCheckBoxPresent( String value )
+ {
+ getSelenium().isElementPresent( "xpath=//input[@name='addDSelectedRoles' and @value='" + value + "']" );
+ }
+
+ public void checkUserRoleWithValue( String value )
+ {
+ assertUserRoleCheckBoxPresent( value );
+ getSelenium().click(
+ "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value
+ + "']" );
+ }
+
+ public void checkResourceRoleWithValue( String value )
+ {
+ assertResourceRolesCheckBoxPresent( value );
+ getSelenium().click( "xpath=//input[@name='addDSelectedRoles' and @value='" + value + "']" );
+ }
+
+
+ public void changePassword( String oldPassword, String newPassword )
+ {
+ assertPage( "Apache Archiva \\ Change Password" );
+ setFieldValue( "existingPassword", oldPassword );
+ setFieldValue( "newPassword", newPassword );
+ setFieldValue( "newPasswordConfirm", newPassword );
+ clickButtonWithValue( "Change Password" );
+ }
+
+ public void assertCreateUserPage()
+ {
+ assertPage( "Apache Archiva \\ [Admin] User Create" );
+ assertTextPresent( "[Admin] User Create" );
+ assertTextPresent( "Username*:" );
+ assertElementPresent( "user.username" );
+ assertTextPresent( "Full Name*:" );
+ assertElementPresent( "user.fullName" );
+ assertTextPresent( "Email Address*:" );
+ assertElementPresent( "user.email" );
+ assertTextPresent( "Password*:" );
+ assertElementPresent( "user.password" );
+ assertTextPresent( "Confirm Password*:" );
+ assertElementPresent( "user.confirmPassword" );
+ assertButtonWithValuePresent( "Create User" );
+ }
+
+ public void assertLeftNavMenuWithRole( String role )
+ {
+ if ( role.equals( "Guest" ) || role.equals( "Registered User" ) || role.equals( "Global Repository Observer" )
+ || role.equals( "Repository Observer - internal" ) || role.equals( "Repository Observer - snapshots" ) )
+ {
+ assertTextPresent( "Search" );
+ assertLinkPresent( "Find Artifact" );
+ assertLinkPresent( "Browse" );
+ assertLinkNotPresent( "Repositories" );
+ }
+ else if ( role.equals( "User Administrator" ) )
+ {
+ assertTextPresent( "Search" );
+ assertLinkPresent( "Find Artifact" );
+ assertLinkPresent( "Browse" );
+ assertLinkPresent( "User Management" );
+ assertLinkPresent( "User Roles" );
+ assertLinkNotPresent( "Repositories" );
+ }
+ else if ( role.equals( "Global Repository Manager" ) || role.equals( "Repository Manager - internal" )
+ || role.equals( "Repository Manager - snapshots" ) )
+ {
+ assertTextPresent( "Search" );
+ assertLinkPresent( "Find Artifact" );
+ assertLinkPresent( "Browse" );
+ assertLinkPresent( "Upload Artifact" );
+ assertLinkPresent( "Delete Artifact" );
+ assertLinkNotPresent( "Repositories" );
+ }
+ else
+ {
+ assertTextPresent( "Search" );
+ String navMenu =
+ "Find Artifact,Browse,Reports,User Management,User Roles,Appearance,Upload Artifact,Delete Artifact,Repository Groups,Repositories,Proxy Connectors,Legacy Support,Network Proxies,Repository Scanning,Database";
+ String[] arrayMenu = navMenu.split( "," );
+ for ( String navmenu : arrayMenu )
+ {
+ assertLinkPresent( navmenu );
+ }
+ }
+ }
+
+ //Find Artifact
+ public void goToFindArtifactPage()
+ {
+ getSelenium().open( "/archiva/findArtifact.action" );
+ assertFindArtifactPage();
+ }
+
+ public void assertFindArtifactPage()
+ {
+ assertPage( "Apache Archiva \\ Find Artifact" );
+ assertTextPresent( "Find Artifact" );
+ assertTextPresent( "Search for:" );
+ assertTextPresent( "Checksum:" );
+ assertElementPresent( "q" );
+ assertButtonWithValuePresent( "Search" );
+ }
+
+ //Appearance
+ public void goToAppearancePage()
+ {
+ getSelenium().open( "/archiva/admin/configureAppearance.action" );
+ assertAppearancePage();
+ }
+
+ public void assertAppearancePage()
+ {
+ assertPage( "Apache Archiva \\ Configure Appearance" );
+ String appearance =
+ "Appearance,Organization Details,The logo in the top right of the screen is controlled by the following settings.,Organization Information,Name,URL,Logo URL";
+ String[] arrayAppearance = appearance.split( "," );
+ for ( String appear : arrayAppearance )
+ {
+ assertTextPresent( appear );
+ }
+ assertLinkPresent( "Edit" );
+ assertLinkPresent( "Change your appearance" );
+ }
+
+ public void addEditAppearance( String name, String url, String logoUrl )
+ {
+ setFieldValue( "organisationName", name );
+ setFieldValue( "organisationUrl", url );
+ setFieldValue( "organisationLogo", logoUrl );
+ clickButtonWithValue( "Save" );
+ }
+
+ // Upload Artifact
+ public void goToAddArtifactPage()
+ {
+ getSelenium().open( "/archiva/upload.action" );
+ assertAddArtifactPage();
+ }
+
+ public void assertAddArtifactPage()
+ {
+ assertPage( "Apache Archiva \\ Upload Artifact" );
+ assertTextPresent( "Upload Artifact" );
+
+ String artifact =
+ "Upload Artifact,Group Id*:,Artifact Id*:,Version*:,Packaging*:,Classifier:,Generate Maven 2 POM,Artifact File*:,POM File:,Repository Id:";
+ String[] arrayArtifact = artifact.split( "," );
+ for ( String arrayartifact : arrayArtifact )
+ {
+ assertTextPresent( arrayartifact );
+ }
+
+ String artifactElements =
+ "upload_groupId,upload_artifactId,upload_version,upload_packaging,upload_classifier,upload_generatePom,upload_artifact,upload_pom,upload_repositoryId,upload_0";
+ String[] arrayArtifactElements = artifactElements.split( "," );
+ for ( String artifactelements : arrayArtifactElements )
+ {
+ assertElementPresent( artifactelements );
+ }
+ }
+
+ public void addArtifact( String groupId, String artifactId, String version, String packaging,
+ String artifactFilePath, String repositoryId )
+ {
+ addArtifact( groupId, artifactId, version, packaging, true, artifactFilePath, repositoryId );
+ }
+
+ public void addArtifact( String groupId, String artifactId, String version, String packaging, boolean generatePom,
+ String artifactFilePath, String repositoryId )
+ {
+ goToAddArtifactPage();
+ setFieldValue( "groupId", groupId );
+ setFieldValue( "artifactId", artifactId );
+ setFieldValue( "version", version );
+ setFieldValue( "packaging", packaging );
+
+ if ( generatePom )
+ {
+ checkField( "generatePom" );
+ }
+
+ String path;
+ if ( artifactFilePath != null && artifactFilePath.trim().length() > 0 )
+ {
+ File f = new File( artifactFilePath );
+ try
+ {
+ path = f.getCanonicalPath();
+ }
+ catch ( IOException e )
+ {
+ path = f.getAbsolutePath();
+ }
+ }
+ else
+ {
+ path = artifactFilePath;
+ }
+
+ setFieldValue( "artifact", path );
+ setFieldValue( "repositoryId", repositoryId );
+
+ clickButtonWithValue( "Submit" );
+ }
+
+ public void goToRepositoriesPage()
+ {
+ if ( !getTitle().equals( "Apache Archiva \\ Administration - Repositories" ) )
+ {
+ getSelenium().open( "/archiva/admin/repositories.action" );
+ }
+ assertRepositoriesPage();
+ }
+
+ public void assertRepositoriesPage()
+ {
+ assertPage( "Apache Archiva \\ Administration - Repositories" );
+ assertTextPresent( "Administration - Repositories" );
+ assertTextPresent( "Managed Repositories" );
+ assertTextPresent( "Remote Repositories" );
+ }
+
+ public void addManagedRepository( String identifier, String name, String directory, String indexDirectory,
+ String type, String cron, String daysOlder, String retentionCount )
+ {
+ //goToRepositoriesPage();
+ //clickLinkWithText( "Add" );
+ setFieldValue( "repository.id", identifier );
+ setFieldValue( "repository.name", name );
+ setFieldValue( "repository.location", directory );
+ setFieldValue( "repository.indexDir", indexDirectory );
+ selectValue( "repository.layout", type );
+ setFieldValue( "repository.refreshCronExpression", cron );
+ setFieldValue( "repository.daysOlder", daysOlder );
+ setFieldValue( "repository.retentionCount", retentionCount );
+ //TODO
+ clickButtonWithValue( "Add Repository" );
+ }
+
+ // artifact management
+ public void assertDeleteArtifactPage()
+ {
+ assertPage( "Apache Archiva \\ Delete Artifact" );
+ assertTextPresent( "Delete Artifact" );
+ assertTextPresent( "Group Id*:" );
+ assertTextPresent( "Artifact Id*:" );
+ assertTextPresent( "Version*:" );
+ assertTextPresent( "Repository Id:" );
+ assertElementPresent( "groupId" );
+ assertElementPresent( "artifactId" );
+ assertElementPresent( "version" );
+ assertElementPresent( "repositoryId" );
+ assertButtonWithValuePresent( "Submit" );
+ }
+
+ // network proxies
+ public void goToNetworkProxiesPage()
+ {
+ clickLinkWithText( "Network Proxies" );
+ assertNetworkProxiesPage();
+ }
+
+ public void assertNetworkProxiesPage()
+ {
+ assertPage( "Apache Archiva \\ Administration - Network Proxies" );
+ assertTextPresent( "Administration - Network Proxies" );
+ assertTextPresent( "Network Proxies" );
+ assertLinkPresent( "Add Network Proxy" );
+ }
+
+ public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username,
+ String password )
+ {
+ //goToNetworkProxiesPage();
+ clickLinkWithText( "Add Network Proxy" );
+ assertAddNetworkProxy();
+ setFieldValue( "proxy.id", identifier );
+ setFieldValue( "proxy.protocol", protocol );
+ setFieldValue( "proxy.host", hostname );
+ setFieldValue( "proxy.port", port );
+ setFieldValue( "proxy.username", username );
+ setFieldValue( "proxy.password", password );
+ clickButtonWithValue( "Save Network Proxy" );
+ }
+
+ public void assertAddNetworkProxy()
+ {
+ assertPage( "Apache Archiva \\ Admin: Add Network Proxy" );
+ assertTextPresent( "Admin: Add Network Proxy" );
+ assertTextPresent( "Add network proxy:" );
+ assertTextPresent( "Identifier*:" );
+ assertTextPresent( "Protocol*:" );
+ assertTextPresent( "Hostname*:" );
+ assertTextPresent( "Port*:" );
+ assertTextPresent( "Username:" );
+ assertTextPresent( "Password:" );
+ assertButtonWithValuePresent( "Save Network Proxy" );
+ }
+
+ // Legacy Support
+ public void goToLegacySupportPage()
+ {
+ getSelenium().open( "/archiva/admin/legacyArtifactPath.action" );
+ assertLegacySupportPage();
+ }
+
+ public void assertLegacySupportPage()
+ {
+ assertPage( "Apache Archiva \\ Administration - Legacy Support" );
+ assertTextPresent( "Administration - Legacy Artifact Path Resolution" );
+ assertTextPresent( "Path Mappings" );
+ assertLinkPresent( "Add" );
+ }
+
+ public void addLegacyArtifactPath( String path, String groupId, String artifactId, String version,
+ String classifier, String type )
+ {
+ assertAddLegacyArtifactPathPage();
+ setFieldValue( "legacyArtifactPath.path", path );
+ setFieldValue( "groupId", groupId );
+ setFieldValue( "artifactId", artifactId );
+ setFieldValue( "version", version );
+ setFieldValue( "classifier", classifier );
+ setFieldValue( "type", type );
+ clickButtonWithValue( "Add Legacy Artifact Path" );
+ }
+
+ public void assertAddLegacyArtifactPathPage()
+ {
+ assertPage( "Apache Archiva \\ Admin: Add Legacy Artifact Path" );
+ assertTextPresent( "Admin: Add Legacy Artifact Path" );
+ assertTextPresent(
+ "Enter the legacy path to map to a particular artifact reference, then adjust the fields as necessary." );
+ String element =
+ "addLegacyArtifactPath_legacyArtifactPath_path,addLegacyArtifactPath_groupId,addLegacyArtifactPath_artifactId,addLegacyArtifactPath_version,addLegacyArtifactPath_classifier,addLegacyArtifactPath_type";
+ String[] arrayElement = element.split( "," );
+ for ( String arrayelement : arrayElement )
+ {
+ assertElementPresent( arrayelement );
+ }
+ assertButtonWithValuePresent( "Add Legacy Artifact Path" );
+ }
+
+ protected void logout()
+ {
+ clickLinkWithText( "Logout" );
+ assertTextNotPresent( "Current User:" );
+ assertLinkNotPresent( "Edit Details" );
+ assertLinkNotPresent( "Logout" );
+ assertLinkPresent( "Login" );
+ }
+}
--- /dev/null
+package org.apache.archiva.web.test.parent;
+
+public abstract class AbstractArtifactManagementTest
+ extends AbstractArchivaTest
+{
+
+ public String getGroupId()
+ {
+ String groupId = getProperty( "GROUPID" ) ;
+ return groupId;
+ }
+
+ public String getArtifactId()
+ {
+ String artifactId = getProperty( "ARTIFACTID" ) ;
+ return artifactId;
+ }
+
+ public String getVersion()
+ {
+ String version = getProperty( "VERSION" ) ;
+ return version;
+ }
+
+ public String getPackaging()
+ {
+ String packaging = getProperty( "PACKAGING" ) ;
+ return packaging;
+ }
+
+ public String getArtifactFilePath()
+ {
+ return "src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
+ }
+
+ public String getRepositoryId()
+ {
+ String repositoryId = getProperty( "REPOSITORYID" ) ;
+ return repositoryId;
+ }
+
+ public void goToDeleteArtifactPage()
+ {
+ login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
+ getSelenium().open( "/archiva/deleteArtifact.action" );
+ assertDeleteArtifactPage();
+ }
+
+ public void deleteArtifact( String groupId, String artifactId, String version, String repositoryId )
+ {
+ goToDeleteArtifactPage();
+ setFieldValue( "groupId" , groupId );
+ setFieldValue( "artifactId" , artifactId );
+ setFieldValue( "version" , version );
+ selectValue( "repositoryId" , repositoryId );
+ clickButtonWithValue( "Submit" ) ;
+ }
+}
--- /dev/null
+package org.apache.archiva.web.test.parent;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public abstract class AbstractArtifactReportsTest
+ extends AbstractArchivaTest
+{
+
+ //Reports
+ public void goToReportsPage()
+ {
+ getSelenium().open( "/archiva/report/pickReport.action" );
+ assertReportsPage();
+ }
+
+ public void assertReportsPage()
+ {
+ assertPage( "Apache Archiva \\ Reports" );
+ assertTextPresent( "Reports" );
+ assertTextPresent( "Repository Statistics" );
+ assertTextPresent( "Repositories To Be Compared" );
+ assertElementPresent( "availableRepositories" );
+ assertButtonWithValuePresent( "v" );
+ assertButtonWithValuePresent( "^" );
+ assertButtonWithValuePresent( "<-" );
+ assertButtonWithValuePresent( "->" );
+ assertButtonWithValuePresent( "<<--" );
+ assertButtonWithValuePresent( "-->>" );
+ assertButtonWithValuePresent( "<*>" );
+ assertElementPresent( "selectedRepositories" );
+ assertButtonWithValuePresent( "v" );
+ assertButtonWithValuePresent( "^" );
+ assertTextPresent( "Row Count" );
+ assertElementPresent( "rowCount" );
+ assertTextPresent( "Start Date" );
+ assertElementPresent( "startDate" );
+ assertTextPresent( "End Date" );
+ assertElementPresent( "endDate" );
+ assertButtonWithValuePresent( "View Statistics" );
+ assertTextPresent( "Repository Health" );
+ assertTextPresent( "Row Count" );
+ assertElementPresent( "rowCount" );
+ assertTextPresent( "Group ID" );
+ assertElementPresent( "groupId" );
+ assertTextPresent( "Repository ID" );
+ assertElementPresent( "repositoryId" );
+ assertButtonWithValuePresent( "Show Report" );
+ }
+
+ public void compareRepositories( String labelSelected, String startDate, String endDate )
+ {
+ goToReportsPage();
+ getSelenium().removeSelection( "generateStatisticsReport_availableRepositories" , labelSelected );
+ clickButtonWithValue( "->" , false );
+ getSelenium().type( "startDate", startDate );
+ //clickLinkWithLocator( "1" , false );
+ //getSelenium().click( "endDate" );
+ getSelenium().type( "endDate", endDate );
+ //clickLinkWithLocator( "30" , false );
+ clickButtonWithValue( "View Statistics" );
+ }
+
+}
--- /dev/null
+package org.apache.archiva.web.test.parent;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public abstract class AbstractBrowseTest
+ extends AbstractArchivaTest
+{
+
+ //Browse
+ public void goToBrowsePage()
+ {
+ getSelenium().open( "/archiva/browse" );
+ assertBrowsePage();
+ }
+
+ public void assertBrowsePage()
+ {
+ assertPage( "Apache Archiva \\ Browse Repository" );
+ assertTextPresent( "Browse Repository" );
+ assertTextPresent( "Groups" );
+ }
+
+}
--- /dev/null
+package org.apache.archiva.web.test.parent;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import org.testng.Assert;
+
+public abstract class AbstractRepositoryTest
+ extends AbstractArchivaTest
+{
+ // Repository Groups
+ public void goToRepositoryGroupsPage()
+ {
+ if( !getTitle().equals( "Apache Archiva \\ Administration - Repository Groups" ) )
+ {
+ getSelenium().open( "/archiva/admin/repositoryGroups.action" );
+ }
+ assertRepositoryGroupsPage();
+ }
+
+ public void assertRepositoryGroupsPage()
+ {
+ assertPage( "Apache Archiva \\ Administration - Repository Groups" );
+ assertTextPresent( "Administration - Repository Groups" );
+ assertTextPresent( "Identifier*:" );
+ assertElementPresent( "repositoryGroup.id" );
+ assertButtonWithValuePresent( "Add Group" );
+ assertTextPresent( "Repository Groups" );
+ }
+
+ public void assertAddedRepositoryLink( String repositoryGroupName)
+ {
+ assertPage( "Apache Archiva \\ Administration - Repository Groups" );
+ String repositoryGroupUrlValue = "repository/" + repositoryGroupName + "/";
+ String baseUrlValue = "archiva";
+ String repositoryGroupLink = baseUrl.replaceFirst( baseUrlValue, repositoryGroupUrlValue);
+ assertTextPresent( repositoryGroupLink );
+ }
+
+ public void assertAddedRepositoryToRepositoryGroups( String repositoryName)
+ {
+ assertPage( "Apache Archiva \\ Administration - Repository Groups" );
+ assertTextPresent( repositoryName );
+ assertTextPresent( "Archiva Managed Internal Repository" );
+ assertAddedRepositoryLink( repositoryName );
+ }
+
+ public void assertDeleteRepositoryGroupPage( String repositoryName)
+ {
+ assertPage( "Apache Archiva \\ Admin: Delete Repository Group" );
+ assertTextPresent( "WARNING: This operation can not be undone." );
+ assertTextPresent( "Are you sure you want to delete the following repository group?" );
+ assertElementPresent( "//preceding::td[text()='ID:']//following::td/code[text()='" + repositoryName + "']" );
+ assertButtonWithValuePresent( "Confirm" );
+ assertButtonWithValuePresent( "Cancel" );
+ }
+
+ public void addRepositoryGroup( String repoGroupName )
+ {
+ goToRepositoryGroupsPage();
+ setFieldValue( "repositoryGroup.id", repoGroupName );
+ clickButtonWithValue( "Add Group" );
+ }
+
+ public void addRepositoryToRepositoryGroup( String repositoryGroupName, String repositoryName )
+ {
+ goToRepositoryGroupsPage();
+ String s = getSelenium().getBodyText();
+ if ( s.contains( "No Repository Groups Defined." ) )
+ {
+ setFieldValue( "repositoryGroup.id" , repositoryGroupName );
+ clickButtonWithValue( "Add Group" );
+ //assertAddedRepositoryLink( repositoryGroupName );
+
+ selectValue( "addRepositoryToGroup_repoId" , repositoryName );
+ clickButtonWithValue( "Add Repository" );
+ assertAddedRepositoryToRepositoryGroups( repositoryName );
+ }
+ else
+ {
+ //assertAddedRepositoryLink( repositoryGroupName );
+ selectValue( "addRepositoryToGroup_repoId" , repositoryName );
+ clickButtonWithValue( "Add Repository" );
+ }
+ }
+
+ public void deleteRepositoryInRepositoryGroups()
+ {
+ goToRepositoryGroupsPage();
+ getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" );
+ waitPage();
+ }
+
+ public void deleteRepositoryGroup( String repositoryName )
+ {
+ getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" );
+ waitPage();
+ assertDeleteRepositoryGroupPage( repositoryName );
+ clickButtonWithValue( "Confirm" );
+ }
+
+ ///////////////////////////////
+ // proxy connectors
+ ///////////////////////////////
+ public void goToProxyConnectorsPage()
+ {
+ clickLinkWithText( "Proxy Connectors" );
+ assertProxyConnectorsPage();
+ }
+
+ public void assertProxyConnectorsPage()
+ {
+ assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
+ assertTextPresent( "Administration - Proxy Connectors" );
+ assertTextPresent( "Repository Proxy Connectors" );
+ assertTextPresent( "internal" );
+ assertTextPresent( "Archiva Managed Internal Repository" );
+ assertTextPresent( "Proxy Connector" );
+ assertTextPresent( "Central Repository" );
+ assertTextPresent( "Java.net Repository for Maven 2" );
+ }
+
+ public void assertAddProxyConnectorPage()
+ {
+ assertPage( "Apache Archiva \\ Admin: Add Proxy Connector" );
+ assertTextPresent( "Admin: Add Proxy Connector" );
+ String proxy = "Network Proxy*:,Managed Repository*:,Remote Repository*:,Policies:,Return error when:,On remote error:,Releases:,Snapshots:,Checksum:,Cache failures:,Properties:,No properties have been set.,Black List:,No black list patterns have been set.,White List:,No white list patterns have been set.";
+ String[] arrayProxy = proxy.split( "," );
+ for ( String arrayproxy : arrayProxy )
+ assertTextPresent( arrayproxy );
+ /*String proxyElements = "addProxyConnector_connector_proxyId,addProxyConnector_connector_sourceRepoId,addProxyConnector_connector_targetRepoId,policy_propagate-errors-on-update,policy_propagate-errors,policy_releases,policy_snapshots,policy_checksum,policy_cache-failures,propertiesEntry,propertiesValue,blackListEntry,whiteListEntry";
+ String[] arrayProxyElements = proxyElements.split( "," );
+ for ( String arrayproxyelements : arrayProxyElements )
+ assertTextPresent( arrayproxyelements );*/
+ assertButtonWithValuePresent( "Add Property" );
+ assertButtonWithValuePresent( "Add Pattern" );
+ assertButtonWithValuePresent( "Add Proxy Connector" );
+ }
+
+ // this only fills in the values of required fields in adding Proxy Connectors
+ public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo )
+ {
+ goToProxyConnectorsPage();
+ clickLinkWithText( "Add" );
+ assertAddProxyConnectorPage();
+ selectValue( "connector.proxyId" , networkProxy );
+ selectValue( "connector.sourceRepoId" , managedRepo );
+ selectValue( "connector.targetRepoId" , remoteRepo );
+ }
+
+ public void deleteProxyConnector()
+ {
+ goToProxyConnectorsPage();
+ clickLinkWithXPath( "//div[@id='contentArea']/div[2]/div[1]/div[2]/div[1]/a[3]/img" );
+ assertPage( "Apache Archiva \\ Admin: Delete Proxy Connectors" );
+ clickButtonWithValue( "Delete" );
+ assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
+ }
+
+ ///////////////////////////////
+ // network proxies
+ ///////////////////////////////
+
+ public void editNetworkProxies( String fieldName, String value)
+ {
+ //goToNetworkProxiesPage();
+ clickLinkWithText( "Edit Network Proxy" );
+ setFieldValue( fieldName, value);
+ clickButtonWithValue( "Save Network Proxy" );
+ }
+
+ public void deleteNetworkProxy()
+ {
+ //goToNetworkProxiesPage();
+ clickLinkWithText( "Delete Network Proxy" );
+ assertPage( "Apache Archiva \\ Admin: Delete Network Proxy" );
+ assertTextPresent( "WARNING: This operation can not be undone." );
+ clickButtonWithValue( "Delete" );
+ }
+
+ // remote repositories
+ public void assertAddRemoteRepository()
+ {
+ assertPage( "Apache Archiva \\ Admin: Add Remote Repository" );
+ String remote = "Identifier*:,Name*:,URL*:,Username:,Password:,Timeout in seconds:,Type:";
+ String[] arrayRemote = remote.split( "," );
+ for ( String arrayremote : arrayRemote )
+ assertTextPresent( arrayremote );
+ String remoteElements = "addRemoteRepository_repository_id,addRemoteRepository_repository_name,addRemoteRepository_repository_url,addRemoteRepository_repository_username,addRemoteRepository_repository_password,addRemoteRepository_repository_timeout,addRemoteRepository_repository_layout";
+ String[] arrayRemoteElements = remoteElements.split( "," );
+ for ( String arrayremotelement : arrayRemoteElements )
+ assertElementPresent( arrayremotelement );
+ }
+
+ public void assertDeleteRemoteRepositoryPage()
+ {
+ assertPage( "Apache Archiva \\ Admin: Delete Remote Repository" );
+ assertTextPresent( "Admin: Delete Remote Repository" );
+ assertTextPresent( "WARNING: This operation can not be undone." );
+ assertTextPresent( "Are you sure you want to delete the following remote repository?" );
+ assertButtonWithValuePresent( "Confirm" );
+ assertButtonWithValuePresent( "Cancel" );
+ }
+
+ public void addRemoteRepository( String identifier, String name, String url, String username, String password, String timeout, String type )
+ {
+ //goToRepositoriesPage();
+ assertAddRemoteRepository();
+ setFieldValue( "addRemoteRepository_repository_id" , identifier );
+ setFieldValue( "addRemoteRepository_repository_name" , name );
+ setFieldValue( "addRemoteRepository_repository_url" , url );
+ setFieldValue( "addRemoteRepository_repository_username" , username );
+ setFieldValue( "addRemoteRepository_repository_password" , password );
+ setFieldValue( "addRemoteRepository_repository_timeout" , timeout );
+ selectValue( "addRemoteRepository_repository_layout" , type );
+ clickButtonWithValue( "Add Repository" );
+ }
+
+ public void deleteRemoteRepository()
+ {
+ goToRepositoriesPage();
+ clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" );
+ assertDeleteRemoteRepositoryPage();
+ clickButtonWithValue( "Confirm" );
+ }
+
+ public void editRemoteRepository( String fieldName, String value)
+ {
+ goToRepositoriesPage();
+ clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" );
+ setFieldValue( fieldName, value );
+ clickButtonWithValue( "Update Repository" );
+ }
+
+ public void editManagedRepository( String fieldName, String value )
+ {
+ goToRepositoriesPage();
+ clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
+ assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
+ setFieldValue(fieldName, value);
+ //TODO
+ clickButtonWithValue( "Update Repository" );
+ }
+
+ public void editManagedRepository(String name, String directory, String indexDirectory, String type, String cron, String daysOlder, String retentionCount)
+ {
+ goToRepositoriesPage();
+ clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
+ assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
+ setFieldValue( "repository.name" , name );
+ setFieldValue( "repository.location" , directory );
+ setFieldValue( "repository.indexDir" , indexDirectory );
+ selectValue( "repository.layout", type );
+ setFieldValue( "repository.refreshCronExpression" , cron );
+ setFieldValue( "repository.daysOlder" , daysOlder );
+ setFieldValue( "repository.retentionCount" , retentionCount );
+ clickButtonWithValue( "Update Repository" );
+ }
+
+ public void deleteManagedRepository()
+ {
+ clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[2]" );
+ assertPage( "Apache Archiva \\ Admin: Delete Managed Repository" );
+ clickButtonWithValue( "Delete Configuration Only" );
+ }
+
+ public String getRepositoryDir()
+ {
+ File f = new File( "" );
+ String artifactFilePath = f.getAbsolutePath();
+ return artifactFilePath + "/target/";
+ }
+
+ /////////////////////////////////////////////
+ // Repository Scanning
+ /////////////////////////////////////////////
+ public void goToRepositoryScanningPage()
+ {
+ clickLinkWithText( "Repository Scanning" );
+ assertRepositoryScanningPage();
+ }
+
+ public void assertRepositoryScanningPage()
+ {
+ assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
+ assertTextPresent( "Administration - Repository Scanning" );
+ assertTextPresent( "Repository Scanning - File Types" );
+ String artifactsTypes = "**/*.pom,**/*.jar,**/*.ear,**/*.war,**/*.car,**/*.sar,**/*.mar,**/*.rar,**/*.dtd,**/*.tld,**/*.tar.gz,**/*.tar.bz2,**/*.zip";
+ String [] arrayArtifactTypes = artifactsTypes.split( "," );
+ for (int i = 0; i < arrayArtifactTypes.length; i++)
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table."+i+".0"), arrayArtifactTypes[i]);
+
+ String autoremove = "**/*.bak,**/*~,**/*-";
+ String [] arrayAutoremove = autoremove.split( "," );
+ for (int i = 0; i < arrayAutoremove.length; i++)
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table."+i+".0"), arrayAutoremove[i]);
+
+ String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**";
+ String [] arrayIgnored = ignored.split( "," );
+ for (int i = 0; i < arrayIgnored.length; i++)
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table."+i+".0"), arrayIgnored[i]);
+
+ String indexableContent = "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld";
+ String [] arrayIndexableContent = indexableContent.split( "," );
+ for (int i = 0; i < arrayIndexableContent.length; i++)
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table."+i+".0"), arrayIndexableContent[i]);
+ }
+
+ /////////////////////////////////////////////
+ // Database
+ /////////////////////////////////////////////
+ public void goToDatabasePage()
+ {
+ clickLinkWithText( "Database" );
+ assertDatabasePage();
+ }
+
+ public void assertDatabasePage()
+ {
+ assertPage( "Apache Archiva \\ Administration - Database" );
+ assertTextPresent( "Administration - Database" );
+ assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
+ assertTextPresent( "Cron:" );
+ assertElementPresent( "database_cron" );
+ assertButtonWithValuePresent( "Update Cron" );
+ assertButtonWithValuePresent( "Update Database Now" );
+ assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
+ assertTextPresent( "Database - Artifact Cleanup Scanning" );
+ }
+}
--- /dev/null
+package org.apache.archiva.web.test.parent;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public abstract class AbstractSearchTest
+ extends AbstractArchivaTest
+{
+ //Search
+ public void goToSearchPage()
+ {
+ if ( !"Apache Archiva \\ Quick Search".equals( getTitle() ) )
+ {
+ clickLinkWithText( "Search" );
+ getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+
+ assertPage( "Apache Archiva \\ Quick Search" );
+ }
+ }
+
+ public void assertSearchPage()
+ {
+ assertPage( "Apache Archiva \\ Quick Search" );
+ assertTextPresent( "Search for" );
+ assertElementPresent( "quickSearch_q" );
+ assertButtonWithValuePresent( "Search" );
+ //assertLinkPresent( "Advanced Search" );
+ assertTextPresent( "Enter your search terms. A variety of data will be searched for your keywords." );
+ //assertButtonWithDivIdPresent( "searchHint" );
+ }
+
+ public void searchForArtifact( String artifactId )
+ {
+ goToSearchPage();
+
+ getSelenium().type( "dom=document.forms[1].elements[0]", artifactId );
+ clickButtonWithValue( "Search" );
+ }
+
+ public void searchForArtifactAdvancedSearch( String groupId, String artifactId, String version, String repositoryId,
+ String className, String rowCount )
+ {
+ goToSearchPage();
+
+ clickLinkWithXPath( "//div[@id='contentArea']/div[1]/a[1]/strong", false );
+ assertElementPresent( "filteredSearch_searchField" );
+ assertElementPresent( "filteredSearch_repositoryId" );
+
+ if ( groupId != null )
+ {
+ selectValue( "filteredSearch_searchField", "Group ID" );
+ clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false );
+
+ assertElementPresent( "groupId" );
+ setFieldValue( "groupId", groupId );
+ }
+
+ if ( artifactId != null )
+ {
+ selectValue( "filteredSearch_searchField", "Artifact ID" );
+ clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false );
+
+ assertElementPresent( "artifactId" );
+ setFieldValue( "artifactId", artifactId );
+ }
+
+ if ( version != null )
+ {
+ selectValue( "filteredSearch_searchField", "Version" );
+ clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false );
+
+ assertElementPresent( "version" );
+ setFieldValue( "version", version );
+ }
+
+ if ( className != null )
+ {
+ selectValue( "filteredSearch_searchField", "Class/Package Name" );
+ clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false );
+
+ assertElementPresent( "className" );
+ setFieldValue( "className", className );
+ }
+
+ if ( rowCount != null )
+ {
+ selectValue( "filteredSearch_searchField", "Row Count" );
+ clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false );
+
+ assertElementPresent( "rowCount" );
+ setFieldValue( "rowCount", rowCount );
+ }
+
+ if ( repositoryId != null )
+ {
+ selectValue( "filteredSearch_repositoryId", repositoryId );
+ }
+ clickSubmitWithLocator( "filteredSearch_0" );
+ }
+}
--- /dev/null
+package org.apache.archiva.web.test.parent;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+
+import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.Selenium;
+import org.apache.commons.io.IOUtils;
+import org.testng.Assert;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id: AbstractSeleniumTestCase.java 761154 2009-04-02 03:31:19Z wsmoak $
+ */
+
+public abstract class AbstractSeleniumTest {
+
+ public static String baseUrl;
+
+ public static String maxWaitTimeInMs;
+
+ private static ThreadLocal<Selenium> selenium = new ThreadLocal<Selenium>();
+
+ public static Properties p;
+
+ private final static String PROPERTIES_SEPARATOR = "=";
+
+ public void open()
+ throws Exception
+ {
+ p = new Properties();
+ p.load( this.getClass().getClassLoader().getResourceAsStream( "testng.properties" ) );
+
+ //baseUrl = getProperty( "BASE_URL" );
+ maxWaitTimeInMs = System.getProperty( "MAX_WAIT_TIME_IN_MS" );
+ }
+
+ /**
+ * Initialize selenium
+ */
+ public void open( String baseUrl, String browser, String seleniumHost, int seleniumPort )
+ throws Exception
+ {
+ this.baseUrl = baseUrl;
+
+ if ( getSelenium() == null )
+ {
+ DefaultSelenium s = new DefaultSelenium( seleniumHost, seleniumPort, browser, baseUrl );
+ s.start();
+ s.setTimeout( maxWaitTimeInMs );
+ selenium.set( s );
+ }
+ }
+
+ public static Selenium getSelenium()
+ {
+ if (selenium.get() != null)
+ {
+ return selenium.get();
+ }
+ DefaultSelenium s =
+ new DefaultSelenium( System.getProperty("seleniumHost","localhost"), Integer.getInteger( "seleniumPort",4444), System.getProperty("browser"), baseUrl );
+ s.start();
+ s.setTimeout( maxWaitTimeInMs );
+ selenium.set( s );
+ return selenium.get();
+ }
+
+ protected String getProperty( String key )
+ {
+ return p.getProperty( key );
+ }
+
+ protected String getEscapeProperty( String key )
+ {
+ InputStream input = this.getClass().getClassLoader().getResourceAsStream( "testng.properties" );
+ String value = null;
+ List<String> lines;
+ try
+ {
+ lines = IOUtils.readLines( input );
+ }
+ catch ( IOException e )
+ {
+ lines = new ArrayList<String>();
+ }
+ for ( String l : lines )
+ {
+ if ( l != null && l.startsWith( key ) )
+ {
+ int indexSeparator = l.indexOf( PROPERTIES_SEPARATOR );
+ value = l.substring( indexSeparator + 1 ).trim();
+ break;
+ }
+ }
+ return value;
+ }
+
+
+ /**
+ * Close selenium session. Called from AfterSuite method of sub-class
+ */
+ public void close()
+ throws Exception
+ {
+ if ( getSelenium() != null )
+ {
+ getSelenium().stop();
+ selenium.set( null );
+ }
+ }
+
+ // *******************************************************
+ // Auxiliar methods. This method help us and simplify test.
+ // *******************************************************
+
+ public void assertFieldValue( String fieldValue, String fieldName )
+ {
+ assertElementPresent( fieldName );
+ Assert.assertEquals( fieldValue, getSelenium().getValue( fieldName ) );
+ }
+
+ public void assertPage( String title )
+ {
+ Assert.assertEquals( getTitle(), title );
+ }
+
+ public String getTitle()
+ {
+ // Collapse spaces
+ return getSelenium().getTitle().replaceAll( "[ \n\r]+", " " );
+ }
+
+ public String getHtmlContent()
+ {
+ return getSelenium().getHtmlSource();
+ }
+
+ public String getText( String locator )
+ {
+ return getSelenium().getText( locator );
+ }
+
+ public void assertTextPresent( String text )
+ {
+ Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." );
+ }
+
+ public void assertTextNotPresent( String text )
+ {
+ Assert.assertFalse( getSelenium().isTextPresent( text ), "'" + text + "' is present." );
+ }
+
+ public void assertElementPresent( String elementLocator )
+ {
+ Assert.assertTrue( isElementPresent( elementLocator ), "'" + elementLocator + "' isn't present." );
+ }
+
+ public void assertElementNotPresent( String elementLocator )
+ {
+ Assert.assertFalse( isElementPresent( elementLocator ), "'" + elementLocator + "' is present." );
+ }
+
+ public void assertLinkPresent( String text )
+ {
+ Assert.assertTrue( isElementPresent( "link=" + text ), "The link '" + text + "' isn't present." );
+ }
+
+ public void assertLinkNotPresent( String text )
+ {
+ Assert.assertFalse( isElementPresent( "link=" + text ), "The link('" + text + "' is present." );
+ }
+
+ public void assertImgWithAlt( String alt )
+ {
+ assertElementPresent( "/¯img[@alt='" + alt + "']" );
+ }
+
+ public void assertImgWithAltAtRowCol( boolean isALink, String alt, int row, int column )
+ {
+ String locator = "//tr[" + row + "]/td[" + column + "]/";
+ locator += isALink ? "a/" : "";
+ locator += "img[@alt='" + alt + "']";
+
+ assertElementPresent( locator );
+ }
+
+ public void assertCellValueFromTable( String expected, String tableElement, int row, int column )
+ {
+ Assert.assertEquals( expected, getCellValueFromTable( tableElement, row, column ) );
+ }
+
+ public boolean isTextPresent( String text )
+ {
+ return getSelenium().isTextPresent( text );
+ }
+
+ public boolean isLinkPresent( String text )
+ {
+ return isElementPresent( "link=" + text );
+ }
+
+ public boolean isElementPresent( String locator )
+ {
+ return getSelenium().isElementPresent( locator );
+ }
+
+ public void waitPage()
+ {
+ getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+ }
+
+ public String getFieldValue( String fieldName )
+ {
+ return getSelenium().getValue( fieldName );
+ }
+
+ public String getCellValueFromTable( String tableElement, int row, int column )
+ {
+ return getSelenium().getTable( tableElement + "." + row + "." + column );
+ }
+
+ public void selectValue( String locator, String value )
+ {
+ getSelenium().select( locator, "label=" + value );
+ }
+
+ public void assertOptionPresent( String selectField, String[] options )
+ {
+ assertElementPresent( selectField );
+ String[] optionsPresent = getSelenium().getSelectOptions( selectField );
+ List<String> expected = Arrays.asList( options );
+ List<String> present = Arrays.asList( optionsPresent );
+ Assert.assertTrue( present.containsAll( expected ), "Options expected are not included in present options" );
+ }
+
+ public void assertSelectedValue( String value, String fieldName )
+ {
+ assertElementPresent( fieldName );
+ String optionsPresent = getSelenium().getSelectedLabel( value );
+ Assert.assertEquals( optionsPresent, value );
+ }
+
+ public void submit()
+ {
+ clickLinkWithXPath( "//input[@type='submit']" );
+ }
+
+ public void assertButtonWithValuePresent( String text )
+ {
+ Assert.assertTrue( isButtonWithValuePresent( text ), "'" + text + "' button isn't present" );
+ }
+
+ public void assertButtonWithIdPresent( String id )
+ {
+ Assert.assertTrue( isButtonWithIdPresent( id ), "'Button with id =" + id + "' isn't present" );
+ }
+
+ public void assertButtonWithValueNotPresent( String text )
+ {
+ Assert.assertFalse( isButtonWithValuePresent( text ), "'" + text + "' button is present" );
+ }
+
+ public boolean isButtonWithValuePresent( String text )
+ {
+ return isElementPresent( "//button[@value='" + text + "']" )
+ || isElementPresent( "//input[@value='" + text + "']" );
+ }
+
+ public boolean isButtonWithIdPresent( String text )
+ {
+ return isElementPresent( "//button[@id='" + text + "']" ) || isElementPresent( "//input[@id='" + text + "']" );
+ }
+
+ public void clickButtonWithValue( String text )
+ {
+ clickButtonWithValue( text, true );
+ }
+
+ public void clickButtonWithValue( String text, boolean wait )
+ {
+ assertButtonWithValuePresent( text );
+
+ if ( isElementPresent( "//button[@value='" + text + "']" ) )
+ {
+ clickLinkWithXPath( "//button[@value='" + text + "']", wait );
+ }
+ else
+ {
+ clickLinkWithXPath( "//input[@value='" + text + "']", wait );
+ }
+ }
+
+ public void clickSubmitWithLocator( String locator )
+ {
+ clickLinkWithLocator( locator );
+ }
+
+ public void clickSubmitWithLocator( String locator, boolean wait )
+ {
+ clickLinkWithLocator( locator, wait );
+ }
+
+ public void clickImgWithAlt( String alt )
+ {
+ clickLinkWithLocator( "//img[@alt='" + alt + "']" );
+ }
+
+ public void clickLinkWithText( String text )
+ {
+ clickLinkWithText( text, true );
+ }
+
+ public void clickLinkWithText( String text, boolean wait )
+ {
+ clickLinkWithLocator( "link=" + text, wait );
+ }
+
+ public void clickLinkWithXPath( String xpath )
+ {
+ clickLinkWithXPath( xpath, true );
+ }
+
+ public void clickLinkWithXPath( String xpath, boolean wait )
+ {
+ clickLinkWithLocator( "xpath=" + xpath, wait );
+ }
+
+ public void clickLinkWithLocator( String locator )
+ {
+ clickLinkWithLocator( locator, true );
+ }
+
+ public void clickLinkWithLocator( String locator, boolean wait )
+ {
+ assertElementPresent( locator );
+ getSelenium().click( locator );
+ if ( wait )
+ {
+ waitPage();
+ }
+ }
+
+ public void setFieldValues( Map<String, String> fieldMap )
+ {
+ Map.Entry<String, String> entry;
+
+ for ( Iterator<Entry<String, String>> entries = fieldMap.entrySet().iterator(); entries.hasNext(); )
+ {
+ entry = entries.next();
+
+ getSelenium().type( entry.getKey(), entry.getValue() );
+ }
+ }
+
+ public void setFieldValue( String fieldName, String value )
+ {
+ getSelenium().type( fieldName, value );
+ }
+
+ public void checkField( String locator )
+ {
+ getSelenium().check( locator );
+ }
+
+ public void uncheckField( String locator )
+ {
+ getSelenium().uncheck( locator );
+ }
+
+ public boolean isChecked( String locator )
+ {
+ return getSelenium().isChecked( locator );
+ }
+
+ public void assertIsChecked( String locator )
+ {
+ Assert.assertTrue( getSelenium().isChecked( locator ) );
+ }
+
+ public void assertIsNotChecked( String locator )
+ {
+ Assert.assertFalse( getSelenium().isChecked( locator ) );
+ }
+
+ public void assertXpathCount(String locator, int expectedCount)
+ {
+ Assert.assertEquals( getSelenium().getXpathCount(locator).intValue(), expectedCount );
+ }
+
+ public void assertElementValue(String locator, String expectedValue)
+ {
+ Assert.assertEquals(getSelenium().getValue(locator), expectedValue);
+ }
+}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractArchivaTest;
-import org.testng.annotations.Test;
-
-@Test( groups = { "appearance" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
-public class AppearanceTest extends AbstractArchivaTest
-{
- public void testAddAppearanceEmptyValues()
- {
- goToAppearancePage();
- clickLinkWithText( "Edit" );
- addEditAppearance( "", "", "" );
- assertTextPresent( "You must enter a name" );
- }
-
- @Test( dependsOnMethods = { "testAddAppearanceEmptyValues" })
- public void testAddAppearanceInvalidValues()
- {
- addEditAppearance( "<>~+[ ]'\"" , "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"" , "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"" );
- 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);
- }
-
- @Test( dependsOnMethods = { "testAddAppearanceInvalidValues" })
- public void testAddAppearanceInvalidOrganisationName()
- {
- addEditAppearance( "<>~+[ ]'\"" , "http://www.apache.org/" , "http://www.apache.org/images/asf_logo_wide.gifs" );
- 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(-)." );
- }
-
- @Test( dependsOnMethods = { "testAddAppearanceInvalidOrganisationName" })
- public void testAddAppearanceInvalidOrganisationUrl()
- {
- addEditAppearance( "The Apache Software Foundation" , "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"" , "http://www.apache.org/images/asf_logo_wide.gifs" );
- assertTextPresent( "You must enter a URL" );
- assertXpathCount("//span[@class='errorMessage' and text()='You must enter a URL']", 1);
- }
-
- @Test( dependsOnMethods = { "testAddAppearanceInvalidOrganisationUrl" })
- public void testAddAppearanceInvalidOrganisationLogo()
- {
- addEditAppearance( "The Apache Software Foundation" , "http://www.apache.org/" , "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"" );
- assertTextPresent( "You must enter a URL" );
- assertXpathCount("//span[@class='errorMessage' and text()='You must enter a URL']", 1);
- }
-
- @Test( dependsOnMethods = { "testAddAppearanceInvalidOrganisationLogo" })
- public void testAddAppearanceValidValues()
- {
- addEditAppearance( "The Apache Software Foundation" , "http://www.apache.org/" , "http://www.apache.org/images/asf_logo_wide.gifs" );
- assertTextPresent( "The Apache Software Foundation" );
- }
-
- @Test( dependsOnMethods = { "testAddAppearanceValidValues" })
- public void testEditAppearance()
- {
- clickLinkWithText( "Edit" );
- addEditAppearance( "Apache Software Foundation" , "http://www.apache.org/" , "http://www.apache.org/images/asf_logo_wide.gifs" );
- assertTextPresent( "Apache Software Foundation" );
- }
-
-}
\ No newline at end of file
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractArchivaTest;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Optional;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-@Test( groups = { "about" }, alwaysRun = true )
-public class ArchivaAdminTest
- extends AbstractArchivaTest
-{
-
- @Override
- @AfterTest
- public void close()
- throws Exception
- {
- super.close();
- }
-
- @Override
- @BeforeSuite
- public void open()
- throws Exception
- {
- super.open();
- }
-
- @BeforeTest
- @Parameters( { "baseUrl", "browser", "seleniumHost", "seleniumPort" } )
- public void initializeArchiva( String baseUrl, String browser, @Optional( "localhost" ) String seleniumHost, @Optional( "4444" ) int seleniumPort ) throws Exception
- {
- super.open( baseUrl, browser, seleniumHost, seleniumPort );
- getSelenium().open( baseUrl );
- String title = getSelenium().getTitle();
- if ( title.endsWith( "Create Admin User" ) )
- {
- assertCreateAdmin();
- String fullname = getProperty( "ADMIN_FULLNAME" );
- String username = getProperty( "ADMIN_USERNAME" );
- String mail = getProperty( "ADMIN_EMAIL" );
- String password = getProperty( "ADMIN_PASSWORD" );
- submitAdminData( fullname, mail, password );
- assertUserLoggedIn( username );
- submit();
- clickLinkWithText( "Logout" );
- }
- }
-
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractArtifactManagementTest;
-import org.testng.annotations.Test;
-
-@Test( groups = { "artifactmanagement" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
-public class ArtifactManagementTest
- extends AbstractArtifactManagementTest
-{
-
-
- public void testAddArtifactNullValues()
- {
- goToAddArtifactPage();
- clickButtonWithValue( "Submit" );
- assertTextPresent( "Please add a file to upload." );
- assertTextPresent( "Invalid version." );
- assertTextPresent( "You must enter a groupId." );
- assertTextPresent( "You must enter an artifactId." );
- assertTextPresent( "You must enter a version" );
- assertTextPresent( "You must enter a packaging" );
- }
-
- @Test(dependsOnMethods = { "testAddArtifactNullValues" } )
- public void testAddArtifactNoGroupId()
- {
- addArtifact( " " , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
- assertTextPresent( "You must enter a groupId." );
- }
-
- @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
- public void testAddArtifactNoArtifactId()
- {
-
- addArtifact( getGroupId() , " ", getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
- assertTextPresent( "You must enter an artifactId." );
- }
-
- @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
- public void testAddArtifactNoVersion()
- {
- addArtifact( getGroupId() , getArtifactId(), " ", getPackaging() , getArtifactFilePath(), getRepositoryId() );
- assertTextPresent( "You must enter a version." );
- }
-
- @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
- public void testAddArtifactInvalidVersion()
- {
- addArtifact( getGroupId() , getArtifactId(), "asdf", getPackaging() , getArtifactFilePath(), getRepositoryId() );
- assertTextPresent( "Invalid version." );
- }
-
- @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
- public void testAddArtifactNoPackaging()
- {
- addArtifact( getGroupId() , getArtifactId(), getVersion(), " " , getArtifactFilePath(), getRepositoryId() );
- assertTextPresent( "You must enter a packaging." );
- }
-
- @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
- public void testAddArtifactNoFilePath()
- {
- addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , " ", getRepositoryId() );
- assertTextPresent( "Please add a file to upload." );
- }
-
- @Test(groups = "requiresUpload")
- public void testAddArtifactValidValues()
- {
- addArtifact( getGroupId() , "testAddArtifactValidValues", getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
- assertTextPresent( "Artifact 'test:testAddArtifactValidValues:1.0' was successfully deployed to repository 'internal'" );
- }
-
- //MRM-747
- @Test(groups = "requiresUpload")
- public void testAddArtifactBlockRedeployments()
- {
- addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
- assertTextPresent( "Overwriting released artifacts in repository '" + getRepositoryId() + "' is not allowed." );
- }
-
- @Test(groups = "requiresUpload")
- public void testDeleteArtifact()
- {
- //prep
- String groupId = getProperty( "GROUPID1" );
- String artifactId = getProperty( "ARTIFACTID1" );
- String version = getProperty( "VERSION1" );
- String packaging = getProperty( "PACKAGING1" );
- String repositoryId = getProperty( "REPOSITORYID1" );
- // TODO: do this differently as it only works in Firefox's chrome mode
- addArtifact( groupId , artifactId, version, packaging , getArtifactFilePath(), repositoryId );
- assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deployed to repository 'internal'" );
-
- deleteArtifact( "delete", "delete", "1.0", "internal");
- assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" );
- }
-
- public void testDeleteArtifactNoGroupId()
- {
- deleteArtifact( " ", "delete", "1.0", "internal");
- assertTextPresent( "You must enter a groupId." );
- }
-
- public void testDeleteArtifactNoArtifactId()
- {
- deleteArtifact( "delete", " ", "1.0", "internal");
- assertTextPresent( "You must enter an artifactId." );
- }
-
- public void testDeleteArtifactNoVersion()
- {
- deleteArtifact( "delete", "delete", " ", "internal");
- assertTextPresent( "Invalid version." );
- assertTextPresent( "You must enter a version." );
- }
-
- public void testDeleteArtifactInvalidVersion()
- {
- deleteArtifact( "delete", "delete", "asdf", "internal");
- assertTextPresent( "Invalid version." );
- }
-
- // HTML select should have the proper value, else it will cause a selenium error: Option with label 'customValue' not found
- public void testDeleteArtifactInvalidValues()
- {
- deleteArtifact( "<> \\/~+[ ]'\"", "<> \\/~+[ ]'\"", "<>", "internal");
- assertTextPresent( "Invalid version." );
- assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- }
-
- public void testDeleteArtifactInvalidGroupId()
- {
- deleteArtifact( "<> \\/~+[ ]'\"", "delete", "1.0", "internal");
- assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- }
-
- public void testDeleteArtifactInvalidArtifactId()
- {
- deleteArtifact( "delete", "<> \\/~+[ ]'\"", "1.0", "internal");
- assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- }
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractArchivaTest;
-import org.testng.annotations.Test;
-
-@Test( groups = { "auditlogsreport" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
-public class AuditLogsReportTest
- extends AbstractArchivaTest
-{
- private void goToAuditLogReports()
- {
- getSelenium().open( "/archiva/report/queryAuditLogReport.action" );
- }
-
- private void assertAuditLogsReportPage()
- {
- assertPage( "Apache Archiva \\ Audit Log Report" );
- assertTextPresent( "Audit Log Report" );
-
- assertElementPresent( "repository" );
- assertElementPresent( "groupId" );
- assertElementPresent( "artifactId" );
- assertElementPresent( "startDate" );
- assertElementPresent( "endDate" );
- assertElementPresent( "rowCount" );
- assertButtonWithValuePresent( "View Audit Log" );
- }
-
- @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
- public void testAuditLogsReport()
- {
- goToAuditLogReports();
- assertAuditLogsReportPage();
- assertTextPresent( "Latest Events" );
- }
-
- @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
- public void testViewAuditLogsNoDataFound()
- {
- goToAuditLogReports();
- assertAuditLogsReportPage();
-
- setFieldValue( "groupId", "non.existing" );
- submit();
-
- assertPage( "Apache Archiva \\ Audit Log Report" );
- assertTextPresent( "Results" );
- assertTextPresent( "No audit logs found." );
- }
-
- // TODO: add test for adding via WebDAV
- @Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload")
- public void testViewAuditLogsDataFound()
- {
- goToAuditLogReports();
- assertAuditLogsReportPage();
-
- selectValue( "repository", "internal" );
- setFieldValue( "groupId", "test" );
- submit();
-
- assertAuditLogsReportPage();
- assertTextPresent( "Results" );
- assertTextNotPresent( "No audit logs found." );
- assertTextPresent( "testAddArtifactValidValues-1.0.jar" );
- assertTextPresent( "Uploaded File" );
- assertTextPresent( "internal" );
- assertTextPresent( "admin" );
- }
-
- // TODO: add test for adding via WebDAV
- @Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload")
- public void testViewAuditLogsOnlyArtifactIdIsSpecified()
- {
- goToAuditLogReports();
- assertAuditLogsReportPage();
-
- selectValue( "repository", "internal" );
- setFieldValue( "artifactId", "test" );
- submit();
-
- assertAuditLogsReportPage();
- assertTextPresent( "Results" );
- assertTextNotPresent( "No audit logs found." );
- assertTextPresent( "testAddArtifactValidValues-1.0.jar" );
- assertTextPresent( "Uploaded File" );
- assertTextPresent( "internal" );
- assertTextPresent( "admin" );
- }
-
- // TODO: add test for adding via WebDAV
- @Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload")
- public void testViewAuditLogsForAllRepositories()
- {
- goToAuditLogReports();
- assertAuditLogsReportPage();
-
- selectValue( "repository", "all" );
- submit();
-
- assertAuditLogsReportPage();
- assertTextPresent( "Results" );
- assertTextNotPresent( "No audit logs found." );
- assertTextPresent( "testAddArtifactValidValues-1.0.jar" );
- assertTextPresent( "Uploaded File" );
- assertTextPresent( "internal" );
- assertTextPresent( "admin" );
- }
-
- @Test (dependsOnMethods = { "testAddArtifactValidValues", "testUserWithRepoManagerInternalRole" }, groups = "requiresUpload")
- public void testViewAuditLogsViewAuditEventsForManageableRepositoriesOnly()
- {
- String groupId = getProperty( "SNAPSHOT_GROUPID" );
- String artifactId = getProperty( "SNAPSHOT_ARTIFACTID" );
- String version = getProperty( "SNAPSHOT_VERSION" );
- String repo = getProperty( "SNAPSHOT_REPOSITORYID" );
- String packaging = getProperty( "SNAPSHOT_PACKAGING" );
-
- addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repo );
- assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + version +
- "' was successfully deployed to repository '" + repo + "'" );
-
- clickLinkWithText( "Logout" );
-
- login( getProperty( "REPOMANAGER_INTERNAL_USERNAME" ), getUserRoleNewPassword() );
-
- goToAuditLogReports();
- assertAuditLogsReportPage();
-
- selectValue( "repository", "all" );
- submit();
-
- assertAuditLogsReportPage();
- assertTextPresent( "Results" );
- assertTextNotPresent( "No audit logs found." );
- assertTextPresent( "testAddArtifactValidValues-1.0.jar" );
- assertTextPresent( "Uploaded File" );
- assertTextPresent( "internal" );
- assertTextPresent( "admin" );
-
- assertTextNotPresent( artifactId + "-" + version + "." + packaging );
- clickLinkWithText( "Logout" );
- login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
- }
-
- @Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload")
- public void testViewAuditLogsReportForGroupId()
- {
- String groupId = getProperty("AUDITLOG_GROUPID");
- String artifactId = getProperty("ARTIFACTID");
- String version = getProperty("VERSION");
- String packaging = getProperty("PACKAGING");
- String repositoryId = getProperty("REPOSITORYID");
- String expectedArtifact = getProperty("AUDITLOG_EXPECTED_ARTIFACT");
-
- addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repositoryId );
-
- goToAuditLogReports();
-
- selectValue( "repository", repositoryId );
- setFieldValue( "groupId", groupId );
- submit();
-
- assertAuditLogsReportPage();
- assertTextPresent( expectedArtifact );
- assertTextPresent( repositoryId );
- }
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-import org.apache.archiva.web.test.parent.AbstractBrowseTest;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-@Test( groups = { "browse" }, dependsOnMethods = { "testAddArtifactNullValues" } )
-public class BrowseTest
- extends AbstractBrowseTest
-{
-
- public void testBrowseArtifact()
- {
- goToBrowsePage();
- assertBrowsePage();
- }
-
- @Test( dependsOnMethods = { "testAddArtifactValidValues" } )
- public void testClickArtifactFromBrowse()
- {
- goToBrowsePage();
- assertBrowsePage();
- clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
- assertPage( "Apache Archiva \\ Browse Repository" );
- assertTextPresent( "Artifacts" );
- }
-
- // MRM-1278
- @Test(groups = {"requiresUpload"})
- public void testCorrectRepositoryInBrowse()
- {
- String releasesRepo = getProperty( "RELEASES_REPOSITORY" );
-
- // create releases repository first
- goToRepositoriesPage();
- clickLinkWithText( "Add" );
- addManagedRepository( getProperty( "RELEASES_REPOSITORY" ), "Releases Repository",
- new File( getBasedir(), "target/repository/releases" ).getPath(), "", "Maven 2.x Repository",
- "0 0 * * * ?", "", "" );
- assertTextPresent( "Releases Repository" );
-
- String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
-
- String path = "src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
- // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
- // upload a snapshot artifact to repository 'releases'
- addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", path, releasesRepo );
- assertTextPresent( "Artifact 'archiva:archiva-webapp:1.0-SNAPSHOT' was successfully deployed to repository '" + releasesRepo + "'" );
-
- goToBrowsePage();
- assertBrowsePage();
- assertGroupsPage( "archiva/" );
- assertArtifactsPage( "archiva-webapp/" );
- assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" );
-
- // upload a snapshot artifact to repository 'snapshots'
- addArtifact( "continuum", "continuum-core", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
- assertTextPresent( "Artifact 'continuum:continuum-core:1.0-SNAPSHOT' was successfully deployed to repository '" + snapshotsRepo + "'" );
-
- goToBrowsePage();
- assertBrowsePage();
- assertGroupsPage( "continuum/" );
- assertArtifactsPage( "continuum-core/" );
- assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "continuum", "continuum-core", "1.0-SNAPSHOT", "jar" );
- }
-
- // MRM-1353
- @Test( groups = { "requiresUpload" } )
- public void testBuildNumberOfSnapshotArtifact()
- {
- String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
-
- String path = "src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
- // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
- // upload a snapshot artifact to repository 'releases'
- addArtifact( "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
- assertTextPresent( "Artifact 'archiva:archiva-multiple-artifacts:1.0-SNAPSHOT' was successfully deployed to repository '"
- + snapshotsRepo + "'" );
-
- goToBrowsePage();
- assertBrowsePage();
- assertGroupsPage( "archiva/" );
- assertArtifactsPage( "archiva-multiple-artifacts/" );
- assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
-
-
- addArtifact( "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
- assertTextPresent( "Artifact 'archiva:archiva-multiple-artifacts:1.0-SNAPSHOT' was successfully deployed to repository '"
- + snapshotsRepo + "'" );
-
- goToBrowsePage();
- assertBrowsePage();
- assertGroupsPage( "archiva/" );
- assertArtifactsPage( "archiva-multiple-artifacts/" );
- assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
-
- String firstSnapshotVersion = getText( "//div[@id='tabArea']/table[@class='infoTable']/tbody/tr[6]/td/a[1]" );
- Assert.assertTrue( firstSnapshotVersion.endsWith( "-1" ) );
-
- String secondSnapshotVersion = getText( "//div[@id='tabArea']/table[@class='infoTable']/tbody/tr[6]/td/a[2]" );
- Assert.assertTrue( secondSnapshotVersion.endsWith( "-2" ) );
- }
-
- private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId,
- String artifactInfoArtifactId, String artifactInfoVersion, String artifactInfoPackaging )
- {
- clickLinkWithText( version );
- assertPage( "Apache Archiva \\ Browse Repository" );
- assertTextPresent( artifactInfoRepositoryId );
- assertTextPresent( artifactInfoGroupId );
- assertTextPresent( artifactInfoArtifactId );
- assertTextPresent( artifactInfoVersion );
- assertTextPresent( artifactInfoPackaging );
- }
-
- private void assertArtifactsPage( String artifactId )
- {
- clickLinkWithText( artifactId );
- assertPage( "Apache Archiva \\ Browse Repository" );
- assertTextPresent( "Versions" );
- }
-
- private void assertGroupsPage( String groupId )
- {
- clickLinkWithText( groupId );
- assertPage( "Apache Archiva \\ Browse Repository" );
- assertTextPresent( "Artifacts" );
- }
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractArchivaTest;
-import org.testng.annotations.Test;
-
-/**
- * Test all actions affected with CSRF security issue.
- */
-@Test( groups = { "csrf" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
-public class CSRFSecurityTest
- extends AbstractArchivaTest
-{
- public void testCSRFDeleteRepository()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/admin/deleteRepository.action?repoid=test&method%3AdeleteContents=Delete+Configuration+and+Contents" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testCSRFDeleteArtifact()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/deleteArtifact!doDelete.action?groupId=1&artifactId=1&version=1&repositoryId=snapshots" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testCSRFAddRepositoryGroup()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/admin/addRepositoryGroup.action?repositoryGroup.id=csrfgrp" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testCSRFDeleteRepositoryGroup()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/admin/deleteRepositoryGroup.action?repoGroupId=test&method%3Adelete=Confirm" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testCSRFDisableProxyConnector()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/admin/disableProxyConnector!disable.action?target=maven2-repository.dev.java.net&source=internal" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testCSRFDeleteProxyConnector()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/admin/deleteProxyConnector!delete.action?target=maven2-repository.dev.java.net&source=snapshots" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testCSRFDeleteLegacyArtifactPath()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/admin/deleteLegacyArtifactPath.action?path=jaxen%2Fjars%2Fjaxen-1.0-FCS-full.jar" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testCSRFSaveNetworkProxy()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/admin/saveNetworkProxy.action?mode=add&proxy.id=ntwrk&proxy.protocol=http&" +
- "proxy.host=test&proxy.port=8080&proxy.username=&proxy.password=" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testCSRFDeleteNetworkProxy()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/admin/deleteNetworkProxy!delete.action?proxyid=myproxy" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testCSRFAddFileTypePattern()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/admin/repositoryScanning!addFiletypePattern.action?pattern=**%2F*.rum&fileTypeId=artifacts" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testCSRFRemoveFileTypePattern()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/admin/repositoryScanning!removeFiletypePattern.action?pattern=**%2F*.rum&fileTypeId=artifacts" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testCSRFUpdateKnownConsumers()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/admin/repositoryScanning!updateKnownConsumers.action?enabledKnownContentConsumers=auto-remove&" +
- "enabledKnownContentConsumers=auto-rename&enabledKnownContentConsumers=create-missing-checksums&" +
- "enabledKnownContentConsumers=index-content&enabledKnownContentConsumers=metadata-updater&" +
- "enabledKnownContentConsumers=repository-purge&enabledKnownContentConsumers=update-db-artifact&" +
- "enabledKnownContentConsumers=validate-checksums" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testCSRFUpdateUnprocessedConsumers()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/admin/database!updateUnprocessedConsumers.action?enabledUnprocessedConsumers=update-db-project" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testCSRFUpdateCleanupConsumers()
- {
- getSelenium().open( baseUrl );
- getSelenium().open( baseUrl + "/admin/database!updateCleanupConsumers.action?enabledCleanupConsumers=not-present-remove-db-artifact&" +
- "enabledCleanupConsumers=not-present-remove-db-project&enabledCleanupConsumers=not-present-remove-indexed" );
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
-import org.testng.annotations.Test;
-
-@Test( groups = { "database" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
-public class DatabaseTest
- extends AbstractRepositoryTest
-{
- public void testUpdateCron_NullValue()
- {
- goToDatabasePage();
- setFieldValue( "database_cron" , "");
- clickButtonWithValue( "Update Cron" );
- assertTextPresent( "Invalid cron expression value(s)" );
- assertTextPresent( "You must enter a cron expression." );
- }
-
- @Test (dependsOnMethods = { "testUpdateCron_NullValue" } )
- public void testUpdateCron_InvalidValue()
- {
- setFieldValue( "database_cron" , "asdf" );
- clickButtonWithValue( "Update Cron" );
- assertTextPresent( "Invalid cron expression value(s)" );
- }
-
- @Test (dependsOnMethods = { "testUpdateCron_InvalidValue" } )
- public void testUpdateCron_ValidValue()
- {
- setFieldValue( "database_cron" , "0 0 * * * ?" );
- clickButtonWithValue( "Update Cron" );
- assertPage( "Apache Archiva \\ Administration - Database" );
- }
-
- @Test (dependsOnMethods = { "testUpdateCron_ValidValue" } )
- public void testUpdateConsumersUnprocessedArtifactsScanning_UnsetAll()
- {
- getSelenium().uncheck( "enabledUnprocessedConsumers" );
- clickSubmitWithLocator( "//input[@id='database_0' and @value='Update Consumers']" );
-
- assertPage( "Apache Archiva \\ Administration - Database" );
- }
-
- @Test (dependsOnMethods = { "testUpdateConsumersUnprocessedArtifactsScanning_UnsetAll" } )
- public void testUpdateConsumersUnprocessedArtifactsScanning()
- {
- checkField( "enabledUnprocessedConsumers" );
- clickSubmitWithLocator( "//input[@id='database_0' and @value='Update Consumers']" );
- assertPage( "Apache Archiva \\ Administration - Database" );
- }
-
- @Test (dependsOnMethods = { "testUpdateConsumersUnprocessedArtifactsScanning" } )
- public void testUpdateConsumersArtifactCleanupScanning_UnsetAll()
- {
- getSelenium().uncheck( "enabledCleanupConsumers" );
- getSelenium().uncheck( "//input[@name='enabledCleanupConsumers' and @value='not-present-remove-db-project']" );
- getSelenium().uncheck( "//input[@name='enabledCleanupConsumers' and @value='not-present-remove-indexed']" );
- clickSubmitWithLocator( "//form[@id='database']/table/tbody/tr[5]/td/input" );
- assertPage( "Apache Archiva \\ Administration - Database" );
- }
-
- @Test (dependsOnMethods = { "testUpdateConsumersArtifactCleanupScanning_UnsetAll" } )
- public void testUpdateConsumersArtifactCleanupScanning()
- {
- checkField( "enabledCleanupConsumers" );
- clickSubmitWithLocator( "//form[@id='database']/table/tbody/tr[5]/td/input" );
- assertPage( "Apache Archiva \\ Administration - Database" );
- }
-
- @Test (dependsOnMethods = { "testUpdateConsumersArtifactCleanupScanning" } )
- public void testUpdateDatabaseNow()
- {
- clickButtonWithValue( "Update Database Now" );
- assertPage( "Apache Archiva \\ Administration - Database" );
- }
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractArchivaTest;
-import org.testng.annotations.Test;
-
-@Test( groups = { "findartifact" }, sequential = true )
-public class FindArtifactTest
- extends AbstractArchivaTest
-{
- public void testFindArtifactNullValues()
- {
- goToFindArtifactPage();
- clickButtonWithValue( "Search" );
- assertTextPresent( "You must select a file, or enter the checksum. If the file was given and you receive this message, there may have been an error generating the checksum." );
- }
-
- public void testFindArtifactUsingChecksum()
- {
- goToFindArtifactPage();
- setFieldValue( "checksumSearch_q" , "8e896baea663a45d7bd2737f8e464481" );
- clickButtonWithValue( "Search" );
- assertTextPresent( "No results found" );
- }
-
- // TODO: test using file upload on Firefox versions that support getAsBinary (ie, no applet)
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractArtifactManagementTest;
-import org.testng.annotations.Test;
-
-@Test( groups = { "legacysupport" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
-public class LegacySupportTest
- extends AbstractArtifactManagementTest
-{
- public void testAddLegacyArtifact_NullValues()
- {
- goToLegacySupportPage();
- clickLinkWithText( "Add" );
- addLegacyArtifactPath( "" , "" , "" , "" , "" , "");
- assertTextPresent( "You must enter a legacy path." );
- assertTextPresent( "You must enter a groupId." );
- assertTextPresent( "You must enter an artifactId." );
- assertTextPresent( "You must enter a version." );
- assertTextPresent( "You must enter a type." );
- }
-
- @Test( dependsOnMethods = { "testAddLegacyArtifact_NullValues" })
- public void testAddLegacyArtifact_NullLegacyPath()
- {
- addLegacyArtifactPath( "" , "test" , "test" , "1.0-SNAPSHOT" , "testing" , "jar");
- assertTextPresent( "You must enter a legacy path." );
- }
-
- @Test( dependsOnMethods = { "testAddLegacyArtifact_NullLegacyPath" })
- public void testAddLegacyArtifact_NullGroupId()
- {
- addLegacyArtifactPath( "test" , "" , "test" , "1.0-SNAPSHOT" , "testing" , "jar");
- assertTextPresent( "You must enter a groupId." );
- }
-
- @Test( dependsOnMethods = { "testAddLegacyArtifact_NullGroupId" })
- public void testAddLegacyArtifact_NullArtifactId()
- {
- addLegacyArtifactPath( "test" , "test" , "" , "1.0-SNAPSHOT" , "testing" , "jar");
- assertTextPresent( "You must enter an artifactId." );
- }
-
- @Test( dependsOnMethods = { "testAddLegacyArtifact_NullArtifactId" })
- public void testAddLegacyArtifact_NullVersion()
- {
- addLegacyArtifactPath( "test" , "test" , "test" , "" , "testing" , "jar");
- assertTextPresent( "You must enter a version." );
- }
-
- @Test( dependsOnMethods = { "testAddLegacyArtifact_NullVersion" })
- public void testAddLegacyArtifact_NullType()
- {
- addLegacyArtifactPath( "test" , "test" , "test" , "1.0-SNAPSHOT" , "testing" , "");
- assertTextPresent( "You must enter a type." );
- }
-
- @Test( dependsOnMethods = { "testAddLegacyArtifact_NullType" })
- public void testAddLegacyArtifact_InvalidValues()
- {
- addLegacyArtifactPath( "<> ~+[ ]'\"" , "<> \\/~+[ ]'\"" , "<> \\/~+[ ]'\"" , "<> \\/~+[ ]'\"" , "<> \\/~+[ ]'\"" , "<> \\/~+[ ]'\"");
- assertTextPresent( "Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- }
-
- @Test( dependsOnMethods = { "testAddLegacyArtifact_InvalidValues" })
- public void testAddLegacyArtifact_InvalidLegacyPath()
- {
- addLegacyArtifactPath( "<> ~+[ ]'\"" , "test" , "test" , "1.0-SNAPSHOT" , "testing" , "jar");
- assertTextPresent( "Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
- }
-
- @Test( dependsOnMethods = { "testAddLegacyArtifact_InvalidLegacyPath" })
- public void testAddLegacyArtifact_InvalidGroupId()
- {
- addLegacyArtifactPath( "test" , "<> \\/~+[ ]'\"" , "test" , "1.0-SNAPSHOT" , "testing" , "jar");
- assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- }
-
- @Test( dependsOnMethods = { "testAddLegacyArtifact_InvalidGroupId" })
- public void testAddLegacyArtifact_InvalidArtifactId()
- {
- addLegacyArtifactPath( "test" , "test" , "<> \\/~+[ ]'\"" , "1.0-SNAPSHOT" , "testing" , "jar");
- assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- }
-
- @Test( dependsOnMethods = { "testAddLegacyArtifact_InvalidArtifactId" })
- public void testAddLegacyArtifact_InvalidVersion()
- {
- addLegacyArtifactPath( "test" , "test" , "test" , "<> \\/~+[ ]'\"" , "testing" , "jar");
- assertTextPresent( "Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- }
-
- @Test( dependsOnMethods = { "testAddLegacyArtifact_InvalidVersion" })
- public void testAddLegacyArtifact_InvalidType()
- {
- addLegacyArtifactPath( "test" , "test" , "test" , "1.0-SNAPSHOT" , "testing" , "<> \\/~+[ ]'\"");
- assertTextPresent( "Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- }
-
- @Test( dependsOnMethods = { "testAddLegacyArtifact_InvalidType" })
- public void testAddLegacyArtifact_InvalidClassifier()
- {
- addLegacyArtifactPath( "test" , "test" , "test" , "1.0-SNAPSHOT" , "<> \\/~+[ ]'\"" , "jar");
- assertTextPresent( "Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- }
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractArchivaTest;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-/*
- * Bug in TestNG. TESTNG-285: @Test(sequential=true) works incorrectly for classes with inheritance
- * http://code.google.com/p/testng/source/browse/trunk/CHANGES.txt
- * Waiting 5.9 release. It's comming soon.
- */
-/**
- * Based on LoginTest of Emmanuel Venisse test.
- *
- * @author José Morales Martínez
- * @version $Id$
- */
-
-@Test ( groups = { "login" } )
-public class LoginTest
- extends AbstractArchivaTest
-{
- public void testWithBadUsername()
- {
- goToLoginPage();
- getSelenium().type( "loginForm_username", "badUsername" );
- getSelenium().click( "loginForm__login" );
- getSelenium().waitForPageToLoad( maxWaitTimeInMs );
- assertTextPresent( "You have entered an incorrect username and/or password" );
- }
-
- @Test( dependsOnMethods = { "testWithBadUsername" }, alwaysRun = true )
- public void testWithBadPassword()
- {
- goToLoginPage();
- getSelenium().type( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
- getSelenium().type( "loginForm_password", "badPassword" );
- getSelenium().click( "loginForm__login" );
- getSelenium().waitForPageToLoad( maxWaitTimeInMs );
- assertTextPresent( "You have entered an incorrect username and/or password" );
- }
-
- @Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true )
- public void testWithEmptyUsername()
- {
- goToLoginPage();
- getSelenium().type( "loginForm_password", "password" );
- getSelenium().click( "loginForm__login" );
- getSelenium().waitForPageToLoad( maxWaitTimeInMs );
- assertTextPresent( "User Name is required" );
- }
-
- @Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true )
- public void testWithEmptyPassword()
- {
- goToLoginPage();
- getSelenium().type( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
- getSelenium().click( "loginForm__login" );
- getSelenium().waitForPageToLoad( maxWaitTimeInMs );
- assertTextPresent( "You have entered an incorrect username and/or password" );
- }
-
- @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun = true )
- public void testWithCorrectUsernamePassword()
- {
- goToLoginPage();
- getSelenium().type( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
- getSelenium().type( "loginForm_password", getProperty( "ADMIN_PASSWORD" ) );
- getSelenium().click( "loginForm__login" );
- getSelenium().waitForPageToLoad( maxWaitTimeInMs );
- assertTextPresent( "Edit Details" );
- assertTextPresent( "Logout" );
- assertTextPresent( getProperty( "ADMIN_USERNAME" ) );
- }
-
- @BeforeTest
- public void open()
- throws Exception
- {
- super.open();
- }
-
- @Override
- @AfterTest
- public void close()
- throws Exception
- {
- super.close();
- }
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
-import org.testng.annotations.Test;
-
-@Test( groups = { "networkproxies" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
-public class NetworkProxiesTest
- extends AbstractRepositoryTest
-{
- @Test (dependsOnMethods = { "testDeleteRepositoryGroup" } )
- public void testAddNetworkProxyNullValues()
- {
- goToNetworkProxiesPage();
- addNetworkProxy( "", "", "", "", "", "");
- assertTextPresent( "You must enter an identifier." );
- assertTextPresent( "You must enter a protocol." );
- assertTextPresent( "You must enter a host." );
- }
-
- @Test (dependsOnMethods = { "testAddNetworkProxyNullValues" } )
- public void testAddNetworkProxyNullIdentifier()
- {
- goToNetworkProxiesPage();
- addNetworkProxy( "", "http", "localhost", "8080", "", "");
- assertTextPresent( "You must enter an identifier." );
- }
-
- @Test (dependsOnMethods = { "testAddNetworkProxyNullIdentifier" } )
- public void testAddNetworkProxyNullProtocol()
- {
- goToNetworkProxiesPage();
- addNetworkProxy( "testing123", "", "localhost", "8080", "", "");
- assertTextPresent( "You must enter a protocol." );
- }
-
- @Test (dependsOnMethods = { "testAddNetworkProxyNullProtocol" } )
- public void testAddNetworkProxiesNullHostname()
- {
- goToNetworkProxiesPage();
- addNetworkProxy( "testing123", "http", "", "8080", "", "");
- assertTextPresent( "You must enter a host." );
- }
-
- @Test (dependsOnMethods = { "testAddNetworkProxiesNullHostname" } )
- public void testAddNetworkProxiesInvalidValues()
- {
- goToNetworkProxiesPage();
- addNetworkProxy( "<> \\/~+[ ]'\"", "<> ~+[ ]'\"", "<> ~+[ ]'\"", "0", "<> ~+[ ]'\"", "");
- assertTextPresent( "Proxy id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Protocol must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), dots(.), colons(:), and dashes(-)." );
- assertTextPresent( "Host must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
- assertTextPresent( "Port needs to be larger than 1" );
- assertTextPresent( "Username must only contain alphanumeric characters, at's(@), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
- }
-
- @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidValues" } )
- public void testAddNetworkProxiesInvalidIdentifier()
- {
- goToNetworkProxiesPage();
- addNetworkProxy( "<> \\/~+[ ]'\"", "http", "localhost", "8080", "", "");
- assertTextPresent( "Proxy id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- }
-
- @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidIdentifier" } )
- public void testAddNetworkProxiesInvalidProtocol()
- {
- goToNetworkProxiesPage();
- addNetworkProxy( "testing123", "<> ~+[ ]'\"", "localhost", "8080", "", "");
- assertTextPresent( "Protocol must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), dots(.), colons(:), and dashes(-)." );
- }
-
- @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidProtocol" } )
- public void testAddNetworkProxiesInvalidHostname()
- {
- goToNetworkProxiesPage();
- addNetworkProxy( "testing123", "http", "<> ~+[ ]'\"", "8080", "", "");
- assertTextPresent( "Host must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
- }
-
- @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidHostname" } )
- public void testAddNetworkProxiesInvalidPort()
- {
- goToNetworkProxiesPage();
- addNetworkProxy( "testing123", "http", "localhost", "0", "", "");
- assertTextPresent( "Port needs to be larger than 1" );
- }
-
- @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidPort" } )
- public void testAddNetworkProxiesInvalidUsername()
- {
- goToNetworkProxiesPage();
- addNetworkProxy( "testing123", "http", "localhost", "8080", "<> ~+[ ]'\"", "");
- assertTextPresent( "Username must only contain alphanumeric characters, at's(@), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
- }
-
- @Test (dependsOnMethods = { "testAddNetworkProxiesInvalidUsername" } )
- public void testAddNetworkProxiesValidValues()
- {
- goToNetworkProxiesPage();
- addNetworkProxy( "testing123", "http", "localhost", "8080", "", "");
- assertPage( "Apache Archiva \\ Administration - Network Proxies" );
- assertTextPresent( "testing123" );
- }
-
- @Test (dependsOnMethods = { "testAddNetworkProxiesValidValues" } )
- public void testEditNetworkProxy()
- {
- editNetworkProxies( "proxy.host", "localhost" );
- assertPage( "Apache Archiva \\ Administration - Network Proxies" );
- assertTextPresent( "localhost" );
- }
-
- @Test (dependsOnMethods = { "testEditNetworkProxy" } )
- public void testDeleteNetworkProxy()
- {
- deleteNetworkProxy();
- assertPage( "Apache Archiva \\ Administration - Network Proxies" );
- assertTextPresent( "There are no network proxies configured yet." );
- }
-
- @Test (dependsOnMethods = { "testDeleteNetworkProxy" } )
- public void testAddNetworkProxyAfterDelete()
- {
- addNetworkProxy( "testing123", "http", "localhost", "8080", "", "");
- assertPage( "Apache Archiva \\ Administration - Network Proxies" );
- assertTextPresent( "testing123" );
- }
-
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractArtifactReportsTest;
-import org.testng.annotations.Test;
-
-@Test( groups = { "reports" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
-public class ReportsTest
- extends AbstractArtifactReportsTest
-{
- //TODO Tests for repository with defects
-
- public void testRepoStatisticsWithoutRepoCompared()
- {
- goToReportsPage();
- clickButtonWithValue( "View Statistics" );
- assertTextPresent( "Please select a repository (or repositories) from the list." );
- }
-
- @Test(dependsOnMethods = { "testRepoStatisticsWithoutRepoCompared" } )
- public void testRepositoryStatisticsWithoutDate()
- {
- String repositoryName = getProperty( "REPOSITORY_NAME" ) ;
- compareRepositories( "label=" + repositoryName, "", "" );
- //TODO
- //assertTextPresent( "Statistics Report" );
- }
-
- @Test(dependsOnMethods = { "testRepoStatisticsWithoutRepoCompared" } )
- public void testRepositoryStatisticsEndEarlierThanStart()
- {
- String repositoryName = getProperty( "REPOSITORY_NAME" ) ;
- String startDate = getProperty( "END_DATE" );
- String endDate = getProperty( "START_DATE" );
- compareRepositories( "label=" + repositoryName, startDate, endDate );
- //assertTextPresent( "Statistics for Repository '" + repositoryName + "'" );
- assertPage( "Apache Archiva \\ Reports" );
- assertTextPresent( "Start Date must be earlier than the End Date" );
- }
-
- public void testRepositoryStatistics()
- {
- String repositoryName = getProperty( "REPOSITORY_NAME" ) ;
- String startDate = getProperty( "START_DATE" );
- String endDate = getProperty( "END_DATE" );
- compareRepositories( "label=" + repositoryName, startDate, endDate );
- //assertTextPresent( "Statistics for Repository '" + repositoryName + "'" );
- //assertPage( "Apache Archiva \\ Reports" );
- //assertTextPresent( "Statistics Report" );
- }
-
- /* @Test( dependsOnMethods = { "testRepositoryStatistics" } )
- public void testRepositoriesStatisticComparisonReport()
- {
- //goToReportsPage();
- clickButtonWithValue( "-->>" , false );
- clickButtonWithValue( "View Statistics" );
- assertTextPresent( "Statistics Report" );
- }
-
- public void testRepositoryHealthWithoutDefect()
- {
- goToReportsPage();
- String groupId = getProperty( "ARTIFACT_GROUPID" );
- getSelenium().type( "generateReport_groupId" , groupId );
- clickButtonWithValue( "Show Report" );
- assertPage( "Apache Archiva \\ Reports" );
- assertTextPresent( "The operation generated an empty report." );
- }
-
- public void testRepositoryHealthWithoutGroupId()
- {
- goToReportsPage();
- clickButtonWithValue( "Show Report" );
- assertPage( "Apache Archiva \\ Reports" );
- assertTextPresent( "The operation generated an empty report." );
-
- //TODO As of the creation of the tests, GroupId is not a required field in showing the reports of repository health. GroupId should be required I think.
- }*/
-
-
-
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
-import org.testng.annotations.Test;
-import org.testng.Assert;
-
-@Test( groups = { "reposcan" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
-public class RepositoryScanningTest
- extends AbstractRepositoryTest
-{
- public void testAddArtifactFileType_NullValue()
- {
- goToRepositoryScanningPage();
- clickAddIcon( "newpattern_0" );
- assertTextPresent( "Unable to process blank pattern." );
- }
-
- @Test (dependsOnMethods = { "testAddArtifactFileType_NullValue" } )
- public void testAddArtifactFileType()
- {
- setFieldValue( "newpattern_0" , "**/*.dll" );
- clickAddIcon( "newpattern_0" );
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "**/*.dll" );
- }
-
- @Test (dependsOnMethods = { "testAddArtifactFileType" } )
- public void testAddArtifactFileType_ExistingValue()
- {
- setFieldValue( "newpattern_0" , "**/*.zip" );
- clickAddIcon( "newpattern_0" );
- Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.zip\" to filetype artifacts as it already exists." );
- }
-
- @Test (dependsOnMethods = { "testAddArtifactFileType_ExistingValue" } )
- public void testDeleteArtifactFileType()
- {
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "**/*.dll" );
- clickDeleteIcon( "**/*.dll" );
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "" );
- }
-
- @Test (dependsOnMethods = { "testDeleteArtifactFileType" } )
- public void testAddAutoRemove_NullValue()
- {
- setFieldValue( "newpattern_1" , "" );
- clickAddIcon( "newpattern_1" );
- assertTextPresent( "Unable to process blank pattern." );
- }
-
- @Test (dependsOnMethods = { "testAddAutoRemove_NullValue" } )
- public void testAddAutoRemove_ExistingValue()
- {
- setFieldValue( "newpattern_1" , "**/*-" );
- clickAddIcon( "newpattern_1" );
- Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." );
- }
-
- @Test (dependsOnMethods = { "testAddAutoRemove_ExistingValue" } )
- public void testAddAutoRemove()
- {
- setFieldValue( "newpattern_1" , "**/*.test" );
- clickAddIcon( "newpattern_1" );
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "**/*.test" );
- }
-
- @Test (dependsOnMethods = { "testAddAutoRemove" } )
- public void testDeleteAutoRemove()
- {
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "**/*.test" );
- clickDeleteIcon( "**/*.test" );
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "" );
- }
-
- @Test (dependsOnMethods = { "testDeleteAutoRemove" } )
- public void testAddIgnoredArtifacts_NullValue()
- {
- setFieldValue( "newpattern_2" , "" );
- clickAddIcon( "newpattern_2" );
- Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." );
- }
-
- @Test (dependsOnMethods = { "testAddIgnoredArtifacts_NullValue" } )
- public void testAddIgnoredArtifacts_ExistingValue()
- {
- setFieldValue( "newpattern_2" , "**/*.sh" );
- clickAddIcon( "newpattern_2" );
- Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." );
- }
-
- @Test (dependsOnMethods = { "testAddIgnoredArtifacts_ExistingValue" } )
- public void testAddIgnoredArtifacts()
- {
- setFieldValue( "newpattern_2" , "**/*.log" );
- clickAddIcon( "newpattern_2" );
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "**/*.log" );
- }
-
- @Test (dependsOnMethods = { "testAddIgnoredArtifacts" } )
- public void testDeleteIgnoredArtifacts()
- {
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "**/*.log" );
- clickDeleteIcon( "**/*.log" );
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "" );
- }
-
- //
- @Test (dependsOnMethods = { "testDeleteIgnoredArtifacts" } )
- public void testAddIndexableContent_NullValue()
- {
- setFieldValue( "newpattern_3" , "" );
- clickAddIcon( "newpattern_3" );
- Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." );
- }
-
- @Test (dependsOnMethods = { "testAddIndexableContent_NullValue" } )
- public void testAddIndexableContent_ExistingValue()
- {
- setFieldValue( "newpattern_3" , "**/*.xml" );
- clickAddIcon( "newpattern_3" );
- Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." );
- }
-
- @Test (dependsOnMethods = { "testAddIndexableContent_ExistingValue" } )
- public void testAddIndexableContent()
- {
- setFieldValue( "newpattern_3" , "**/*.html" );
- clickAddIcon( "newpattern_3" );
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "**/*.html" );
- }
-
- @Test (dependsOnMethods = { "testAddIndexableContent" } )
- public void testDeleteIndexableContent()
- {
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "**/*.html" );
- clickDeleteIcon( "**/*.html" );
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "" );
- }
-
- @Test (dependsOnMethods = { "testDeleteIndexableContent" } )
- public void testUpdateConsumers()
- {
- checkField( "enabledKnownContentConsumers" );
- checkField( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
- clickButtonWithValue( "Update Consumers" );
- assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
- }
-
- @Test (dependsOnMethods = { "testUpdateConsumers" } )
- public void testUpdateConsumers_UnsetAll()
- {
- getSelenium().uncheck( "enabledKnownContentConsumers" );
- getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
- getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='create-missing-checksums']" );
- getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='index-content']" );
- getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='metadata-updater']" );
- getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='repository-purge']" );
- getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='update-db-artifact']" );
- getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='validate-checksums']" );
- clickButtonWithValue( "Update Consumers" );
-
- assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
- }
-
- private void clickAddIcon( String fieldId )
- {
- String xPath = "//preceding::td/input[@id='" + fieldId + "']//following::td/a/img";
- clickLinkWithLocator( xPath );
- }
-
- private void clickDeleteIcon( String pattern )
- {
- String xPath = "//preceding::td/code[contains(text(),'" + pattern + "')]//following::td/a/img";
- clickLinkWithLocator( xPath );
- }
-
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
-import org.testng.annotations.Test;
-
-@Test( groups = { "repository" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
-public class RepositoryTest
- extends AbstractRepositoryTest
-{
- public void testAddManagedRepoValidValues()
- {
- goToRepositoriesPage();
- getSelenium().open( "/archiva/admin/addRepository.action" );
- addManagedRepository( "managedrepo1", "Managed Repository Sample 1" , getRepositoryDir() + "repository/" , "", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
- clickButtonWithValue( "Save" );
- assertTextPresent( "Managed Repository Sample 1" );
- assertRepositoriesPage();
- }
-
- @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } )
- 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(-)." );
- 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." );
- }
-
- @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(-)." );
- }
-
- @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(-)." );
- }
-
- @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(-)." );
- }
-
- @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(-)." );
- }
-
- @Test(dependsOnMethods = { "testAddManagedRepoInvalidIndexDir" } )
- public void testAddManagedRepoInvalidRetentionCount()
- {
- addManagedRepository( "identifier", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "101" );
- 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" );
- assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
- }
-
- @Test(dependsOnMethods = { "testAddManagedRepoInvalidDaysOlder" } )
- public void testAddManagedRepoBlankValues()
- {
- goToRepositoriesPage();
- getSelenium().open( "/archiva/admin/addRepository.action" ); ;
- addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" );
- assertTextPresent( "You must enter a repository identifier." );
- assertTextPresent( "You must enter a repository name." );
- assertTextPresent( "You must enter a directory." );
- assertTextPresent( "Invalid cron expression." );
- }
-
- @Test(dependsOnMethods = { "testAddManagedRepoBlankValues" } )
- public void testAddManagedRepoNoIdentifier()
- {
- addManagedRepository( "", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
- assertTextPresent( "You must enter a repository identifier." );
- }
-
- @Test(dependsOnMethods = { "testAddManagedRepoNoIdentifier" } )
- public void testAddManagedRepoNoRepoName()
- {
- addManagedRepository( "identifier", "" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
- assertTextPresent( "You must enter a repository name." );
- }
-
- @Test(dependsOnMethods = { "testAddManagedRepoNoRepoName" } )
- public void testAddManagedRepoNoDirectory()
- {
- addManagedRepository( "identifier", "name" , "" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
- assertTextPresent( "You must enter a directory." );
- }
-
- @Test(dependsOnMethods = { "testAddManagedRepoNoDirectory" } )
- public void testAddManagedRepoNoCron()
- {
- addManagedRepository( "identifier", "name" , "/home" , "/.index", "Maven 2.x Repository", "", "", "" );
- assertTextPresent( "Invalid cron expression." );
- }
-
- @Test(dependsOnMethods = { "testAddManagedRepoNoCron" } )
- public void testAddManagedRepoForEdit()
- {
- goToRepositoriesPage();
- clickLinkWithText( "Add" );
- addManagedRepository( "managedrepo", "Managed Repository Sample" , getRepositoryDir() + "local-repo/", "", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
- clickButtonWithValue( "Save" );
- assertTextPresent( "Managed Repository Sample" );
- }
-
- @Test(dependsOnMethods = { "testAddManagedRepoForEdit" } )
- 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( "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." );
- }
-
- @Test(dependsOnMethods = { "testEditManagedRepoInvalidValues" } )
- 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(-)." );
- }
-
- @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(-)." );
- }
-
- @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(-)." );
- }
-
- @Test(dependsOnMethods = { "testEditManagedRepoInvalidIndexDir" } )
- public void testEditManagedRepoInvalidCron()
- {
- editManagedRepository("name" , "/home" , "/.index", "Maven 2.x Repository", "", "1", "1");
- assertTextPresent( "Invalid cron expression." );
- }
-
- @Test(dependsOnMethods = { "testEditManagedRepoInvalidCron" } )
- public void testEditManagedRepoInvalidRetentionCount()
- {
- editManagedRepository("name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "101");
- assertTextPresent( "Repository Purge By Retention Count needs to be between 1 and 100." );
- }
-
- @Test(dependsOnMethods = { "testEditManagedRepoInvalidRetentionCount" } )
- public void testEditManagedRepoInvalidDaysOlder()
- {
- editManagedRepository("name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "-1", "1");
- assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
- }
-
- //TODO
- @Test(dependsOnMethods = { "testEditManagedRepoInvalidDaysOlder" } )
- public void testEditManagedRepo()
- {
- editManagedRepository( "repository.name" , "Managed Repo" );
- assertTextPresent( "Managed Repository Sample" );
- }
-
- //TODO
- @Test(dependsOnMethods = { "testEditManagedRepo" } )
- public void testDeleteManageRepo()
- {
- deleteManagedRepository();
- //assertTextNotPresent( "managedrepo" );
- }
-
- @Test(dependsOnMethods = { "testAddRemoteRepoValidValues" } )
- public void testAddRemoteRepoNullValues()
- {
- getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
- addRemoteRepository( "" , "" , "" , "" , "" , "" , "Maven 2.x Repository" );
- assertTextPresent( "You must enter a repository identifier." );
- assertTextPresent( "You must enter a repository name." );
- assertTextPresent( "You must enter a url." );
- }
-
- @Test(dependsOnMethods = { "testAddRemoteRepoNullValues" } )
- public void testAddRemoteRepositoryNullIdentifier()
- {
- addRemoteRepository( "" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
- assertTextPresent( "You must enter a repository identifier." );
- }
-
- @Test(dependsOnMethods = { "testAddRemoteRepositoryNullIdentifier" } )
- public void testAddRemoteRepoNullName()
- {
- addRemoteRepository( "remoterepo" , "" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
- assertTextPresent( "You must enter a repository name." );
- }
-
- @Test(dependsOnMethods = { "testAddRemoteRepoNullName" } )
- public void testAddRemoteRepoNullURL()
- {
- addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "" , "" , "" , "" , "Maven 2.x Repository" );
- assertTextPresent( "You must enter a url." );
- }
-
- @Test(dependsOnMethods = { "testDeleteManageRepo" } )
- public void testAddRemoteRepoValidValues()
- {
- getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
- addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
- assertTextPresent( "Remote Repository Sample" );
- }
-
- // *** BUNDLED REPOSITORY TEST ***
-
- @Test ( dependsOnMethods = { "testWithCorrectUsernamePassword" }, alwaysRun = true )
- public void testBundledRepository()
- {
- String repo1 = baseUrl + "repository/internal/";
- String repo2 = baseUrl + "repository/snapshots/";
-
- assertRepositoryAccess( repo1 );
- assertRepositoryAccess( repo2 );
-
- getSelenium().open( "/archiva" );
- }
-
- private void assertRepositoryAccess( String repo )
- {
- getSelenium().open( "/archiva" );
- goToRepositoriesPage();
- assertLinkPresent( repo );
- clickLinkWithText( repo );
- assertPage( "Collection: /" );
- assertTextPresent( "Collection: /" );
- }
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-import org.apache.archiva.web.test.parent.AbstractSearchTest;
-import org.testng.annotations.Test;
-
-@Test( groups = { "search" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
-public class SearchTest
- extends AbstractSearchTest
-{
-
- public void testSearchNonExistingArtifact()
- throws Exception
- {
- searchForArtifact( getProperty( "SEARCH_BAD_ARTIFACT" ) );
- assertTextPresent( "No results found" );
- }
-
- public void testSearchExistingArtifact()
- {
- searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
- assertTextPresent( "Results" );
- assertTextPresent( "Hits: 1 to 1 of 1" );
- assertLinkPresent( "test" );
- }
-
- public void testViewSearchedArtifact()
- {
- searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
- clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) );
- assertPage( "Apache Archiva \\ Browse Repository" );
- assertTextPresent( getProperty( "ARTIFACT_ARTIFACTID" ) );
- clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
- assertPage( "Apache Archiva \\ Browse Repository" );
- }
-
- public void testSearchNonExistingArtifactInAdvancedSearch()
- {
- searchForArtifactAdvancedSearch( null, getProperty( "SEARCH_BAD_ARTIFACT"), null, null, null, null );
- assertTextPresent( "No results found" );
- }
-
- public void testSearchNoSearchCriteriaSpecifiedInAdvancedSearch()
- {
- searchForArtifactAdvancedSearch( null, null, null, null, null, null );
- assertTextPresent( "Advanced Search - At least one search criteria must be provided." );
- }
-
- public void testSearchExistingArtifactUsingAdvancedSearchArtifactId()
- {
- searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, getProperty( "REPOSITORYID" ), null, null );
- assertTextPresent( "Results" );
- assertTextPresent( "Hits: 1 to 1 of 1" );
- assertLinkPresent( "test" );
- }
-
- public void testSearchExistingArtifactUsingAdvancedSearchGroupId()
- {
- searchForArtifactAdvancedSearch( getProperty( "GROUPID" ), null, null, getProperty( "REPOSITORYID" ), null, null );
- assertTextPresent( "Results" );
- assertTextPresent( "Hits: 1 to 1 of 1" );
- assertLinkPresent( "test" );
- }
-
- public void testSearchExistingArtifactUsingAdvancedSearchNotInRepository()
- {
- searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, "snapshots", null, null );
- assertTextPresent( "No results found" );
- assertTextNotPresent( "Results" );
- assertTextNotPresent( "Hits: 1 to 1 of 1" );
- assertLinkNotPresent( "test" );
- }
-}
-
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractArchivaTest;
-import org.testng.annotations.Test;
-
-@Test( groups = { "userroles" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
-public class UserRolesTest
- extends AbstractArchivaTest
-{
-
- public void testBasicAddDeleteUser()
- {
- username = getProperty( "GUEST_USERNAME" );
- fullname = getProperty( "GUEST_FULLNAME" );
-
- createUser( username, fullname, getUserEmail(), getUserRolePassword(), true);
- deleteUser( username, fullname, getUserEmail() );
- logout();
- login( getAdminUsername() , getAdminPassword() );
- }
-
- @Test (dependsOnMethods = { "testBasicAddDeleteUser" } )
- public void testUserWithGuestRole()
- {
- username = getProperty("GUEST_USERNAME");
- fullname = getProperty("GUEST_FULLNAME");
-
- createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
- clickLinkWithText( username );
- clickLinkWithText( "Edit Roles" );
- checkUserRoleWithValue( fullname );
- clickButtonWithValue( "Submit" );
-
- logout();
- login(username, getUserRolePassword());
- changePassword( getUserRolePassword(), getUserRoleNewPassword());
-
- // this section will be removed if issue from redback after changing password will be fixed.
- getSelenium().goBack();
- logout();
- //assertTextPresent("You are already logged in.");
-
- login(username, getUserRoleNewPassword());
- assertLeftNavMenuWithRole( fullname );
- logout();
- login( getAdminUsername() , getAdminPassword() );
- }
-
- @Test (dependsOnMethods = { "testUserWithGuestRole" } )
- public void testUserWithRegisteredUserRole()
- {
- username = getProperty("REGISTERED_USERNAME");
- fullname = getProperty("REGISTERED_FULLNAME");
-
- createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
- clickLinkWithText( username );
- clickLinkWithText( "Edit Roles" );
- checkUserRoleWithValue( fullname );
- clickButtonWithValue( "Submit" );
-
- logout();
- login(username, getUserRolePassword());
- changePassword( getUserRolePassword(), getUserRoleNewPassword());
-
- // this section will be removed if issue from redback after changing password will be fixed.
- getSelenium().goBack();
- logout();
- //assertTextPresent("You are already logged in.");
-
- login(username, getUserRoleNewPassword());
- assertLeftNavMenuWithRole( fullname );
- logout();
- login( getAdminUsername() , getAdminPassword() );
- }
-
- @Test (dependsOnMethods = { "testUserWithRegisteredUserRole" } )
- public void testUserWithSysAdminUserRole()
- {
- username = getProperty("SYSAD_USERNAME");
- fullname = getProperty("SYSAD_FULLNAME");
-
- createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
- clickLinkWithText( username );
- clickLinkWithText( "Edit Roles" );
- checkUserRoleWithValue( fullname );
- clickButtonWithValue( "Submit" );
-
- logout();
- login(username, getUserRolePassword());
- changePassword( getUserRolePassword(), getUserRoleNewPassword());
-
- // this section will be removed if issue from redback after changing password will be fixed.
- getSelenium().goBack();
- logout();
- //assertTextPresent("You are already logged in.");
-
- login(username, getUserRoleNewPassword());
- assertLeftNavMenuWithRole( fullname );
- logout();
- login( getAdminUsername() , getAdminPassword() );
- }
-
- @Test (dependsOnMethods = { "testUserWithSysAdminUserRole" } )
- public void testUserWithUserAdminUserRole()
- {
- username = getProperty("USERADMIN_USERNAME");
- fullname = getProperty("USERADMIN_FULLNAME");
-
- createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
- clickLinkWithText( username );
- clickLinkWithText( "Edit Roles" );
- checkUserRoleWithValue( fullname );
- clickButtonWithValue( "Submit" );
-
- logout();
- login(username, getUserRolePassword());
- changePassword( getUserRolePassword(), getUserRoleNewPassword());
-
- // this section will be removed if issue from redback after changing password will be fixed.
- getSelenium().goBack();
- logout();
- //assertTextPresent("You are already logged in.");
-
- login(username, getUserRoleNewPassword());
- assertLeftNavMenuWithRole( fullname );
- logout();
- login( getAdminUsername() , getAdminPassword() );
- }
-
- @Test (dependsOnMethods = { "testUserWithUserAdminUserRole" } )
- public void testUserWithGlobalRepoManagerRole()
- {
- username = getProperty("GLOBALREPOMANAGER_USERNAME");
- fullname = getProperty("GLOBALREPOMANAGER_FULLNAME");
-
- createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
- clickLinkWithText( username );
- clickLinkWithText( "Edit Roles" );
- checkUserRoleWithValue( fullname );
- clickButtonWithValue( "Submit" );
-
- logout();
- login(username, getUserRolePassword());
- changePassword( getUserRolePassword(), getUserRoleNewPassword());
-
- // this section will be removed if issue from redback after changing password will be fixed.
- getSelenium().goBack();
- logout();
- //assertTextPresent("You are already logged in.");
-
- login(username, getUserRoleNewPassword());
- assertLeftNavMenuWithRole( fullname );
- logout();
- login( getAdminUsername() , getAdminPassword() );
- }
-
- @Test (dependsOnMethods = { "testUserWithGlobalRepoManagerRole" } )
- public void testUserWithGlobalRepoObserverRole()
- {
- username = getProperty("GLOBALREPOOBSERVER_USERNAME");
- fullname = getProperty("GLOBALREPOOBSERVER_FULLNAME");
-
- createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
- clickLinkWithText( username );
- clickLinkWithText( "Edit Roles" );
- checkUserRoleWithValue( fullname );
- clickButtonWithValue( "Submit" );
-
- logout();
- login(username, getUserRolePassword());
- changePassword( getUserRolePassword(), getUserRoleNewPassword());
-
- // this section will be removed if issue from redback after changing password will be fixed.
- getSelenium().goBack();
- logout();
- //assertTextPresent("You are already logged in.");
-
- login(username, getUserRoleNewPassword());
- assertLeftNavMenuWithRole( fullname );
- logout();
- login( getAdminUsername() , getAdminPassword() );
- }
-
- @Test (dependsOnMethods = { "testUserWithGlobalRepoObserverRole" } )
- public void testUserWithRepoManagerInternalRole()
- {
- username = getProperty("REPOMANAGER_INTERNAL_USERNAME");
- fullname = getProperty("REPOMANAGER_INTERNAL_FULLNAME");
-
- createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
- clickLinkWithText( username );
- clickLinkWithText( "Edit Roles" );
- checkResourceRoleWithValue( fullname );
- clickButtonWithValue( "Submit" );
-
- logout();
- login(username, getUserRolePassword());
- changePassword( getUserRolePassword(), getUserRoleNewPassword());
-
- // this section will be removed if issue from redback after changing password will be fixed.
- getSelenium().goBack();
- logout();
- //assertTextPresent("You are already logged in.");
-
- login(username, getUserRoleNewPassword());
- assertLeftNavMenuWithRole( fullname );
- logout();
- login( getAdminUsername() , getAdminPassword() );
- }
-
- /*@Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
- public void testUserWithRepoManagerSnapshotsRole()
- {
- username = getProperty("REPOMANAGER_SNAPSHOTS_USERNAME");
- fullname = getProperty("REPOMANAGER_SNAPSHOTS_FULLNAME");
-
- createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
- clickLinkWithText( username );
- clickLinkWithText( "Edit Roles" );
- checkResourceRoleWithValue( fullname );
- clickButtonWithValue( "Submit" );
-
- clickLinkWithText("Logout");
- login(username, getUserRolePassword());
- changePassword( getUserRolePassword(), getUserRoleNewPassword());
-
- // this section will be removed if issue from redback after changing password will be fixed.
- getSelenium().goBack();
- clickLinkWithText("Logout");
- //assertTextPresent("You are already logged in.");
-
- login(username, getUserRoleNewPassword());
- assertLeftNavMenuWithRole( fullname );
- clickLinkWithText("Logout");
- login( getAdminUsername() , getAdminPassword() );
- }*/
-
- @Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
- public void testUserWithRepoObserverInternalRole()
- {
- username = getProperty( "REPOOBSERVER_INTERNAL_USERNAME" );
- fullname = getProperty( "REPOOBSERVER_INTERNAL_FULLNAME" );
-
- createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
- clickLinkWithText( username );
- clickLinkWithText( "Edit Roles" );
- checkResourceRoleWithValue( fullname );
- clickButtonWithValue( "Submit" );
-
- logout();
- login(username, getUserRolePassword());
- changePassword( getUserRolePassword(), getUserRoleNewPassword());
-
- // this section will be removed if issue from redback after changing password will be fixed.
- getSelenium().goBack();
- logout();
- //assertTextPresent("You are already logged in.");
-
- login(username, getUserRoleNewPassword());
- assertLeftNavMenuWithRole( fullname );
- logout();
- login( getAdminUsername() , getAdminPassword() );
- }
-
- /*@Test (dependsOnMethods = { "testUserWithRepoObserverInternalRole" } )
- public void testUserWithRepoObserverSnapshotsRole()
- {
- username = getProperty( "REPOOBSERVER_SNAPSHOTS_USERNAME" );
- fullname = getProperty( "REPOOBSERVER_SNAPSHOTS_FULLNAME" );
-
- createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
- clickLinkWithText( username );
- clickLinkWithText( "Edit Roles" );
- checkResourceRoleWithValue( fullname );
- clickButtonWithValue( "Submit" );
-
- clickLinkWithText("Logout");
- login(username, getUserRolePassword());
- changePassword( getUserRolePassword(), getUserRoleNewPassword());
-
- // this section will be removed if issue from redback after changing password will be fixed.
- getSelenium().goBack();
- clickLinkWithText("Logout");
- //assertTextPresent("You are already logged in.");
-
- login(username, getUserRoleNewPassword());
- assertLeftNavMenuWithRole( fullname );
- clickLinkWithText("Logout");
- login( getAdminUsername() , getAdminPassword() );
- }*/
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
-import org.testng.annotations.Test;
-import org.testng.Assert;
-
-@Test( groups = { "virtualrepository" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
-public class VirtualRepositoryTest
- extends AbstractRepositoryTest
-{
- public void testAddRepositoryGroupNullValue()
- {
- addRepositoryGroup( " " );
- assertTextPresent( "Identifier field is required." );
- }
-
- @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
- public void testAddRepositoryGroupValidValue()
- {
- addRepositoryGroup( "testing" );
- //assertAddedRepositoryLink( "testing" );
- Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[1]/p[1]" ), "testing" );
- }
-
- @Test(dependsOnMethods = { "testAddRepositoryGroupValidValue" } )
- public void testAddRepositoryToRepositoryGroup()
- {
- addRepositoryToRepositoryGroup( "testing", "internal" );
- Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[3]/div[2]/p[1]" ), "internal" );
- //clickLinkWithXPath( "/html/body/div[4]/div/div/div[2]/div/div/p[2]/a" );
- //getSelenium().goBack();
- }
-
- @Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } )
- public void testDeleteRepositoryOfRepositoryGroup()
- {
- goToRepositoryGroupsPage();
- deleteRepositoryInRepositoryGroups();
- assertTextPresent( "Repository Groups" );
- assertTextNotPresent( "No Repository Groups Defined." );
- Assert.assertFalse( getSelenium().isElementPresent( "//div[@id='contentArea']/div[2]/div/div[3]/div[2]/p[1]" ) );
- }
-
- @Test(dependsOnMethods = { "testDeleteRepositoryOfRepositoryGroup" } )
- public void testDeleteRepositoryGroup()
- {
- assertRepositoryGroupsPage();
- deleteRepositoryGroup( "testing" );
- assertTextPresent( "No Repository Groups Defined." );
- }
-
- /*@Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } )
- public void testCheckRepositoryGroup()
- {
- clickLinkWithXPath( "/html/body/div[4]/div/div/div[2]/div/div/p[2]/a" );
- getSelenium().goBack();
- }*/
-}
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Utility class for creating xpath expressions
- */
-public class XPathExpressionUtil
-{
- public static final String CONTAINS = "contains";
-
- public static final String AND = " and ";
-
- public static final String CURRENT_NODE = "./";
-
- public static final String PARENT_NODE = "../";
-
- public static final String GRANDPARENT_NODE = "../../";
-
- public static final String ELEMENT_ANY_LEVEL = "//";
-
- public static final String TABLE_COLUMN = "td";
-
- public static final String TABLE_ROW = "tr";
-
- public static final String START_NODE_TEST = "[";
-
- public static final String END_NODE_TEST = "]";
-
- public static final String ANCHOR = "a";
-
- public static final String IMG = "img";
-
- public static final String LIST = "ul";
-
- public static final String LINE = "li";
-
- public static String getList( String[] values )
- {
- String xpathExpression = "";
-
- if ( values.length > 0 )
- {
- xpathExpression += ELEMENT_ANY_LEVEL;
- xpathExpression += LIST;
- xpathExpression += START_NODE_TEST;
-
- for (int nIndex = 0; nIndex < values.length; nIndex++ )
- {
- xpathExpression += ( ( nIndex > 0 ) ? AND : "" );
- xpathExpression += contains( LINE + position( nIndex + 1 ), values[nIndex] );
- }
-
- xpathExpression += END_NODE_TEST;
- }
-
- return xpathExpression;
- }
-
- /**
- * expression for acquiring an element in one of the table columns
- *
- * @param element the node element
- * @param elementIndex column index of the element, used for skipping
- * @param columnValues the values to be matched in each column, element column is included
- * @return
- */
- public static String getColumnElement( String element, int elementIndex, String[] columnValues )
- {
- return getColumnElement( element, elementIndex, null, columnValues );
- }
-
- /**
- * expression for acquiring an element in one of the table columns
- *
- * @param element the node element
- * @param elementIndex column index of the element, used for skipping
- * @param elementValue the matched element value
- * @param columnValues the values to be matched in each column, element column is included
- * @return
- */
- public static String getColumnElement( String element, int elementIndex, String elementValue,
- String[] columnValues )
- {
- return getColumnElement( element, elementIndex, elementValue, "TEXT", columnValues );
- }
-
- /**
- * expression for acquiring an element in one of the table columns
- *
- * @param element the node element
- * @param elementIndex column index of the element, used for skipping
- * @param imageName the matched image name
- * @param columnValues the values to be matched in each column, element column is included
- * @return
- */
- public static String getImgColumnElement( String element, int elementIndex, String imageName,
- String[] columnValues )
- {
- return getColumnElement( element, elementIndex, imageName, IMG, columnValues );
- }
-
- /**
- * expression for acquiring an element in one of the table columns
- *
- * @param element the node element
- * @param elementIndex column index of the element, used for skipping
- * @param imageName the matched image name
- * @param columnValues the values to be matched in each column, element column is included
- * @return
- */
- private static String getColumnElement( String element, int elementIndex, String elementValue,
- String elementValueType, String[] columnValues )
- {
- String xpathExpression = null;
-
- if ( ( columnValues != null ) && ( columnValues.length > 0 ) )
- {
- xpathExpression = ELEMENT_ANY_LEVEL + element;
- xpathExpression += START_NODE_TEST;
-
- if ( elementValue != null )
- {
- if ( "TEXT".equals( elementValueType ) )
- {
- xpathExpression += contains( elementValue );
- xpathExpression += ( columnValues.length > 0 ) ? AND : "";
- }
- }
-
- // we are two levels below the table row element ( tr/td/<element> )
- xpathExpression += matchColumns( GRANDPARENT_NODE, columnValues, elementIndex );
-
- xpathExpression += END_NODE_TEST;
- }
-
- if ( IMG.equals( elementValueType ) )
- {
- xpathExpression += "/img[contains(@src, '" + elementValue + "')]";
- }
-
- return xpathExpression;
- }
-
- /**
- * expression for acquiring the table row that matches all column values with the same order
- * as the list
- *
- * @param columnValues the matched list of columnValues
- * @return
- */
- public static String getTableRow( String[] columnValues )
- {
- String xpathExpression = null;
-
- if ( ( columnValues != null ) && ( columnValues.length > 0 ) )
- {
- xpathExpression = new String( ELEMENT_ANY_LEVEL + TABLE_ROW + START_NODE_TEST );
- xpathExpression += matchColumns( columnValues );
- xpathExpression += END_NODE_TEST;
- }
-
- return xpathExpression;
- }
-
- private static String matchColumns( String[] columnValues )
- {
- return matchColumns( columnValues, -1 );
- }
-
- private static String matchColumns( String[] columnValues, int skipIndex )
- {
- return matchColumns( null, columnValues, skipIndex );
- }
-
- private static String matchColumns( String parent, String[] columnValues, int skipIndex )
- {
- String xpathExpression = "";
-
- for ( int nIndex = 0; nIndex < columnValues.length; nIndex++ )
- {
- if ( ( skipIndex != nIndex ) || ( skipIndex == -1 ) )
- {
- // prepend "and" if index > 0
- xpathExpression += ( ( nIndex > 0 ) ? AND : "" );
- xpathExpression += contains( parent, TABLE_COLUMN + position( nIndex + 1 ), columnValues[nIndex] );
- }
- }
-
- return xpathExpression;
- }
-
- private static String position( int nIndex )
- {
- return new String( "[" + nIndex + "]" );
- }
-
- private static String contains( String parent, String element, String matchedString )
- {
- String finalElement = ( parent != null ) ? parent : "";
- finalElement += element;
-
- return contains( finalElement, matchedString );
- }
-
- private static String contains( String matchedString )
- {
- return contains( ".", matchedString );
- }
-
- private static String contains( String axis, String matchedString )
- {
- return new String( CONTAINS + "(" + axis + "," + "'" + matchedString + "')" );
- }
-
- private static String equals( String parent, String element, String matchedString )
- {
- String finalElement = ( parent != null ) ? parent : "";
- finalElement += element;
-
- return equals( finalElement, matchedString );
- }
-
- private static String equals( String axis, String matchedString )
- {
- return new String( axis + "==" + "'" + matchedString + "'" );
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.apache.archiva.web.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.testng.annotations.Test;
-import org.apache.archiva.web.test.parent.AbstractArchivaTest;
-
-/**
- * Test all actions affected with XSS security issue.
- */
-@Test( groups = { "xss" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
-public class XSSSecurityTest
- extends AbstractArchivaTest
-{
- public void testDeleteArtifactImmunityToURLCrossSiteScripting()
- {
- getSelenium().open( "/archiva/deleteArtifact!doDelete.action?groupId=\"/>1<script>alert('xss')</script>&artifactId=\"/>1<script>alert('xss')</script>&version=\"/>1<script>alert('xss')</script>&repositoryId=\"/>1<script>alert('xss')</script>");
- assertDeleteArtifactPage();
- assertTextPresent( "Invalid version." );
- assertTextPresent( "User is not authorized to delete artifacts in repository '\"/>1<script>alert('xss')</script>'." );
- assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Repository id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertElementValue("//input[@id='deleteArtifact_groupId']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='deleteArtifact_artifactId']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='deleteArtifact_version']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//select[@id='deleteArtifact_repositoryId']", "internal");
- }
-
- public void testDeleteArtifactImmunityToEncodedURLCrossSiteScripting()
- {
- getSelenium().open( "/archiva/deleteArtifact!doDelete.action?groupId=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&artifactId=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&version=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&repositoryId=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E");
- assertDeleteArtifactPage();
- assertTextPresent( "Invalid version." );
- assertTextPresent( "User is not authorized to delete artifacts in repository '\"/>1<script>alert('xss')</script>'." );
- assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Repository id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertElementValue("//input[@id='deleteArtifact_groupId']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='deleteArtifact_artifactId']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='deleteArtifact_version']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//select[@id='deleteArtifact_repositoryId']", "internal");
- }
-
- public void testEditAppearanceImmunityToURLCrossSiteScripting()
- {
- getSelenium().open( "/archiva/admin/configureAppearance.action?organisationName=<script>alert('xss')</script>&organisationUrl=<script>alert('xss')</script>&organisationLogo=<script>alert('xss')</script>");
- assertAppearancePage();
- assertXpathCount("//td[text()=\"<script>alert('xss')</script>\"]", 1);
- assertXpathCount("//code[text()=\"<script>alert('xss')</script>\"]", 2);
-
- }
-
- public void testEditAppearanceImmunityToEncodedURLCrossSiteScripting()
- {
- getSelenium().open( "/archiva/admin/configureAppearance.action?organisationName=%3Cscript%3Ealert('xss')%3C%2Fscript%3E&organisationUrl=%3Cscript%3Ealert('xss')%3C%2Fscript%3E&organisationLogo=%3Cscript%3Ealert('xss')%3C%2Fscript%3E");
- assertAppearancePage();
- assertXpathCount("//td[text()=\"<script>alert('xss')</script>\"]", 1);
- assertXpathCount("//code[text()=\"<script>alert('xss')</script>\"]", 2);
- }
-
- public void testAddLegacyArtifactImmunityToURLCrossSiteScripting()
- {
- getSelenium().open( "/archiva/admin/addLegacyArtifactPath!commit.action?legacyArtifactPath.path=\"/>1<script>alert('xss')</script>&groupId=\"/>1<script>alert('xss')</script>&artifactId=\"/>1<script>alert('xss')</script>&version=\"/>1<script>alert('xss')</script>&classifier=\"/>1<script>alert('xss')</script>&type=\"/>1<script>alert('xss')</script>");
- assertAddLegacyArtifactPathPage();
- assertTextPresent( "Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertElementValue("//input[@id='addLegacyArtifactPath_legacyArtifactPath_path']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='addLegacyArtifactPath_artifactId']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='addLegacyArtifactPath_version']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='addLegacyArtifactPath_groupId']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='addLegacyArtifactPath_classifier']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='addLegacyArtifactPath_type']", "\"/>1<script>alert('xss')</script>");
- }
-
- public void testAddLegacyArtifactImmunityToEncodedURLCrossSiteScripting()
- {
- getSelenium().open( "/archiva/admin/addLegacyArtifactPath!commit.action?legacyArtifactPath.path=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&groupId=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&artifactId=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&version=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&classifier=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E&type=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E");
- assertAddLegacyArtifactPathPage();
- assertTextPresent( "Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertElementValue("//input[@id='addLegacyArtifactPath_legacyArtifactPath_path']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='addLegacyArtifactPath_artifactId']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='addLegacyArtifactPath_version']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='addLegacyArtifactPath_groupId']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='addLegacyArtifactPath_classifier']", "\"/>1<script>alert('xss')</script>");
- assertElementValue("//input[@id='addLegacyArtifactPath_type']", "\"/>1<script>alert('xss')</script>");
- }
-
- public void testDeleteNetworkProxyImmunityToURLCrossSiteScripting()
- {
- getSelenium().open( "/archiva/admin/deleteNetworkProxy!confirm.action?proxyid=\"/>1<script>alert('xss')</script>");
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testDeleteNetworkProxyImmunityToEncodedURLCrossSiteScripting()
- {
- getSelenium().open( "/archiva/admin/deleteNetworkProxy!confirm.action?proxyid=%22%2F%3E1%3Cscript%3Ealert('xss')%3C%2Fscript%3E");
- assertTextPresent( "Security Alert - Invalid Token Found" );
- assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." );
- }
-
- public void testAddManagedRepositoryImmunityToInputFieldCrossSiteScripting()
- {
- goToRepositoriesPage();
- 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" );
- // xss inputs are blocked by validation.
- 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." );
- }
-
- public void testEditAppearanceImmunityToInputFieldCrossSiteScripting()
- {
- goToAppearancePage();
- clickLinkWithText( "Edit" );
- addEditAppearance( "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>" );
- // xss inputs are blocked by validation.
- 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);
- }
-
- public void testEditAppearanceImmunityToCrossSiteScriptingRendering()
- {
- goToAppearancePage();
- clickLinkWithText( "Edit" );
- addEditAppearance( "xss" , "http://\">test<script>alert(\"xss\")</script>" , "http://\">test<script>alert(\"xss\")</script>" );
- // escaped html/url prevents cross-site scripting exploits
- assertXpathCount("//td[text()=\"xss\"]", 1);
- assertXpathCount("//code[text()='http://\">test<script>alert(\"xss\")</script>']", 2);
- }
-
- public void testAddLegacyArtifactPathImmunityToInputFieldCrossSiteScripting()
- {
- goToLegacySupportPage();
- clickLinkWithText( "Add" );
- addLegacyArtifactPath( "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>" , "test<script>alert('xss')</script>");
- // xss inputs are blocked by validation.
- assertTextPresent( "Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- }
-
- public void testAddNetworkProxyImmunityToInputFieldCrossSiteScripting()
- {
- goToNetworkProxiesPage();
- addNetworkProxy( "test<script>alert('xss')</script>", "test<script>alert('xss')</script>", "test<script>alert('xss')</script>", "test<script>alert('xss')</script>", "test<script>alert('xss')</script>", "");
- // xss inputs are blocked by validation.
- assertTextPresent( "Proxy id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
- assertTextPresent( "Protocol must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), dots(.), colons(:), and dashes(-)." );
- assertTextPresent( "Host must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
- assertTextPresent( "Invalid field value for field \"proxy.port\"." );
- assertTextPresent( "Username must only contain alphanumeric characters, at's(@), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.apache.archiva.web.test.listener;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.regex.Pattern;
-
-import org.apache.archiva.web.test.parent.AbstractSeleniumTest;
-import org.apache.commons.io.FileUtils;
-import org.testng.ITestResult;
-import org.testng.TestListenerAdapter;
-import com.thoughtworks.selenium.Selenium;
-
-public class CaptureScreenShotsListener
- extends TestListenerAdapter
-{
- @Override
- public void onTestSkipped( ITestResult tr )
- {
- System.out.println( "Test " + tr.getName() + " -> Skipped" );
- super.onTestSkipped( tr );
- }
-
- @Override
- public void onTestFailure( ITestResult tr )
- {
- captureError( tr );
- System.out.println( "Test " + tr.getName() + " -> Failed" );
- super.onTestFailure( tr );
- }
-
- @Override
- public void onTestSuccess( ITestResult tr )
- {
- System.out.println( "Test " + tr.getName() + " -> Success" );
- super.onTestFailure( tr );
- }
-
- private void captureError( ITestResult tr )
- {
- SimpleDateFormat sdf = new SimpleDateFormat( "yyyy.MM.dd-HH_mm_ss" );
- String time = sdf.format( new Date() );
- File targetPath = new File( "target", "screenshots" );
- StackTraceElement stackTrace[] = tr.getThrowable().getStackTrace();
- String cName = tr.getTestClass().getName();
- int index = getStackTraceIndexOfCallingClass( cName, stackTrace );
- String methodName = stackTrace[index].getMethodName();
- int lNumber = stackTrace[index].getLineNumber();
- String lineNumber = Integer.toString( lNumber );
- String className = cName.substring( cName.lastIndexOf( '.' ) + 1 );
- targetPath.mkdirs();
- Selenium selenium = AbstractSeleniumTest.getSelenium();
- String fileBaseName = methodName + "_" + className + ".java_" + lineNumber + "-" + time;
- try
- {
- selenium.windowMaximize();
- File fileName = new File( targetPath, fileBaseName + ".png" );
- selenium.captureEntirePageScreenshot( fileName.getAbsolutePath(), "background=#FFFFFF" );
- }
- catch ( RuntimeException e )
- {
- System.out.println( "Error when take screenshot for test " + tr.getName() + ": " + e.getMessage() );
- try
- {
- File fileName = new File( targetPath, fileBaseName + ".html" );
- FileUtils.writeStringToFile( fileName, selenium.getHtmlSource() );
- }
- catch ( IOException ioe )
- {
- System.out.println( ioe.getMessage() );
- }
- }
- }
-
- private int getStackTraceIndexOfCallingClass( String nameOfClass, StackTraceElement stackTrace[] )
- {
- boolean match = false;
- int i = 0;
- do
- {
- String className = stackTrace[i].getClassName();
- match = Pattern.matches( nameOfClass, className );
- i++;
- }
- while ( match == false );
- i--;
- return i;
- }
-}
+++ /dev/null
-package org.apache.archiva.web.test.parent;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.archiva.web.test.XPathExpressionUtil;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public abstract class AbstractArchivaTest
- extends AbstractSeleniumTest
-{
- protected String username;
- protected String fullname;
-
- public String getUserEmail()
- {
- String email = getProperty("USERROLE_EMAIL");
- return email;
- }
-
- public String getUserRolePassword()
- {
- String password = getProperty("USERROLE_PASSWORD");
- return password;
- }
-
- public String getUserRoleNewPassword()
- {
- String password_new = getProperty( "NEW_USERROLE_PASSWORD" );
- return password_new;
- }
-
- public String getBasedir()
- {
- String basedir = System.getProperty( "basedir" );
-
- if ( basedir == null )
- {
- basedir = new File( "" ).getAbsolutePath();
- }
-
- return basedir;
- }
-
- public String getAdminUsername()
- {
- String adminUsername = getProperty( "ADMIN_USERNAME" );
- return adminUsername;
- }
-
- public String getAdminPassword()
- {
- String adminPassword = getProperty( "ADMIN_PASSWORD" );
- return adminPassword;
- }
-
- public void assertCreateAdmin()
- {
- assertPage( "Apache Archiva \\ Create Admin User" );
- assertTextPresent( "Username" );
- assertFieldValue( "admin", "user.username" );
- assertTextPresent( "Full Name*" );
- assertElementPresent( "user.fullName" );
- assertTextPresent( "Email Address*" );
- assertElementPresent( "user.email");
- assertTextPresent( "Password*" );
- assertElementPresent( "user.password" );
- assertTextPresent( "Confirm Password*" );
- assertElementPresent( "user.confirmPassword" );
- assertButtonWithValuePresent( "Create Admin" );
- }
-
- public void submitAdminData( String fullname, String email, String password )
- {
- setFieldValue( "user.fullName", fullname );
- setFieldValue( "user.email", email );
- setFieldValue( "user.password", password );
- setFieldValue( "user.confirmPassword", password );
- submit();
- }
-
- //Go to Login Page
- public void goToLoginPage()
- {
- getSelenium().open( baseUrl );
- clickLinkWithText( "Login");
- assertLoginPage();
- }
-
- public void submitUserData( String username, String password, boolean rememberme, boolean success )
- {
-
- setFieldValue( "username", username );
- setFieldValue( "password", password );
- if ( rememberme )
- {
- checkField( "rememberMe" );
- }
-
- submit();
- if ( success )
- {
- assertUserLoggedIn( username );
- }
- else
- {
- assertLoginPage();
- }
- }
-
- public void assertLoginPage()
- {
- assertPage( "Apache Archiva \\ Login Page" );
- assertTextPresent( "Login" );
- assertTextPresent( "Register" );
- assertTextPresent( "Username" );
- assertElementPresent( "username" );
- assertTextPresent( "Password" );
- assertElementPresent( "password" );
- assertTextPresent( "Remember Me" );
- assertElementPresent( "rememberMe" );
- assertButtonWithValuePresent( "Login" );
- assertButtonWithValuePresent( "Cancel" );
- assertTextPresent( "Need an Account? Register!" );
- assertTextPresent( "Forgot your Password? Request a password reset." );
- }
-
- //User Management
- public void goToUserManagementPage()
- {
- getSelenium().open( "/archiva/security/userlist.action" );
- assertUserManagementPage();
- }
-
- public void assertUserManagementPage()
- {
- assertPage( "Apache Archiva \\ [Admin] User List" );
- assertTextPresent( "[Admin] List of Users in Role: Any" );
- assertTextPresent( "Navigation" );
- assertImgWithAlt( "First" );
- assertImgWithAlt( "Prev" );
- assertImgWithAlt( "Next" );
- assertImgWithAlt( "Last" );
- assertTextPresent( "Display Rows" );
- assertTextPresent( "Username" );
- assertTextPresent( "Full Name" );
- assertTextPresent( "Email" );
- assertTextPresent( "Permanent" );
- assertTextPresent( "Validated" );
- assertTextPresent( "Locked" );
- assertTextPresent( "Tasks" );
- assertTextPresent( "Tools" );
- assertTextPresent( "Tasks" );
- assertTextPresent( "The following tools are available for administrators to manipulate the user list." );
- assertButtonWithValuePresent( "Create New User" );
- assertButtonWithValuePresent( "Show Users In Role" );
- assertElementPresent( "roleName" );
- assertTextPresent( "Reports" );
- assertTextPresent( "Name" );
- assertTextPresent( "Types" );
- assertTextPresent( "User List" );
- assertTextPresent( "Roles Matrix" );
- }
-
-/* //User Role
- public void goToUserRolesPage()
- {
- clickLinkWithText( "User Roles" );
- assertUserRolesPage();
- }*/
-
- public void assertUserRolesPage()
- {
- assertPage( "Apache Archiva \\ [Admin] User Edit" );
- assertTextPresent( "[Admin] User Roles" );
- assertTextPresent( "Username" );
- assertTextPresent( "Full Name" );
- String userRoles = "Guest,Registered User,System Administrator,User Administrator,Global Repository Observer,Global Repository Manager,Repository Observer,Repository Manager,internal";
- String[] arrayRole = userRoles.split( "," );
- for ( String userroles : arrayRole )
- assertTextPresent( userroles );
- }
-
- public void assertDeleteUserPage( String username )
- {
- assertPage( "Apache Archiva \\ [Admin] User Delete" ); //TODO
- assertTextPresent( "[Admin] User Delete" );
- assertTextPresent( "The following user will be deleted:" );
- assertTextPresent( "Username: " + username );
- assertButtonWithValuePresent( "Delete User" );
- }
-
- public void createUser( String userName, String fullName, String email, String password, boolean valid )
- {
- createUser( userName, fullName, email, password, password, valid );
- }
-
- private void createUser( String userName, String fullName, String emailAd, String password, String confirmPassword, boolean valid )
- {
- //login( getAdminUsername() , getAdminPassword() );
- getSelenium().open( "/archiva/security/userlist.action" );
- clickButtonWithValue( "Create New User" );
- assertCreateUserPage();
- setFieldValue( "user.username", userName );
- setFieldValue( "user.fullName", fullName );
- setFieldValue( "user.email", emailAd );
- setFieldValue( "user.password", password );
- setFieldValue( "user.confirmPassword", confirmPassword );
- submit();
-
- assertUserRolesPage( );
- clickButtonWithValue( "Submit" );
-
- if (valid )
- {
- String[] columnValues = {userName, fullName, emailAd};
- assertElementPresent( XPathExpressionUtil.getTableRow( columnValues ) );
- }
- else
- {
- assertCreateUserPage();
- }
- }
-
- public void deleteUser( String userName, String fullName, String emailAdd )
- {
- deleteUser( userName, fullName, emailAdd, false, false );
- }
-
- public void deleteUser(String userName, String fullName, String emailAd, boolean validated, boolean locked)
- {
- String[] columnValues = {userName, fullName, emailAd};
- //clickLinkWithText( "userlist" );
- clickLinkWithXPath( "//table[@id='ec_table']/tbody[2]/tr[3]/td[7]/a/img" );
- assertDeleteUserPage( userName );
- submit();
- assertElementNotPresent( XPathExpressionUtil.getTableRow( columnValues ) );
- }
-
- public void login( String username, String password )
- {
- login( username, password, true, "Login Page" );
- }
-
- public void login( String username, String password, boolean valid, String assertReturnPage )
- {
- if ( isLinkPresent( "Login" ) )
- {
- goToLoginPage();
-
- submitLoginPage( username, password, false, valid, assertReturnPage );
- }
- if ( valid )
- {
- assertUserLoggedIn( username );
- }
- }
-
- public void submitLoginPage( String username, String password )
- {
- submitLoginPage( username, password, false, true, "Login Page" );
- }
-
- public void submitLoginPage( String username, String password, boolean validUsernamePassword )
- {
- submitLoginPage( username, password, false, validUsernamePassword, "Login Page" );
- }
-
- public void submitLoginPage( String username, String password, boolean rememberMe, boolean validUsernamePassword,
- String assertReturnPage )
- {
- assertLoginPage();
- setFieldValue( "username", username );
- setFieldValue( "password", password );
- if ( rememberMe )
- {
- checkField( "rememberMe" );
- }
- clickButtonWithValue( "Login" );
-
- if ( validUsernamePassword )
- {
- assertUserLoggedIn( username );
- }
- else
- {
- if ( "Login Page".equals( assertReturnPage ) )
- {
- assertLoginPage();
- }
- else
- {
- assertPage( assertReturnPage );
- }
- }
- }
-
- protected void assertUserLoggedIn( String username )
- {
- assertTextPresent( "Current User:" );
- assertTextPresent( username );
- assertLinkPresent( "Edit Details" );
- assertLinkPresent( "Logout" );
- assertTextNotPresent( "Login" );
- }
-
- // User Roles
- public void assertUserRoleCheckBoxPresent(String value)
- {
- getSelenium() .isElementPresent("xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value + "']");
- }
-
- public void assertResourceRolesCheckBoxPresent(String value) {
- getSelenium().isElementPresent("xpath=//input[@name='addDSelectedRoles' and @value='" + value + "']");
- }
-
- public void checkUserRoleWithValue(String value)
- {
- assertUserRoleCheckBoxPresent(value);
- getSelenium().click( "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value + "']");
- }
-
- public void checkResourceRoleWithValue(String value)
- {
- assertResourceRolesCheckBoxPresent(value);
- getSelenium().click( "xpath=//input[@name='addDSelectedRoles' and @value='" + value + "']" );
- }
-
-
- public void changePassword(String oldPassword, String newPassword) {
- assertPage("Apache Archiva \\ Change Password");
- setFieldValue("existingPassword", oldPassword);
- setFieldValue("newPassword", newPassword);
- setFieldValue("newPasswordConfirm", newPassword);
- clickButtonWithValue("Change Password");
- }
-
- public void assertCreateUserPage()
- {
- assertPage( "Apache Archiva \\ [Admin] User Create" );
- assertTextPresent( "[Admin] User Create" );
- assertTextPresent( "Username*:" );
- assertElementPresent( "user.username" );
- assertTextPresent( "Full Name*:");
- assertElementPresent( "user.fullName" );
- assertTextPresent( "Email Address*:" );
- assertElementPresent( "user.email" );
- assertTextPresent( "Password*:" );
- assertElementPresent( "user.password" );
- assertTextPresent( "Confirm Password*:" );
- assertElementPresent( "user.confirmPassword" );
- assertButtonWithValuePresent( "Create User" );
- }
-
- public void assertLeftNavMenuWithRole( String role )
- {
- if ( role.equals( "Guest" ) || role.equals( "Registered User" ) || role.equals( "Global Repository Observer" ) || role.equals( "Repository Observer - internal" ) || role.equals( "Repository Observer - snapshots" ) )
- {
- assertTextPresent( "Search" );
- assertLinkPresent( "Find Artifact" );
- assertLinkPresent( "Browse" );
- assertLinkNotPresent( "Repositories" );
- }
- else if ( role.equals( "User Administrator" ) )
- {
- assertTextPresent( "Search" );
- assertLinkPresent( "Find Artifact" );
- assertLinkPresent( "Browse" );
- assertLinkPresent( "User Management" );
- assertLinkPresent( "User Roles" );
- assertLinkNotPresent( "Repositories" );
- }
- else if ( role.equals( "Global Repository Manager" ) || role.equals( "Repository Manager - internal" ) || role.equals( "Repository Manager - snapshots" ) )
- {
- assertTextPresent( "Search" );
- assertLinkPresent( "Find Artifact" );
- assertLinkPresent( "Browse" );
- assertLinkPresent( "Upload Artifact" );
- assertLinkPresent( "Delete Artifact" );
- assertLinkNotPresent( "Repositories" );
- }
- else
- {
- assertTextPresent( "Search" );
- String navMenu = "Find Artifact,Browse,Reports,User Management,User Roles,Appearance,Upload Artifact,Delete Artifact,Repository Groups,Repositories,Proxy Connectors,Legacy Support,Network Proxies,Repository Scanning,Database";
- String[] arrayMenu = navMenu.split( "," );
- for (String navmenu : arrayMenu )
- assertLinkPresent( navmenu );
- }
- }
- //Find Artifact
- public void goToFindArtifactPage()
- {
- getSelenium().open( "/archiva/findArtifact.action" );
- assertFindArtifactPage();
- }
-
- public void assertFindArtifactPage()
- {
- assertPage( "Apache Archiva \\ Find Artifact" );
- assertTextPresent( "Find Artifact" );
- assertTextPresent( "Search for:" );
- assertTextPresent( "Checksum:" );
- assertElementPresent( "q" );
- assertButtonWithValuePresent( "Search" );
- }
-
- //Appearance
- public void goToAppearancePage()
- {
- getSelenium().open( "/archiva/admin/configureAppearance.action" );
- assertAppearancePage();
- }
-
- public void assertAppearancePage()
- {
- assertPage( "Apache Archiva \\ Configure Appearance" );
- String appearance = "Appearance,Organization Details,The logo in the top right of the screen is controlled by the following settings.,Organization Information,Name,URL,Logo URL";
- String[] arrayAppearance = appearance.split( "," );
- for ( String appear : arrayAppearance )
- assertTextPresent( appear );
- assertLinkPresent( "Edit" );
- assertLinkPresent( "Change your appearance" );
- }
-
- public void addEditAppearance( String name, String url, String logoUrl )
- {
- setFieldValue( "organisationName" , name );
- setFieldValue( "organisationUrl" , url );
- setFieldValue( "organisationLogo" , logoUrl );
- clickButtonWithValue( "Save" );
- }
-
- // Upload Artifact
- public void goToAddArtifactPage()
- {
- getSelenium().open( "/archiva/upload.action" );
- assertAddArtifactPage();
- }
-
- public void assertAddArtifactPage()
- {
- assertPage( "Apache Archiva \\ Upload Artifact" );
- assertTextPresent( "Upload Artifact" );
-
- String artifact =
- "Upload Artifact,Group Id*:,Artifact Id*:,Version*:,Packaging*:,Classifier:,Generate Maven 2 POM,Artifact File*:,POM File:,Repository Id:";
- String[] arrayArtifact = artifact.split( "," );
- for ( String arrayartifact : arrayArtifact )
- assertTextPresent( arrayartifact );
-
- String artifactElements =
- "upload_groupId,upload_artifactId,upload_version,upload_packaging,upload_classifier,upload_generatePom,upload_artifact,upload_pom,upload_repositoryId,upload_0";
- String[] arrayArtifactElements = artifactElements.split( "," );
- for ( String artifactelements : arrayArtifactElements )
- assertElementPresent( artifactelements );
- }
-
- public void addArtifact( String groupId, String artifactId, String version, String packaging,
- String artifactFilePath, String repositoryId )
- {
- addArtifact( groupId, artifactId, version, packaging, true, artifactFilePath, repositoryId );
- }
-
- public void addArtifact( String groupId, String artifactId, String version, String packaging, boolean generatePom,
- String artifactFilePath, String repositoryId )
- {
- goToAddArtifactPage();
- setFieldValue( "groupId", groupId );
- setFieldValue( "artifactId", artifactId );
- setFieldValue( "version", version );
- setFieldValue( "packaging", packaging );
-
- if ( generatePom )
- {
- checkField( "generatePom" );
- }
-
- String path;
- if ( artifactFilePath != null && artifactFilePath.trim().length() > 0 )
- {
- File f = new File( artifactFilePath );
- try
- {
- path = f.getCanonicalPath();
- }
- catch ( IOException e )
- {
- path = f.getAbsolutePath();
- }
- }
- else
- {
- path = artifactFilePath;
- }
-
- setFieldValue( "artifact", path );
- setFieldValue( "repositoryId", repositoryId );
-
- clickButtonWithValue( "Submit" );
- }
-
- public void goToRepositoriesPage()
- {
- if( !getTitle().equals( "Apache Archiva \\ Administration - Repositories" ) )
- {
- getSelenium().open( "/archiva/admin/repositories.action" );
- }
- assertRepositoriesPage();
- }
-
- public void assertRepositoriesPage()
- {
- assertPage( "Apache Archiva \\ Administration - Repositories" );
- assertTextPresent( "Administration - Repositories" );
- assertTextPresent( "Managed Repositories" );
- assertTextPresent( "Remote Repositories" );
- }
-
- public void addManagedRepository( String identifier, String name, String directory, String indexDirectory, String type, String cron,
- String daysOlder, String retentionCount )
- {
- //goToRepositoriesPage();
- //clickLinkWithText( "Add" );
- setFieldValue( "repository.id" , identifier );
- setFieldValue( "repository.name" , name );
- setFieldValue( "repository.location" , directory );
- setFieldValue( "repository.indexDir" , indexDirectory );
- selectValue( "repository.layout", type );
- setFieldValue( "repository.refreshCronExpression" , cron );
- setFieldValue( "repository.daysOlder" , daysOlder );
- setFieldValue( "repository.retentionCount" , retentionCount );
- //TODO
- clickButtonWithValue( "Add Repository" );
- }
-
- // artifact management
- public void assertDeleteArtifactPage()
- {
- assertPage( "Apache Archiva \\ Delete Artifact" );
- assertTextPresent( "Delete Artifact" );
- assertTextPresent( "Group Id*:" );
- assertTextPresent( "Artifact Id*:" );
- assertTextPresent( "Version*:" );
- assertTextPresent( "Repository Id:" );
- assertElementPresent( "groupId" );
- assertElementPresent( "artifactId" );
- assertElementPresent( "version" );
- assertElementPresent( "repositoryId" );
- assertButtonWithValuePresent( "Submit" );
- }
-
- // network proxies
- public void goToNetworkProxiesPage()
- {
- clickLinkWithText( "Network Proxies" );
- assertNetworkProxiesPage();
- }
-
- public void assertNetworkProxiesPage()
- {
- assertPage( "Apache Archiva \\ Administration - Network Proxies" );
- assertTextPresent( "Administration - Network Proxies" );
- assertTextPresent( "Network Proxies" );
- assertLinkPresent( "Add Network Proxy" );
- }
-
- public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username, String password )
- {
- //goToNetworkProxiesPage();
- clickLinkWithText( "Add Network Proxy" );
- assertAddNetworkProxy();
- setFieldValue( "proxy.id" , identifier );
- setFieldValue( "proxy.protocol" , protocol );
- setFieldValue( "proxy.host" , hostname );
- setFieldValue( "proxy.port" , port );
- setFieldValue( "proxy.username" , username );
- setFieldValue( "proxy.password" , password );
- clickButtonWithValue( "Save Network Proxy" );
- }
-
- public void assertAddNetworkProxy()
- {
- assertPage( "Apache Archiva \\ Admin: Add Network Proxy" );
- assertTextPresent( "Admin: Add Network Proxy" );
- assertTextPresent( "Add network proxy:" );
- assertTextPresent( "Identifier*:" );
- assertTextPresent( "Protocol*:" );
- assertTextPresent( "Hostname*:" );
- assertTextPresent( "Port*:" );
- assertTextPresent( "Username:" );
- assertTextPresent( "Password:" );
- assertButtonWithValuePresent( "Save Network Proxy" );
- }
-
- // Legacy Support
- public void goToLegacySupportPage()
- {
- getSelenium().open( "/archiva/admin/legacyArtifactPath.action" );
- assertLegacySupportPage();
- }
-
- public void assertLegacySupportPage()
- {
- assertPage( "Apache Archiva \\ Administration - Legacy Support" );
- assertTextPresent( "Administration - Legacy Artifact Path Resolution" );
- assertTextPresent( "Path Mappings" );
- assertLinkPresent( "Add" );
- }
-
- public void addLegacyArtifactPath( String path, String groupId, String artifactId, String version, String classifier, String type)
- {
- assertAddLegacyArtifactPathPage();
- setFieldValue( "legacyArtifactPath.path" , path );
- setFieldValue( "groupId" , groupId );
- setFieldValue( "artifactId" , artifactId );
- setFieldValue( "version" , version );
- setFieldValue( "classifier" , classifier );
- setFieldValue( "type" , type );
- clickButtonWithValue( "Add Legacy Artifact Path" );
- }
-
- public void assertAddLegacyArtifactPathPage()
- {
- assertPage( "Apache Archiva \\ Admin: Add Legacy Artifact Path" );
- assertTextPresent( "Admin: Add Legacy Artifact Path" );
- assertTextPresent( "Enter the legacy path to map to a particular artifact reference, then adjust the fields as necessary." );
- String element = "addLegacyArtifactPath_legacyArtifactPath_path,addLegacyArtifactPath_groupId,addLegacyArtifactPath_artifactId,addLegacyArtifactPath_version,addLegacyArtifactPath_classifier,addLegacyArtifactPath_type";
- String[] arrayElement = element.split( "," );
- for ( String arrayelement : arrayElement )
- assertElementPresent( arrayelement );
- assertButtonWithValuePresent( "Add Legacy Artifact Path" );
- }
-
- protected void logout()
- {
- clickLinkWithText("Logout");
- assertTextNotPresent( "Current User:" );
- assertLinkNotPresent( "Edit Details" );
- assertLinkNotPresent( "Logout" );
- assertLinkPresent( "Login" );
- }
-}
+++ /dev/null
-package org.apache.archiva.web.test.parent;
-
-public abstract class AbstractArtifactManagementTest
- extends AbstractArchivaTest
-{
-
- public String getGroupId()
- {
- String groupId = getProperty( "GROUPID" ) ;
- return groupId;
- }
-
- public String getArtifactId()
- {
- String artifactId = getProperty( "ARTIFACTID" ) ;
- return artifactId;
- }
-
- public String getVersion()
- {
- String version = getProperty( "VERSION" ) ;
- return version;
- }
-
- public String getPackaging()
- {
- String packaging = getProperty( "PACKAGING" ) ;
- return packaging;
- }
-
- public String getArtifactFilePath()
- {
- return "src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
- }
-
- public String getRepositoryId()
- {
- String repositoryId = getProperty( "REPOSITORYID" ) ;
- return repositoryId;
- }
-
- public void goToDeleteArtifactPage()
- {
- login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
- getSelenium().open( "/archiva/deleteArtifact.action" );
- assertDeleteArtifactPage();
- }
-
- public void deleteArtifact( String groupId, String artifactId, String version, String repositoryId )
- {
- goToDeleteArtifactPage();
- setFieldValue( "groupId" , groupId );
- setFieldValue( "artifactId" , artifactId );
- setFieldValue( "version" , version );
- selectValue( "repositoryId" , repositoryId );
- clickButtonWithValue( "Submit" ) ;
- }
-}
+++ /dev/null
-package org.apache.archiva.web.test.parent;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public abstract class AbstractArtifactReportsTest
- extends AbstractArchivaTest
-{
-
- //Reports
- public void goToReportsPage()
- {
- getSelenium().open( "/archiva/report/pickReport.action" );
- assertReportsPage();
- }
-
- public void assertReportsPage()
- {
- assertPage( "Apache Archiva \\ Reports" );
- assertTextPresent( "Reports" );
- assertTextPresent( "Repository Statistics" );
- assertTextPresent( "Repositories To Be Compared" );
- assertElementPresent( "availableRepositories" );
- assertButtonWithValuePresent( "v" );
- assertButtonWithValuePresent( "^" );
- assertButtonWithValuePresent( "<-" );
- assertButtonWithValuePresent( "->" );
- assertButtonWithValuePresent( "<<--" );
- assertButtonWithValuePresent( "-->>" );
- assertButtonWithValuePresent( "<*>" );
- assertElementPresent( "selectedRepositories" );
- assertButtonWithValuePresent( "v" );
- assertButtonWithValuePresent( "^" );
- assertTextPresent( "Row Count" );
- assertElementPresent( "rowCount" );
- assertTextPresent( "Start Date" );
- assertElementPresent( "startDate" );
- assertTextPresent( "End Date" );
- assertElementPresent( "endDate" );
- assertButtonWithValuePresent( "View Statistics" );
- assertTextPresent( "Repository Health" );
- assertTextPresent( "Row Count" );
- assertElementPresent( "rowCount" );
- assertTextPresent( "Group ID" );
- assertElementPresent( "groupId" );
- assertTextPresent( "Repository ID" );
- assertElementPresent( "repositoryId" );
- assertButtonWithValuePresent( "Show Report" );
- }
-
- public void compareRepositories( String labelSelected, String startDate, String endDate )
- {
- goToReportsPage();
- getSelenium().removeSelection( "generateStatisticsReport_availableRepositories" , labelSelected );
- clickButtonWithValue( "->" , false );
- getSelenium().type( "startDate", startDate );
- //clickLinkWithLocator( "1" , false );
- //getSelenium().click( "endDate" );
- getSelenium().type( "endDate", endDate );
- //clickLinkWithLocator( "30" , false );
- clickButtonWithValue( "View Statistics" );
- }
-
-}
+++ /dev/null
-package org.apache.archiva.web.test.parent;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public abstract class AbstractBrowseTest
- extends AbstractArchivaTest
-{
-
- //Browse
- public void goToBrowsePage()
- {
- getSelenium().open( "/archiva/browse" );
- assertBrowsePage();
- }
-
- public void assertBrowsePage()
- {
- assertPage( "Apache Archiva \\ Browse Repository" );
- assertTextPresent( "Browse Repository" );
- assertTextPresent( "Groups" );
- }
-
-}
+++ /dev/null
-package org.apache.archiva.web.test.parent;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import org.testng.Assert;
-
-public abstract class AbstractRepositoryTest
- extends AbstractArchivaTest
-{
- // Repository Groups
- public void goToRepositoryGroupsPage()
- {
- if( !getTitle().equals( "Apache Archiva \\ Administration - Repository Groups" ) )
- {
- getSelenium().open( "/archiva/admin/repositoryGroups.action" );
- }
- assertRepositoryGroupsPage();
- }
-
- public void assertRepositoryGroupsPage()
- {
- assertPage( "Apache Archiva \\ Administration - Repository Groups" );
- assertTextPresent( "Administration - Repository Groups" );
- assertTextPresent( "Identifier*:" );
- assertElementPresent( "repositoryGroup.id" );
- assertButtonWithValuePresent( "Add Group" );
- assertTextPresent( "Repository Groups" );
- }
-
- public void assertAddedRepositoryLink( String repositoryGroupName)
- {
- assertPage( "Apache Archiva \\ Administration - Repository Groups" );
- String repositoryGroupUrlValue = "repository/" + repositoryGroupName + "/";
- String baseUrlValue = "archiva";
- String repositoryGroupLink = baseUrl.replaceFirst( baseUrlValue, repositoryGroupUrlValue);
- assertTextPresent( repositoryGroupLink );
- }
-
- public void assertAddedRepositoryToRepositoryGroups( String repositoryName)
- {
- assertPage( "Apache Archiva \\ Administration - Repository Groups" );
- assertTextPresent( repositoryName );
- assertTextPresent( "Archiva Managed Internal Repository" );
- assertAddedRepositoryLink( repositoryName );
- }
-
- public void assertDeleteRepositoryGroupPage( String repositoryName)
- {
- assertPage( "Apache Archiva \\ Admin: Delete Repository Group" );
- assertTextPresent( "WARNING: This operation can not be undone." );
- assertTextPresent( "Are you sure you want to delete the following repository group?" );
- assertElementPresent( "//preceding::td[text()='ID:']//following::td/code[text()='" + repositoryName + "']" );
- assertButtonWithValuePresent( "Confirm" );
- assertButtonWithValuePresent( "Cancel" );
- }
-
- public void addRepositoryGroup( String repoGroupName )
- {
- goToRepositoryGroupsPage();
- setFieldValue( "repositoryGroup.id", repoGroupName );
- clickButtonWithValue( "Add Group" );
- }
-
- public void addRepositoryToRepositoryGroup( String repositoryGroupName, String repositoryName )
- {
- goToRepositoryGroupsPage();
- String s = getSelenium().getBodyText();
- if ( s.contains( "No Repository Groups Defined." ) )
- {
- setFieldValue( "repositoryGroup.id" , repositoryGroupName );
- clickButtonWithValue( "Add Group" );
- //assertAddedRepositoryLink( repositoryGroupName );
-
- selectValue( "addRepositoryToGroup_repoId" , repositoryName );
- clickButtonWithValue( "Add Repository" );
- assertAddedRepositoryToRepositoryGroups( repositoryName );
- }
- else
- {
- //assertAddedRepositoryLink( repositoryGroupName );
- selectValue( "addRepositoryToGroup_repoId" , repositoryName );
- clickButtonWithValue( "Add Repository" );
- }
- }
-
- public void deleteRepositoryInRepositoryGroups()
- {
- goToRepositoryGroupsPage();
- getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" );
- waitPage();
- }
-
- public void deleteRepositoryGroup( String repositoryName )
- {
- getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" );
- waitPage();
- assertDeleteRepositoryGroupPage( repositoryName );
- clickButtonWithValue( "Confirm" );
- }
-
- ///////////////////////////////
- // proxy connectors
- ///////////////////////////////
- public void goToProxyConnectorsPage()
- {
- clickLinkWithText( "Proxy Connectors" );
- assertProxyConnectorsPage();
- }
-
- public void assertProxyConnectorsPage()
- {
- assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
- assertTextPresent( "Administration - Proxy Connectors" );
- assertTextPresent( "Repository Proxy Connectors" );
- assertTextPresent( "internal" );
- assertTextPresent( "Archiva Managed Internal Repository" );
- assertTextPresent( "Proxy Connector" );
- assertTextPresent( "Central Repository" );
- assertTextPresent( "Java.net Repository for Maven 2" );
- }
-
- public void assertAddProxyConnectorPage()
- {
- assertPage( "Apache Archiva \\ Admin: Add Proxy Connector" );
- assertTextPresent( "Admin: Add Proxy Connector" );
- String proxy = "Network Proxy*:,Managed Repository*:,Remote Repository*:,Policies:,Return error when:,On remote error:,Releases:,Snapshots:,Checksum:,Cache failures:,Properties:,No properties have been set.,Black List:,No black list patterns have been set.,White List:,No white list patterns have been set.";
- String[] arrayProxy = proxy.split( "," );
- for ( String arrayproxy : arrayProxy )
- assertTextPresent( arrayproxy );
- /*String proxyElements = "addProxyConnector_connector_proxyId,addProxyConnector_connector_sourceRepoId,addProxyConnector_connector_targetRepoId,policy_propagate-errors-on-update,policy_propagate-errors,policy_releases,policy_snapshots,policy_checksum,policy_cache-failures,propertiesEntry,propertiesValue,blackListEntry,whiteListEntry";
- String[] arrayProxyElements = proxyElements.split( "," );
- for ( String arrayproxyelements : arrayProxyElements )
- assertTextPresent( arrayproxyelements );*/
- assertButtonWithValuePresent( "Add Property" );
- assertButtonWithValuePresent( "Add Pattern" );
- assertButtonWithValuePresent( "Add Proxy Connector" );
- }
-
- // this only fills in the values of required fields in adding Proxy Connectors
- public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo )
- {
- goToProxyConnectorsPage();
- clickLinkWithText( "Add" );
- assertAddProxyConnectorPage();
- selectValue( "connector.proxyId" , networkProxy );
- selectValue( "connector.sourceRepoId" , managedRepo );
- selectValue( "connector.targetRepoId" , remoteRepo );
- }
-
- public void deleteProxyConnector()
- {
- goToProxyConnectorsPage();
- clickLinkWithXPath( "//div[@id='contentArea']/div[2]/div[1]/div[2]/div[1]/a[3]/img" );
- assertPage( "Apache Archiva \\ Admin: Delete Proxy Connectors" );
- clickButtonWithValue( "Delete" );
- assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
- }
-
- ///////////////////////////////
- // network proxies
- ///////////////////////////////
-
- public void editNetworkProxies( String fieldName, String value)
- {
- //goToNetworkProxiesPage();
- clickLinkWithText( "Edit Network Proxy" );
- setFieldValue( fieldName, value);
- clickButtonWithValue( "Save Network Proxy" );
- }
-
- public void deleteNetworkProxy()
- {
- //goToNetworkProxiesPage();
- clickLinkWithText( "Delete Network Proxy" );
- assertPage( "Apache Archiva \\ Admin: Delete Network Proxy" );
- assertTextPresent( "WARNING: This operation can not be undone." );
- clickButtonWithValue( "Delete" );
- }
-
- // remote repositories
- public void assertAddRemoteRepository()
- {
- assertPage( "Apache Archiva \\ Admin: Add Remote Repository" );
- String remote = "Identifier*:,Name*:,URL*:,Username:,Password:,Timeout in seconds:,Type:";
- String[] arrayRemote = remote.split( "," );
- for ( String arrayremote : arrayRemote )
- assertTextPresent( arrayremote );
- String remoteElements = "addRemoteRepository_repository_id,addRemoteRepository_repository_name,addRemoteRepository_repository_url,addRemoteRepository_repository_username,addRemoteRepository_repository_password,addRemoteRepository_repository_timeout,addRemoteRepository_repository_layout";
- String[] arrayRemoteElements = remoteElements.split( "," );
- for ( String arrayremotelement : arrayRemoteElements )
- assertElementPresent( arrayremotelement );
- }
-
- public void assertDeleteRemoteRepositoryPage()
- {
- assertPage( "Apache Archiva \\ Admin: Delete Remote Repository" );
- assertTextPresent( "Admin: Delete Remote Repository" );
- assertTextPresent( "WARNING: This operation can not be undone." );
- assertTextPresent( "Are you sure you want to delete the following remote repository?" );
- assertButtonWithValuePresent( "Confirm" );
- assertButtonWithValuePresent( "Cancel" );
- }
-
- public void addRemoteRepository( String identifier, String name, String url, String username, String password, String timeout, String type )
- {
- //goToRepositoriesPage();
- assertAddRemoteRepository();
- setFieldValue( "addRemoteRepository_repository_id" , identifier );
- setFieldValue( "addRemoteRepository_repository_name" , name );
- setFieldValue( "addRemoteRepository_repository_url" , url );
- setFieldValue( "addRemoteRepository_repository_username" , username );
- setFieldValue( "addRemoteRepository_repository_password" , password );
- setFieldValue( "addRemoteRepository_repository_timeout" , timeout );
- selectValue( "addRemoteRepository_repository_layout" , type );
- clickButtonWithValue( "Add Repository" );
- }
-
- public void deleteRemoteRepository()
- {
- goToRepositoriesPage();
- clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" );
- assertDeleteRemoteRepositoryPage();
- clickButtonWithValue( "Confirm" );
- }
-
- public void editRemoteRepository( String fieldName, String value)
- {
- goToRepositoriesPage();
- clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" );
- setFieldValue( fieldName, value );
- clickButtonWithValue( "Update Repository" );
- }
-
- public void editManagedRepository( String fieldName, String value )
- {
- goToRepositoriesPage();
- clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
- assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
- setFieldValue(fieldName, value);
- //TODO
- clickButtonWithValue( "Update Repository" );
- }
-
- public void editManagedRepository(String name, String directory, String indexDirectory, String type, String cron, String daysOlder, String retentionCount)
- {
- goToRepositoriesPage();
- clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
- assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
- setFieldValue( "repository.name" , name );
- setFieldValue( "repository.location" , directory );
- setFieldValue( "repository.indexDir" , indexDirectory );
- selectValue( "repository.layout", type );
- setFieldValue( "repository.refreshCronExpression" , cron );
- setFieldValue( "repository.daysOlder" , daysOlder );
- setFieldValue( "repository.retentionCount" , retentionCount );
- clickButtonWithValue( "Update Repository" );
- }
-
- public void deleteManagedRepository()
- {
- clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[2]" );
- assertPage( "Apache Archiva \\ Admin: Delete Managed Repository" );
- clickButtonWithValue( "Delete Configuration Only" );
- }
-
- public String getRepositoryDir()
- {
- File f = new File( "" );
- String artifactFilePath = f.getAbsolutePath();
- return artifactFilePath + "/target/";
- }
-
- /////////////////////////////////////////////
- // Repository Scanning
- /////////////////////////////////////////////
- public void goToRepositoryScanningPage()
- {
- clickLinkWithText( "Repository Scanning" );
- assertRepositoryScanningPage();
- }
-
- public void assertRepositoryScanningPage()
- {
- assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
- assertTextPresent( "Administration - Repository Scanning" );
- assertTextPresent( "Repository Scanning - File Types" );
- String artifactsTypes = "**/*.pom,**/*.jar,**/*.ear,**/*.war,**/*.car,**/*.sar,**/*.mar,**/*.rar,**/*.dtd,**/*.tld,**/*.tar.gz,**/*.tar.bz2,**/*.zip";
- String [] arrayArtifactTypes = artifactsTypes.split( "," );
- for (int i = 0; i < arrayArtifactTypes.length; i++)
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table."+i+".0"), arrayArtifactTypes[i]);
-
- String autoremove = "**/*.bak,**/*~,**/*-";
- String [] arrayAutoremove = autoremove.split( "," );
- for (int i = 0; i < arrayAutoremove.length; i++)
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table."+i+".0"), arrayAutoremove[i]);
-
- String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**";
- String [] arrayIgnored = ignored.split( "," );
- for (int i = 0; i < arrayIgnored.length; i++)
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table."+i+".0"), arrayIgnored[i]);
-
- String indexableContent = "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld";
- String [] arrayIndexableContent = indexableContent.split( "," );
- for (int i = 0; i < arrayIndexableContent.length; i++)
- Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table."+i+".0"), arrayIndexableContent[i]);
- }
-
- /////////////////////////////////////////////
- // Database
- /////////////////////////////////////////////
- public void goToDatabasePage()
- {
- clickLinkWithText( "Database" );
- assertDatabasePage();
- }
-
- public void assertDatabasePage()
- {
- assertPage( "Apache Archiva \\ Administration - Database" );
- assertTextPresent( "Administration - Database" );
- assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
- assertTextPresent( "Cron:" );
- assertElementPresent( "database_cron" );
- assertButtonWithValuePresent( "Update Cron" );
- assertButtonWithValuePresent( "Update Database Now" );
- assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
- assertTextPresent( "Database - Artifact Cleanup Scanning" );
- }
-}
+++ /dev/null
-package org.apache.archiva.web.test.parent;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public abstract class AbstractSearchTest
- extends AbstractArchivaTest
-{
- //Search
- public void goToSearchPage()
- {
- if ( !"Apache Archiva \\ Quick Search".equals( getTitle() ) )
- {
- clickLinkWithText( "Search" );
- getSelenium().waitForPageToLoad( maxWaitTimeInMs );
-
- assertPage( "Apache Archiva \\ Quick Search" );
- }
- }
-
- public void assertSearchPage()
- {
- assertPage( "Apache Archiva \\ Quick Search" );
- assertTextPresent( "Search for" );
- assertElementPresent( "quickSearch_q" );
- assertButtonWithValuePresent( "Search" );
- //assertLinkPresent( "Advanced Search" );
- assertTextPresent( "Enter your search terms. A variety of data will be searched for your keywords." );
- //assertButtonWithDivIdPresent( "searchHint" );
- }
-
- public void searchForArtifact( String artifactId )
- {
- goToSearchPage();
-
- getSelenium().type( "dom=document.forms[1].elements[0]", artifactId );
- clickButtonWithValue( "Search" );
- }
-
- public void searchForArtifactAdvancedSearch( String groupId, String artifactId, String version, String repositoryId,
- String className, String rowCount )
- {
- goToSearchPage();
-
- clickLinkWithXPath( "//div[@id='contentArea']/div[1]/a[1]/strong", false );
- assertElementPresent( "filteredSearch_searchField" );
- assertElementPresent( "filteredSearch_repositoryId" );
-
- if ( groupId != null )
- {
- selectValue( "filteredSearch_searchField", "Group ID" );
- clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false );
-
- assertElementPresent( "groupId" );
- setFieldValue( "groupId", groupId );
- }
-
- if ( artifactId != null )
- {
- selectValue( "filteredSearch_searchField", "Artifact ID" );
- clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false );
-
- assertElementPresent( "artifactId" );
- setFieldValue( "artifactId", artifactId );
- }
-
- if ( version != null )
- {
- selectValue( "filteredSearch_searchField", "Version" );
- clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false );
-
- assertElementPresent( "version" );
- setFieldValue( "version", version );
- }
-
- if ( className != null )
- {
- selectValue( "filteredSearch_searchField", "Class/Package Name" );
- clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false );
-
- assertElementPresent( "className" );
- setFieldValue( "className", className );
- }
-
- if ( rowCount != null )
- {
- selectValue( "filteredSearch_searchField", "Row Count" );
- clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false );
-
- assertElementPresent( "rowCount" );
- setFieldValue( "rowCount", rowCount );
- }
-
- if ( repositoryId != null )
- {
- selectValue( "filteredSearch_repositoryId", repositoryId );
- }
- clickSubmitWithLocator( "filteredSearch_0" );
- }
-}
+++ /dev/null
-package org.apache.archiva.web.test.parent;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-
-import com.thoughtworks.selenium.DefaultSelenium;
-import com.thoughtworks.selenium.Selenium;
-import org.apache.commons.io.IOUtils;
-import org.testng.Assert;
-
-/**
- * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
- * @version $Id: AbstractSeleniumTestCase.java 761154 2009-04-02 03:31:19Z wsmoak $
- */
-
-public abstract class AbstractSeleniumTest {
-
- public static String baseUrl;
-
- public static String maxWaitTimeInMs;
-
- private static ThreadLocal<Selenium> selenium = new ThreadLocal<Selenium>();
-
- public static Properties p;
-
- private final static String PROPERTIES_SEPARATOR = "=";
-
- public void open()
- throws Exception
- {
- p = new Properties();
- p.load( this.getClass().getClassLoader().getResourceAsStream( "testng.properties" ) );
-
- //baseUrl = getProperty( "BASE_URL" );
- maxWaitTimeInMs = getProperty( "MAX_WAIT_TIME_IN_MS" );
- }
-
- /**
- * Initialize selenium
- */
- public void open( String baseUrl, String browser, String seleniumHost, int seleniumPort )
- throws Exception
- {
- this.baseUrl = baseUrl;
-
- if ( getSelenium() == null )
- {
- DefaultSelenium s = new DefaultSelenium( seleniumHost, seleniumPort, browser, baseUrl );
- s.start();
- s.setTimeout( maxWaitTimeInMs );
- selenium.set( s );
- }
- }
-
- public static Selenium getSelenium()
- {
- return selenium == null ? null : selenium.get();
- }
-
- protected String getProperty( String key )
- {
- return p.getProperty( key );
- }
-
- protected String getEscapeProperty( String key )
- {
- InputStream input = this.getClass().getClassLoader().getResourceAsStream( "testng.properties" );
- String value = null;
- List<String> lines;
- try
- {
- lines = IOUtils.readLines( input );
- }
- catch ( IOException e )
- {
- lines = new ArrayList<String>();
- }
- for ( String l : lines )
- {
- if ( l != null && l.startsWith( key ) )
- {
- int indexSeparator = l.indexOf( PROPERTIES_SEPARATOR );
- value = l.substring( indexSeparator + 1 ).trim();
- break;
- }
- }
- return value;
- }
-
-
- /**
- * Close selenium session. Called from AfterSuite method of sub-class
- */
- public void close()
- throws Exception
- {
- if ( getSelenium() != null )
- {
- getSelenium().stop();
- selenium.set( null );
- }
- }
-
- // *******************************************************
- // Auxiliar methods. This method help us and simplify test.
- // *******************************************************
-
- public void assertFieldValue( String fieldValue, String fieldName )
- {
- assertElementPresent( fieldName );
- Assert.assertEquals( fieldValue, getSelenium().getValue( fieldName ) );
- }
-
- public void assertPage( String title )
- {
- Assert.assertEquals( getTitle(), title );
- }
-
- public String getTitle()
- {
- // Collapse spaces
- return getSelenium().getTitle().replaceAll( "[ \n\r]+", " " );
- }
-
- public String getHtmlContent()
- {
- return getSelenium().getHtmlSource();
- }
-
- public String getText( String locator )
- {
- return getSelenium().getText( locator );
- }
-
- public void assertTextPresent( String text )
- {
- Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." );
- }
-
- public void assertTextNotPresent( String text )
- {
- Assert.assertFalse( getSelenium().isTextPresent( text ), "'" + text + "' is present." );
- }
-
- public void assertElementPresent( String elementLocator )
- {
- Assert.assertTrue( isElementPresent( elementLocator ), "'" + elementLocator + "' isn't present." );
- }
-
- public void assertElementNotPresent( String elementLocator )
- {
- Assert.assertFalse( isElementPresent( elementLocator ), "'" + elementLocator + "' is present." );
- }
-
- public void assertLinkPresent( String text )
- {
- Assert.assertTrue( isElementPresent( "link=" + text ), "The link '" + text + "' isn't present." );
- }
-
- public void assertLinkNotPresent( String text )
- {
- Assert.assertFalse( isElementPresent( "link=" + text ), "The link('" + text + "' is present." );
- }
-
- public void assertImgWithAlt( String alt )
- {
- assertElementPresent( "/¯img[@alt='" + alt + "']" );
- }
-
- public void assertImgWithAltAtRowCol( boolean isALink, String alt, int row, int column )
- {
- String locator = "//tr[" + row + "]/td[" + column + "]/";
- locator += isALink ? "a/" : "";
- locator += "img[@alt='" + alt + "']";
-
- assertElementPresent( locator );
- }
-
- public void assertCellValueFromTable( String expected, String tableElement, int row, int column )
- {
- Assert.assertEquals( expected, getCellValueFromTable( tableElement, row, column ) );
- }
-
- public boolean isTextPresent( String text )
- {
- return getSelenium().isTextPresent( text );
- }
-
- public boolean isLinkPresent( String text )
- {
- return isElementPresent( "link=" + text );
- }
-
- public boolean isElementPresent( String locator )
- {
- return getSelenium().isElementPresent( locator );
- }
-
- public void waitPage()
- {
- getSelenium().waitForPageToLoad( maxWaitTimeInMs );
- }
-
- public String getFieldValue( String fieldName )
- {
- return getSelenium().getValue( fieldName );
- }
-
- public String getCellValueFromTable( String tableElement, int row, int column )
- {
- return getSelenium().getTable( tableElement + "." + row + "." + column );
- }
-
- public void selectValue( String locator, String value )
- {
- getSelenium().select( locator, "label=" + value );
- }
-
- public void assertOptionPresent( String selectField, String[] options )
- {
- assertElementPresent( selectField );
- String[] optionsPresent = getSelenium().getSelectOptions( selectField );
- List<String> expected = Arrays.asList( options );
- List<String> present = Arrays.asList( optionsPresent );
- Assert.assertTrue( present.containsAll( expected ), "Options expected are not included in present options" );
- }
-
- public void assertSelectedValue( String value, String fieldName )
- {
- assertElementPresent( fieldName );
- String optionsPresent = getSelenium().getSelectedLabel( value );
- Assert.assertEquals( optionsPresent, value );
- }
-
- public void submit()
- {
- clickLinkWithXPath( "//input[@type='submit']" );
- }
-
- public void assertButtonWithValuePresent( String text )
- {
- Assert.assertTrue( isButtonWithValuePresent( text ), "'" + text + "' button isn't present" );
- }
-
- public void assertButtonWithIdPresent( String id )
- {
- Assert.assertTrue( isButtonWithIdPresent( id ), "'Button with id =" + id + "' isn't present" );
- }
-
- public void assertButtonWithValueNotPresent( String text )
- {
- Assert.assertFalse( isButtonWithValuePresent( text ), "'" + text + "' button is present" );
- }
-
- public boolean isButtonWithValuePresent( String text )
- {
- return isElementPresent( "//button[@value='" + text + "']" )
- || isElementPresent( "//input[@value='" + text + "']" );
- }
-
- public boolean isButtonWithIdPresent( String text )
- {
- return isElementPresent( "//button[@id='" + text + "']" ) || isElementPresent( "//input[@id='" + text + "']" );
- }
-
- public void clickButtonWithValue( String text )
- {
- clickButtonWithValue( text, true );
- }
-
- public void clickButtonWithValue( String text, boolean wait )
- {
- assertButtonWithValuePresent( text );
-
- if ( isElementPresent( "//button[@value='" + text + "']" ) )
- {
- clickLinkWithXPath( "//button[@value='" + text + "']", wait );
- }
- else
- {
- clickLinkWithXPath( "//input[@value='" + text + "']", wait );
- }
- }
-
- public void clickSubmitWithLocator( String locator )
- {
- clickLinkWithLocator( locator );
- }
-
- public void clickSubmitWithLocator( String locator, boolean wait )
- {
- clickLinkWithLocator( locator, wait );
- }
-
- public void clickImgWithAlt( String alt )
- {
- clickLinkWithLocator( "//img[@alt='" + alt + "']" );
- }
-
- public void clickLinkWithText( String text )
- {
- clickLinkWithText( text, true );
- }
-
- public void clickLinkWithText( String text, boolean wait )
- {
- clickLinkWithLocator( "link=" + text, wait );
- }
-
- public void clickLinkWithXPath( String xpath )
- {
- clickLinkWithXPath( xpath, true );
- }
-
- public void clickLinkWithXPath( String xpath, boolean wait )
- {
- clickLinkWithLocator( "xpath=" + xpath, wait );
- }
-
- public void clickLinkWithLocator( String locator )
- {
- clickLinkWithLocator( locator, true );
- }
-
- public void clickLinkWithLocator( String locator, boolean wait )
- {
- assertElementPresent( locator );
- getSelenium().click( locator );
- if ( wait )
- {
- waitPage();
- }
- }
-
- public void setFieldValues( Map<String, String> fieldMap )
- {
- Map.Entry<String, String> entry;
-
- for ( Iterator<Entry<String, String>> entries = fieldMap.entrySet().iterator(); entries.hasNext(); )
- {
- entry = entries.next();
-
- getSelenium().type( entry.getKey(), entry.getValue() );
- }
- }
-
- public void setFieldValue( String fieldName, String value )
- {
- getSelenium().type( fieldName, value );
- }
-
- public void checkField( String locator )
- {
- getSelenium().check( locator );
- }
-
- public void uncheckField( String locator )
- {
- getSelenium().uncheck( locator );
- }
-
- public boolean isChecked( String locator )
- {
- return getSelenium().isChecked( locator );
- }
-
- public void assertIsChecked( String locator )
- {
- Assert.assertTrue( getSelenium().isChecked( locator ) );
- }
-
- public void assertIsNotChecked( String locator )
- {
- Assert.assertFalse( getSelenium().isChecked( locator ) );
- }
-
- public void assertXpathCount(String locator, int expectedCount)
- {
- Assert.assertEquals( getSelenium().getXpathCount(locator).intValue(), expectedCount );
- }
-
- public void assertElementValue(String locator, String expectedValue)
- {
- Assert.assertEquals(getSelenium().getValue(locator), expectedValue);
- }
-}
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
- <version>1.0-alpha-4</version>
+ <version>1.3.1</version>
<executions>
<execution>
<goals>
</dependency>
</dependencies>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>2.5</version>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-3</version>
+ <version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
- <version>1.0-beta-2</version>
+ <version>1.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
- <version>2.3</version>
+ <version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
- <version>1.1</version>
+ <version>1.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
- <version>2.2</version>
+ <version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
- <version>2.2</version>
+ <version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
- <version>2.0-beta-9</version>
+ <version>2.4.1</version>
<configuration>
<tagBase>https://svn.apache.org/repos/asf/archiva/tags</tagBase>
<useReleaseProfile>false</useReleaseProfile>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
- <version>2.2</version>
+ <version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.4.2</version>
+ <version>2.16</version>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
- <plugin>
- <artifactId>maven-idea-plugin</artifactId>
- <configuration>
- <jdkLevel>1.5</jdkLevel>
- </configuration>
- </plugin>
</plugins>
</pluginManagement>
</build>