]> source.dussan.org Git - archiva.git/commitdiff
update repository group deletion so cancel works after Struts upgrade
authorBrett Porter <brett@apache.org>
Sat, 1 Feb 2014 23:34:03 +0000 (23:34 +0000)
committerBrett Porter <brett@apache.org>
Sat, 1 Feb 2014 23:34:03 +0000 (23:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-1.3.x@1563511 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/CSRFSecurityTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/VirtualRepositoryTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteRepositoryGroup.jsp

index 58d63757de1834e48bde4780f06791d20af54017..afa3130ed56fd12f1ac6549ff409dbbcdc602f40 100644 (file)
@@ -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." );
     }
index 1e14bee559847a37e984363026f6ba2630140b82..b42fd0b2b55630621f2a6ef2a59830f2bcc583f1 100644 (file)
@@ -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()
        {
index 52726cde6dece51e5076c1afbcff3bb2baf81881..c155c03088264ab161acbe4f14a87efe7463a304 100644 (file)
@@ -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()
index 0c3aad84a1bbc6d7198d160fecaef6bb9fcf2cb7..7a354540227d56ebe229a0490839937e216ab560 100644 (file)
@@ -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 );
+    }
 }
index 69bbd0db42b7b62ab6efe0410fab4f6f19edded5..57fc677dbd2bc540f87269dd12156fed8cb07538 100644 (file)
@@ -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>