add test for lock/unlock user rest methods
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1386870 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
71fc853d38
commit
6e3294a072
|
@ -874,7 +874,7 @@ public class DefaultUserService
|
||||||
throws RedbackServiceException
|
throws RedbackServiceException
|
||||||
{
|
{
|
||||||
User user = getUser( username );
|
User user = getUser( username );
|
||||||
if ( user == null )
|
if ( user != null )
|
||||||
{
|
{
|
||||||
user.setLocked( false );
|
user.setLocked( false );
|
||||||
updateUser( user );
|
updateUser( user );
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class UserServiceTest
|
||||||
assertFalse( users.isEmpty() );
|
assertFalse( users.isEmpty() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test( expected = ServerWebApplicationException.class )
|
@Test (expected = ServerWebApplicationException.class)
|
||||||
public void getUsersWithoutAuthz()
|
public void getUsersWithoutAuthz()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -379,6 +379,45 @@ public class UserServiceTest
|
||||||
getUserService( authorizationHeader ).deleteUser( "toto" );
|
getUserService( authorizationHeader ).deleteUser( "toto" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void lockUnlockUser()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
// START SNIPPET: create-user
|
||||||
|
User user = new User( "toto", "toto the king", "toto@toto.fr", false, false );
|
||||||
|
user.setPassword( "foo123" );
|
||||||
|
user.setPermanent( false );
|
||||||
|
user.setPasswordChangeRequired( false );
|
||||||
|
user.setLocked( false );
|
||||||
|
user.setValidated( true );
|
||||||
|
UserService userService = getUserService( authorizationHeader );
|
||||||
|
userService.createUser( user );
|
||||||
|
// END SNIPPET: create-user
|
||||||
|
user = userService.getUser( "toto" );
|
||||||
|
assertNotNull( user );
|
||||||
|
assertEquals( "toto the king", user.getFullName() );
|
||||||
|
assertEquals( "toto@toto.fr", user.getEmail() );
|
||||||
|
getLoginService( encode( "toto", "foo123" ) ).pingWithAutz();
|
||||||
|
|
||||||
|
userService.lockUser( "toto" );
|
||||||
|
|
||||||
|
assertTrue( userService.getUser( "toto" ).isLocked() );
|
||||||
|
|
||||||
|
userService.unlockUser( "toto" );
|
||||||
|
|
||||||
|
assertFalse( userService.getUser( "toto" ).isLocked() );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
getUserService( authorizationHeader ).deleteUser( "toto" );
|
||||||
|
getUserService( authorizationHeader ).removeFromCache( "toto" );
|
||||||
|
assertNull( getUserService( authorizationHeader ).getUser( "toto" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void guestUserCreate()
|
public void guestUserCreate()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue