Browse Source

allow user tests to be re-run

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-1.3.x@1561917 13f79535-47bb-0310-9956-ffa450edef68
tags/archiva-1.3.7
Brett Porter 10 years ago
parent
commit
228af298a1

+ 1
- 1
archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/AuditLogsReportTest.java View File

@@ -147,8 +147,8 @@ public class AuditLogsReportTest
assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + version +
"' was successfully deployed to repository '" + repo + "'" );

goToUserManagementPage();
String username = "testAuditUser";
goToUserManagementPage();
if ( !isLinkPresent( username ) )
{
createUserWithRole( username, "Repository Manager - internal", getUserEmail(), getUserRolePassword() );

+ 53
- 35
archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/UserRolesTest.java View File

@@ -20,11 +20,12 @@ package org.apache.archiva.web.test;
*/

import org.apache.archiva.web.test.parent.AbstractArchivaTest;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

@Test( groups = { "userroles" })
public class UserRolesTest
public class UserRolesTest
extends AbstractArchivaTest
{
@BeforeTest
@@ -33,23 +34,40 @@ public class UserRolesTest
loginAsAdmin();
}

@AfterSuite
public void tearDown()
{
goToUserManagementPage();
String[] usernameProperties =
new String[]{ "GUEST_USERNAME", "REGISTERED_USERNAME", "SYSAD_USERNAME", "USERADMIN_USERNAME",
"GLOBALREPOMANAGER_USERNAME", "GLOBALREPOOBSERVER_USERNAME", "REPOMANAGER_INTERNAL_USERNAME",
"REPOOBSERVER_INTERNAL_USERNAME" };
for ( String p : usernameProperties )
{
String username = getProperty( p );

if ( isLinkPresent( username ) )
{
deleteUser( username );
}
}
}

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() );
deleteUser( username );
}

@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" );
@@ -59,26 +77,26 @@ public class UserRolesTest
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( username );
clickLinkWithText( "Edit Roles" );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
@@ -86,24 +104,24 @@ public class UserRolesTest
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" );
@@ -113,24 +131,24 @@ public class UserRolesTest
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" );
@@ -140,24 +158,24 @@ public class UserRolesTest
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" );
@@ -167,12 +185,12 @@ public class UserRolesTest
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();
@@ -184,7 +202,7 @@ public class UserRolesTest
{
username = getProperty("GLOBALREPOOBSERVER_USERNAME");
fullname = getProperty("GLOBALREPOOBSERVER_FULLNAME");
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
clickLinkWithText( username );
clickLinkWithText( "Edit Roles" );
@@ -194,18 +212,18 @@ public class UserRolesTest
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()
{
@@ -217,12 +235,12 @@ public class UserRolesTest
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();
@@ -255,7 +273,7 @@ public class UserRolesTest
clickLinkWithText("Logout");
login( getAdminUsername() , getAdminPassword() );
}*/
@Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
public void testUserWithRepoObserverInternalRole()
{
@@ -267,12 +285,12 @@ public class UserRolesTest
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();

+ 3
- 10
archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java View File

@@ -275,19 +275,12 @@ public abstract class AbstractArchivaTest
}
}

public void deleteUser( String userName, String fullName, String emailAdd )
public void deleteUser( String userName )
{
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" );
clickLinkWithXPath( "//tr[.//a[text()='" + userName + "']]/td/a[@title='delete user']" );
assertDeleteUserPage( userName );
submit();
assertElementNotPresent( XPathExpressionUtil.getTableRow( columnValues ) );
assertLinkNotPresent( userName );
}

public void login( String username, String password )

Loading…
Cancel
Save