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." );
}
{
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" );
}
@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()
{
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()
*/
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()
{
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 );
{
this.repoGroupId = repoGroupId;
}
+
+ public void setCancel( String cancel )
+ {
+ this.cancel = StringUtils.isNotBlank( cancel );
+ }
}
<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>