diff options
author | Brett Porter <brett@apache.org> | 2014-02-01 23:34:03 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2014-02-01 23:34:03 +0000 |
commit | 4eb2fee18094a80a25e7ea55eb69c15752378cee (patch) | |
tree | 45619c6404e8122d52eb31ec1001250d20d9126d | |
parent | 0ab449c92a7228ad04560c1823c8cc051542e874 (diff) | |
download | archiva-4eb2fee18094a80a25e7ea55eb69c15752378cee.tar.gz archiva-4eb2fee18094a80a25e7ea55eb69c15752378cee.zip |
update repository group deletion so cancel works after Struts upgrade
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-1.3.x@1563511 13f79535-47bb-0310-9956-ffa450edef68
5 files changed, 50 insertions, 23 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/CSRFSecurityTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/CSRFSecurityTest.java index 58d63757d..afa3130ed 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/CSRFSecurityTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/CSRFSecurityTest.java @@ -65,7 +65,7 @@ public class CSRFSecurityTest public void testCSRFDeleteRepositoryGroup() { getSelenium().open( baseUrl ); - getSelenium().open( baseUrl + "/admin/deleteRepositoryGroup.action?repoGroupId=test&method%3Adelete=Confirm" ); + getSelenium().open( baseUrl + "/admin/deleteRepositoryGroup.action?repoGroupId=test" ); assertTextPresent( "Security Alert - Invalid Token Found" ); assertTextPresent( "Possible CSRF attack detected! Invalid token found in the request." ); } diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/VirtualRepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/VirtualRepositoryTest.java index 1e14bee55..b42fd0b2b 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/VirtualRepositoryTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/VirtualRepositoryTest.java @@ -45,10 +45,15 @@ public class VirtualRepositoryTest { addRepositoryGroup( "testing" ); //assertAddedRepositoryLink( "testing" ); - Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[1]/p[1]" ), "testing" ); - } - - @Test(dependsOnMethods = { "testAddRepositoryGroupValidValue" } ) + assertRepositoryGroup( "testing" ); + } + + private void assertRepositoryGroup( String group ) + { + Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[1]/p[1]" ), group ); + } + + @Test(dependsOnMethods = { "testAddRepositoryGroupValidValue" } ) public void testAddRepositoryToRepositoryGroup() { addRepositoryToRepositoryGroup( "testing", "internal" ); @@ -68,13 +73,23 @@ public class VirtualRepositoryTest } @Test(dependsOnMethods = { "testDeleteRepositoryOfRepositoryGroup" } ) - public void testDeleteRepositoryGroup() + public void testCancelDeleteRepositoryGroup() { assertRepositoryGroupsPage(); + attemptDeleteRepositoryGroup( "testing" ); + clickButtonWithValue( "Cancel" ); + assertTextNotPresent( "No Repository Groups Defined." ); + assertRepositoryGroup( "testing" ); + } + + @Test(dependsOnMethods = { "testCancelDeleteRepositoryGroup" } ) + public void testDeleteRepositoryGroup() + { + assertRepositoryGroupsPage(); deleteRepositoryGroup( "testing" ); assertTextPresent( "No Repository Groups Defined." ); } - + /*@Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } ) public void testCheckRepositoryGroup() { diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java index 52726cde6..c155c0308 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java @@ -116,13 +116,18 @@ public abstract class AbstractRepositoryTest public void deleteRepositoryGroup( String repositoryName ) { - getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" ); - waitPage(); - assertDeleteRepositoryGroupPage( repositoryName ); + attemptDeleteRepositoryGroup( repositoryName ); clickButtonWithValue( "Confirm" ); } - - /////////////////////////////// + + protected void attemptDeleteRepositoryGroup( String repositoryName ) + { + getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" ); + waitPage(); + assertDeleteRepositoryGroupPage( repositoryName ); + } + + /////////////////////////////// // proxy connectors /////////////////////////////// public void goToProxyConnectorsPage() diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java index 0c3aad84a..7a3545402 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java @@ -34,19 +34,12 @@ import org.apache.maven.archiva.repository.audit.AuditEvent; */ public class DeleteRepositoryGroupAction extends AbstractRepositoriesAdminAction - implements Preparable { private RepositoryGroupConfiguration repositoryGroup; private String repoGroupId; - - public void prepare() - { - if ( StringUtils.isNotBlank( repoGroupId ) ) - { - this.repositoryGroup = archivaConfiguration.getConfiguration().findRepositoryGroupById( repoGroupId ); - } - } + + private boolean cancel; public String confirmDelete() { @@ -55,12 +48,21 @@ public class DeleteRepositoryGroupAction addActionError( "Unable to delete repository group: repository id was blank." ); return ERROR; } + else + { + this.repositoryGroup = archivaConfiguration.getConfiguration().findRepositoryGroupById( repoGroupId ); + } return INPUT; } public String delete() { + if ( cancel ) + { + return SUCCESS; + } + Configuration config = archivaConfiguration.getConfiguration(); RepositoryGroupConfiguration group = config.findRepositoryGroupById( repoGroupId ); @@ -94,4 +96,9 @@ public class DeleteRepositoryGroupAction { this.repoGroupId = repoGroupId; } + + public void setCancel( String cancel ) + { + this.cancel = StringUtils.isNotBlank( cancel ); + } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteRepositoryGroup.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteRepositoryGroup.jsp index 69bbd0db4..57fc677db 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteRepositoryGroup.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteRepositoryGroup.jsp @@ -57,8 +57,8 @@ <s:hidden name="repoGroupId"/> <div class="buttons"> <s:token/> - <s:submit value="Confirm" method="delete"/> - <s:submit value="Cancel" method="execute"/> + <s:submit value="Confirm" /> + <s:submit value="Cancel" name="cancel"/> </div> </s:form> </div> |