Switching to snake case for v2 REST service attributes
This commit is contained in:
parent
292e0defcb
commit
bbf073c7da
|
@ -22,6 +22,7 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.core.json.JsonWriteFeature;
|
import com.fasterxml.jackson.core.json.JsonWriteFeature;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
@ -48,8 +49,9 @@ public class JacksonJsonConfigurator
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public JacksonJsonConfigurator( @Named( "redbackJacksonJsonMapper" ) ObjectMapper objectMapper,
|
public JacksonJsonConfigurator( @Named( "redbackJacksonJsonMapper" ) ObjectMapper objectMapper,
|
||||||
@Name( "redbackJacksonXMLMapper" ) XmlMapper xmlMapper)
|
@Name( "redbackJacksonXMLMapper" ) XmlMapper xmlMapper, @Named( "v2.redbackJacksonJsonMapper" ) ObjectMapper objectMapperV2 )
|
||||||
{
|
{
|
||||||
|
|
||||||
log.info( "configure jackson ObjectMapper" );
|
log.info( "configure jackson ObjectMapper" );
|
||||||
objectMapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES );
|
objectMapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES );
|
||||||
objectMapper.enable( DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL );
|
objectMapper.enable( DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL );
|
||||||
|
@ -59,6 +61,16 @@ public class JacksonJsonConfigurator
|
||||||
objectMapper.registerModule( new JavaTimeModule( ) );
|
objectMapper.registerModule( new JavaTimeModule( ) );
|
||||||
objectMapper.setDateFormat( new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ" ) );
|
objectMapper.setDateFormat( new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ" ) );
|
||||||
|
|
||||||
|
objectMapperV2.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES );
|
||||||
|
objectMapperV2.enable( DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL );
|
||||||
|
objectMapperV2.enable( DeserializationFeature.USE_LONG_FOR_INTS );
|
||||||
|
objectMapperV2.setAnnotationIntrospector( new JaxbAnnotationIntrospector( objectMapper.getTypeFactory( ) ) );
|
||||||
|
objectMapperV2.findAndRegisterModules( );
|
||||||
|
objectMapperV2.registerModule( new JavaTimeModule( ) );
|
||||||
|
objectMapperV2.setDateFormat( new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ" ) );
|
||||||
|
objectMapperV2.setPropertyNamingStrategy( PropertyNamingStrategy.SNAKE_CASE );
|
||||||
|
|
||||||
|
|
||||||
xmlMapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES );
|
xmlMapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES );
|
||||||
xmlMapper.setAnnotationIntrospector( new JaxbAnnotationIntrospector( xmlMapper.getTypeFactory( ) ) );
|
xmlMapper.setAnnotationIntrospector( new JaxbAnnotationIntrospector( xmlMapper.getTypeFactory( ) ) );
|
||||||
|
|
||||||
|
|
|
@ -44,19 +44,19 @@ import org.apache.archiva.redback.rbac.RbacManagerException;
|
||||||
import org.apache.archiva.redback.rbac.UserAssignment;
|
import org.apache.archiva.redback.rbac.UserAssignment;
|
||||||
import org.apache.archiva.redback.rest.api.MessageKeys;
|
import org.apache.archiva.redback.rest.api.MessageKeys;
|
||||||
import org.apache.archiva.redback.rest.api.model.ActionStatus;
|
import org.apache.archiva.redback.rest.api.model.ActionStatus;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.AvailabilityStatus;
|
|
||||||
import org.apache.archiva.redback.rest.api.model.ErrorMessage;
|
import org.apache.archiva.redback.rest.api.model.ErrorMessage;
|
||||||
|
import org.apache.archiva.redback.rest.api.model.v2.AvailabilityStatus;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.Operation;
|
import org.apache.archiva.redback.rest.api.model.v2.Operation;
|
||||||
|
import org.apache.archiva.redback.rest.api.model.v2.PagedResult;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.Permission;
|
import org.apache.archiva.redback.rest.api.model.v2.Permission;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.SelfUserData;
|
import org.apache.archiva.redback.rest.api.model.v2.PingResult;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.RegistrationKey;
|
import org.apache.archiva.redback.rest.api.model.v2.RegistrationKey;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.Resource;
|
import org.apache.archiva.redback.rest.api.model.v2.Resource;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.VerificationStatus;
|
import org.apache.archiva.redback.rest.api.model.v2.SelfUserData;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.PagedResult;
|
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.PingResult;
|
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.User;
|
import org.apache.archiva.redback.rest.api.model.v2.User;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.UserInfo;
|
import org.apache.archiva.redback.rest.api.model.v2.UserInfo;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.UserRegistrationRequest;
|
import org.apache.archiva.redback.rest.api.model.v2.UserRegistrationRequest;
|
||||||
|
import org.apache.archiva.redback.rest.api.model.v2.VerificationStatus;
|
||||||
import org.apache.archiva.redback.rest.api.services.RedbackServiceException;
|
import org.apache.archiva.redback.rest.api.services.RedbackServiceException;
|
||||||
import org.apache.archiva.redback.rest.api.services.v2.UserService;
|
import org.apache.archiva.redback.rest.api.services.v2.UserService;
|
||||||
import org.apache.archiva.redback.rest.services.RedbackAuthenticationThreadLocal;
|
import org.apache.archiva.redback.rest.services.RedbackAuthenticationThreadLocal;
|
||||||
|
@ -70,7 +70,6 @@ import org.apache.archiva.redback.system.SecuritySystem;
|
||||||
import org.apache.archiva.redback.users.UserManager;
|
import org.apache.archiva.redback.users.UserManager;
|
||||||
import org.apache.archiva.redback.users.UserManagerException;
|
import org.apache.archiva.redback.users.UserManagerException;
|
||||||
import org.apache.archiva.redback.users.UserNotFoundException;
|
import org.apache.archiva.redback.users.UserNotFoundException;
|
||||||
import org.apache.archiva.redback.users.UserQuery;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -90,15 +89,12 @@ import java.security.Principal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
@ -114,20 +110,28 @@ public class DefaultUserService
|
||||||
private static final String VALID_USERNAME_CHARS = "[a-zA-Z_0-9\\-.@]*";
|
private static final String VALID_USERNAME_CHARS = "[a-zA-Z_0-9\\-.@]*";
|
||||||
private static final String[] INVALID_CREATE_USER_NAMES = {"admin", "guest", "me"};
|
private static final String[] INVALID_CREATE_USER_NAMES = {"admin", "guest", "me"};
|
||||||
|
|
||||||
private static final String[] DEFAULT_SEARCH_FIELDS = {"user_id", "fullName", "email"};
|
private static final String[] DEFAULT_SEARCH_FIELDS = {"user_id", "full_name", "email"};
|
||||||
private static final Map<String, BiPredicate<String, org.apache.archiva.redback.users.User>> FILTER_MAP = new HashMap<>( );
|
private static final Map<String, BiPredicate<String, org.apache.archiva.redback.users.User>> FILTER_MAP = new HashMap<>( );
|
||||||
private static final Map<String, Comparator<org.apache.archiva.redback.users.User>> ORDER_MAP = new HashMap<>( );
|
private static final Map<String, Comparator<org.apache.archiva.redback.users.User>> ORDER_MAP = new HashMap<>( );
|
||||||
static {
|
|
||||||
ORDER_MAP.put( "id", Comparator.comparing( org.apache.archiva.redback.users.User::getId ) );
|
static
|
||||||
ORDER_MAP.put( "user_id", Comparator.comparing( org.apache.archiva.redback.users.User::getUsername ) );
|
{
|
||||||
ORDER_MAP.put( "fullName", Comparator.comparing( org.apache.archiva.redback.users.User::getFullName) );
|
// The simple Comparator.comparing(attribute) is not null safe
|
||||||
ORDER_MAP.put( "email", Comparator.comparing( org.apache.archiva.redback.users.User::getEmail) );
|
// As there are attributes that may have a null value, we have to use a comparator with nullsLast(naturalOrder)
|
||||||
ORDER_MAP.put( "created", Comparator.comparing( org.apache.archiva.redback.users.User::getAccountCreationDate) );
|
// and the wrapping Comparator.nullsLast(Comparator.comparing(attribute)) does not work, because the attribute is not checked by the nullsLast-Comparator
|
||||||
ORDER_MAP.put( "lastLogin", Comparator.comparing( org.apache.archiva.redback.users.User::getLastLoginDate) );
|
ORDER_MAP.put( "id", Comparator.comparing( org.apache.archiva.redback.users.User::getId, Comparator.nullsLast( Comparator.naturalOrder( ) ) ) );
|
||||||
ORDER_MAP.put( "validated", Comparator.comparing( org.apache.archiva.redback.users.User::isValidated) );
|
ORDER_MAP.put( "user_id", Comparator.comparing( org.apache.archiva.redback.users.User::getUsername, Comparator.nullsLast( Comparator.naturalOrder( ) ) ) );
|
||||||
|
ORDER_MAP.put( "full_name", Comparator.comparing( org.apache.archiva.redback.users.User::getFullName, Comparator.nullsLast( Comparator.naturalOrder( ) ) ) );
|
||||||
|
ORDER_MAP.put( "email", Comparator.comparing( org.apache.archiva.redback.users.User::getEmail, Comparator.nullsLast( Comparator.naturalOrder( ) ) ) );
|
||||||
|
ORDER_MAP.put( "created", Comparator.comparing( org.apache.archiva.redback.users.User::getAccountCreationDate, Comparator.nullsLast( Comparator.naturalOrder( ) ) ) );
|
||||||
|
ORDER_MAP.put( "last_login", Comparator.comparing( org.apache.archiva.redback.users.User::getLastLoginDate, Comparator.nullsLast( Comparator.naturalOrder( ) ) ) );
|
||||||
|
ORDER_MAP.put( "validated", Comparator.comparing( org.apache.archiva.redback.users.User::isValidated, Comparator.nullsLast( Comparator.naturalOrder( ) ) ) );
|
||||||
|
ORDER_MAP.put( "locked", Comparator.comparing( org.apache.archiva.redback.users.User::isLocked, Comparator.nullsLast( Comparator.naturalOrder( ) ) ) );
|
||||||
|
ORDER_MAP.put( "password_change_required", Comparator.comparing( org.apache.archiva.redback.users.User::isPasswordChangeRequired, Comparator.nullsLast( Comparator.naturalOrder( ) ) ) );
|
||||||
|
ORDER_MAP.put( "last_password_change", Comparator.comparing( org.apache.archiva.redback.users.User::getLastPasswordChange, Comparator.nullsLast( Comparator.naturalOrder( ) ) ) );
|
||||||
|
|
||||||
FILTER_MAP.put( "user_id", ( String q, org.apache.archiva.redback.users.User u ) -> StringUtils.containsIgnoreCase( u.getUsername( ), q ) );
|
FILTER_MAP.put( "user_id", ( String q, org.apache.archiva.redback.users.User u ) -> StringUtils.containsIgnoreCase( u.getUsername( ), q ) );
|
||||||
FILTER_MAP.put( "fullName", ( String q, org.apache.archiva.redback.users.User u ) -> StringUtils.containsIgnoreCase( u.getFullName( ), q ) );
|
FILTER_MAP.put( "full_name", ( String q, org.apache.archiva.redback.users.User u ) -> StringUtils.containsIgnoreCase( u.getFullName( ), q ) );
|
||||||
FILTER_MAP.put( "email", ( String q, org.apache.archiva.redback.users.User u ) -> StringUtils.containsIgnoreCase( u.getEmail( ), q ) );
|
FILTER_MAP.put( "email", ( String q, org.apache.archiva.redback.users.User u ) -> StringUtils.containsIgnoreCase( u.getEmail( ), q ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,10 +203,13 @@ public class DefaultUserService
|
||||||
this.securitySystem = securitySystem;
|
this.securitySystem = securitySystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
RedbackPrincipal getPrincipal() {
|
RedbackPrincipal getPrincipal( )
|
||||||
if (this.securityContext!=null) {
|
{
|
||||||
|
if ( this.securityContext != null )
|
||||||
|
{
|
||||||
Principal pri = this.securityContext.getUserPrincipal( );
|
Principal pri = this.securityContext.getUserPrincipal( );
|
||||||
if (pri!=null && pri instanceof RedbackPrincipal) {
|
if ( pri != null && pri instanceof RedbackPrincipal )
|
||||||
|
{
|
||||||
return (RedbackPrincipal) pri;
|
return (RedbackPrincipal) pri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,7 +350,8 @@ public class DefaultUserService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ("guest".equals(userId)) {
|
if ( "guest".equals( userId ) )
|
||||||
|
{
|
||||||
return getRestUser( userManager.getGuestUser( ) );
|
return getRestUser( userManager.getGuestUser( ) );
|
||||||
}
|
}
|
||||||
org.apache.archiva.redback.users.User user = userManager.findUser( userId );
|
org.apache.archiva.redback.users.User user = userManager.findUser( userId );
|
||||||
|
@ -359,30 +367,38 @@ public class DefaultUserService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Comparator<org.apache.archiva.redback.users.User> getAttributeComparator(String attributeName) {
|
Comparator<org.apache.archiva.redback.users.User> getAttributeComparator( String attributeName )
|
||||||
|
{
|
||||||
return ORDER_MAP.get( attributeName );
|
return ORDER_MAP.get( attributeName );
|
||||||
}
|
}
|
||||||
|
|
||||||
Comparator<org.apache.archiva.redback.users.User> getComparator( List<String> orderBy, boolean ascending) {
|
Comparator<org.apache.archiva.redback.users.User> getComparator( List<String> orderBy, boolean ascending )
|
||||||
|
{
|
||||||
if ( ascending )
|
if ( ascending )
|
||||||
{
|
{
|
||||||
return orderBy.stream( ).map( ( String name ) -> getAttributeComparator( name ) ).filter( Objects::nonNull ).reduce( Comparator::thenComparing ).get( );
|
return orderBy.stream( ).map( ( String name ) -> getAttributeComparator( name ) ).filter( Objects::nonNull ).reduce( Comparator::thenComparing ).get( );
|
||||||
} else {
|
}
|
||||||
return orderBy.stream( ).map( ( String name ) -> getAttributeComparator( name ).reversed() ).filter( Objects::nonNull ).reduce( Comparator::thenComparing ).get( );
|
else
|
||||||
|
{
|
||||||
|
return orderBy.stream( ).map( ( String name ) -> getAttributeComparator( name ) == null ? null : getAttributeComparator( name ).reversed( ) ).filter( Objects::nonNull ).reduce( Comparator::thenComparing ).get( );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Predicate<org.apache.archiva.redback.users.User> getFilter(final String attribute, final String queryToken) {
|
static Predicate<org.apache.archiva.redback.users.User> getFilter( final String attribute, final String queryToken )
|
||||||
|
{
|
||||||
if ( FILTER_MAP.containsKey( attribute ) )
|
if ( FILTER_MAP.containsKey( attribute ) )
|
||||||
{
|
{
|
||||||
return ( org.apache.archiva.redback.users.User u ) -> FILTER_MAP.get( attribute ).test( queryToken, u );
|
return ( org.apache.archiva.redback.users.User u ) -> FILTER_MAP.get( attribute ).test( queryToken, u );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return Arrays.stream( DEFAULT_SEARCH_FIELDS )
|
return Arrays.stream( DEFAULT_SEARCH_FIELDS )
|
||||||
.map( att -> getFilter( att, queryToken ) ).reduce( Predicate::or ).get( );
|
.map( att -> getFilter( att, queryToken ) ).reduce( Predicate::or ).get( );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate<org.apache.archiva.redback.users.User> getUserFilter(String queryTerms) {
|
Predicate<org.apache.archiva.redback.users.User> getUserFilter( String queryTerms )
|
||||||
|
{
|
||||||
return Arrays.stream( queryTerms.split( "\\s+" ) )
|
return Arrays.stream( queryTerms.split( "\\s+" ) )
|
||||||
.map( s -> {
|
.map( s -> {
|
||||||
if ( s.contains( ":" ) )
|
if ( s.contains( ":" ) )
|
||||||
|
@ -431,7 +447,8 @@ public class DefaultUserService
|
||||||
throws RedbackServiceException
|
throws RedbackServiceException
|
||||||
{
|
{
|
||||||
RedbackPrincipal principal = getPrincipal( );
|
RedbackPrincipal principal = getPrincipal( );
|
||||||
if (principal==null) {
|
if ( principal == null )
|
||||||
|
{
|
||||||
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_UNAUTHORIZED_REQUEST ), 401 );
|
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_UNAUTHORIZED_REQUEST ), 401 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +510,8 @@ public class DefaultUserService
|
||||||
throws RedbackServiceException
|
throws RedbackServiceException
|
||||||
{
|
{
|
||||||
RedbackPrincipal principal = getPrincipal( );
|
RedbackPrincipal principal = getPrincipal( );
|
||||||
if (principal==null) {
|
if ( principal == null )
|
||||||
|
{
|
||||||
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_UNAUTHORIZED_REQUEST ), 401 );
|
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_UNAUTHORIZED_REQUEST ), 401 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,7 +550,9 @@ public class DefaultUserService
|
||||||
catch ( UserNotFoundException e )
|
catch ( UserNotFoundException e )
|
||||||
{
|
{
|
||||||
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_NOT_FOUND ), 404 );
|
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_NOT_FOUND ), 404 );
|
||||||
} catch ( PasswordRuleViolationException e ) {
|
}
|
||||||
|
catch ( PasswordRuleViolationException e )
|
||||||
|
{
|
||||||
List<ErrorMessage> messages = e.getViolations( ).getViolations( ).stream( ).map( m -> ErrorMessage.of( m.getKey( ), m.getArgs( ) ) ).collect( Collectors.toList( ) );
|
List<ErrorMessage> messages = e.getViolations( ).getViolations( ).stream( ).map( m -> ErrorMessage.of( m.getKey( ), m.getArgs( ) ) ).collect( Collectors.toList( ) );
|
||||||
throw new RedbackServiceException( messages, 422 );
|
throw new RedbackServiceException( messages, 422 );
|
||||||
}
|
}
|
||||||
|
@ -600,7 +620,8 @@ public class DefaultUserService
|
||||||
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_ADMIN_EXISTS ), 303 );
|
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_ADMIN_EXISTS ), 303 );
|
||||||
}
|
}
|
||||||
log.debug( "Creating admin admin user '{}'", adminUser.getUserId( ) );
|
log.debug( "Creating admin admin user '{}'", adminUser.getUserId( ) );
|
||||||
if (!RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME.equals(adminUser.getUserId())) {
|
if ( !RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME.equals( adminUser.getUserId( ) ) )
|
||||||
|
{
|
||||||
log.error( "Wrong admin user name {}", adminUser.getUserId( ) );
|
log.error( "Wrong admin user name {}", adminUser.getUserId( ) );
|
||||||
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_ADMIN_BAD_NAME ), 422 );
|
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_ADMIN_BAD_NAME ), 422 );
|
||||||
}
|
}
|
||||||
|
@ -644,7 +665,9 @@ public class DefaultUserService
|
||||||
if ( user.getAccountCreationDate( ) != null )
|
if ( user.getAccountCreationDate( ) != null )
|
||||||
{
|
{
|
||||||
return new AvailabilityStatus( true, user.getAccountCreationDate( ).toInstant( ) );
|
return new AvailabilityStatus( true, user.getAccountCreationDate( ).toInstant( ) );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return new AvailabilityStatus( true );
|
return new AvailabilityStatus( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -872,7 +895,8 @@ public class DefaultUserService
|
||||||
org.apache.archiva.redback.users.User user =
|
org.apache.archiva.redback.users.User user =
|
||||||
securitySystem.getUserManager( ).findUser( authkey.getForPrincipal( ) );
|
securitySystem.getUserManager( ).findUser( authkey.getForPrincipal( ) );
|
||||||
|
|
||||||
if (user.isValidated()) {
|
if ( user.isValidated( ) )
|
||||||
|
{
|
||||||
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_REGISTRATION_USER_VALIDATED ), 404 );
|
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_REGISTRATION_USER_VALIDATED ), 404 );
|
||||||
}
|
}
|
||||||
user.setValidated( true );
|
user.setValidated( true );
|
||||||
|
@ -889,11 +913,14 @@ public class DefaultUserService
|
||||||
|
|
||||||
VerificationStatus status = new VerificationStatus( false );
|
VerificationStatus status = new VerificationStatus( false );
|
||||||
SecuritySession authStatus = securitySystem.authenticate( authsource );
|
SecuritySession authStatus = securitySystem.authenticate( authsource );
|
||||||
if (authStatus.isAuthenticated()) {
|
if ( authStatus.isAuthenticated( ) )
|
||||||
|
{
|
||||||
Token accessToken = jwtAuthenticator.generateToken( principal );
|
Token accessToken = jwtAuthenticator.generateToken( principal );
|
||||||
status.setAccessToken( accessToken.getData( ) );
|
status.setAccessToken( accessToken.getData( ) );
|
||||||
status.setSuccess( true );
|
status.setSuccess( true );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
user.setValidated( false );
|
user.setValidated( false );
|
||||||
user.setLocked( true );
|
user.setLocked( true );
|
||||||
user.setPasswordChangeRequired( false );
|
user.setPasswordChangeRequired( false );
|
||||||
|
@ -1100,11 +1127,14 @@ public class DefaultUserService
|
||||||
if ( rawUser != null )
|
if ( rawUser != null )
|
||||||
{
|
{
|
||||||
RedbackServiceException result = updateFunction.apply( rawUser );
|
RedbackServiceException result = updateFunction.apply( rawUser );
|
||||||
if (result!=null) {
|
if ( result != null )
|
||||||
|
{
|
||||||
throw result;
|
throw result;
|
||||||
}
|
}
|
||||||
userManager.updateUser( rawUser, false );
|
userManager.updateUser( rawUser, false );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_NOT_FOUND, userId ), 404 );
|
throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_NOT_FOUND, userId ), 404 );
|
||||||
}
|
}
|
||||||
return rawUser;
|
return rawUser;
|
||||||
|
|
|
@ -43,12 +43,18 @@
|
||||||
<property name="mapper" ref="redbackJacksonJsonMapper"/>
|
<property name="mapper" ref="redbackJacksonJsonMapper"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="v2.jsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider">
|
||||||
|
<property name="mapper" ref="v2.redbackJacksonJsonMapper"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="xmlProvider" class="com.fasterxml.jackson.jaxrs.xml.JacksonJaxbXMLProvider">
|
<bean id="xmlProvider" class="com.fasterxml.jackson.jaxrs.xml.JacksonJaxbXMLProvider">
|
||||||
<property name="mapper" ref="redbackJacksonXMLMapper"/>
|
<property name="mapper" ref="redbackJacksonXMLMapper"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="redbackJacksonJsonMapper" class="com.fasterxml.jackson.databind.ObjectMapper" >
|
<bean id="redbackJacksonJsonMapper" class="com.fasterxml.jackson.databind.ObjectMapper" >
|
||||||
</bean>
|
</bean>
|
||||||
|
<bean id="v2.redbackJacksonJsonMapper" class="com.fasterxml.jackson.databind.ObjectMapper" >
|
||||||
|
</bean>
|
||||||
<bean id="redbackJacksonXMLMapper" class="com.fasterxml.jackson.dataformat.xml.XmlMapper" >
|
<bean id="redbackJacksonXMLMapper" class="com.fasterxml.jackson.dataformat.xml.XmlMapper" >
|
||||||
</bean>
|
</bean>
|
||||||
<bean id="redbackJacksonJsonConfigurator" class="org.apache.archiva.redback.rest.services.interceptors.JacksonJsonConfigurator" />
|
<bean id="redbackJacksonJsonConfigurator" class="org.apache.archiva.redback.rest.services.interceptors.JacksonJsonConfigurator" />
|
||||||
|
@ -94,8 +100,7 @@
|
||||||
</jaxrs:serviceBeans>
|
</jaxrs:serviceBeans>
|
||||||
|
|
||||||
<jaxrs:providers>
|
<jaxrs:providers>
|
||||||
<ref bean="jsonProvider"/>
|
<ref bean="v2.jsonProvider"/>
|
||||||
<ref bean="xmlProvider"/>
|
|
||||||
<ref bean="bearerAuthInterceptor#rest"/>
|
<ref bean="bearerAuthInterceptor#rest"/>
|
||||||
<ref bean="permissionInterceptor#rest"/>
|
<ref bean="permissionInterceptor#rest"/>
|
||||||
<ref bean="redbackServiceExceptionMapper"/>
|
<ref bean="redbackServiceExceptionMapper"/>
|
||||||
|
|
|
@ -18,9 +18,15 @@ package org.apache.archiva.redback.rest.services.v2;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||||
import com.fasterxml.jackson.databind.ser.Serializers;
|
import com.fasterxml.jackson.databind.ser.Serializers;
|
||||||
import io.restassured.RestAssured;
|
import io.restassured.RestAssured;
|
||||||
import io.restassured.builder.RequestSpecBuilder;
|
import io.restassured.builder.RequestSpecBuilder;
|
||||||
|
import io.restassured.config.ObjectMapperConfig;
|
||||||
|
import io.restassured.config.RestAssuredConfig;
|
||||||
|
import io.restassured.path.json.mapper.factory.Jackson2ObjectMapperFactory;
|
||||||
import io.restassured.response.Response;
|
import io.restassured.response.Response;
|
||||||
import io.restassured.specification.RequestSpecification;
|
import io.restassured.specification.RequestSpecification;
|
||||||
import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants;
|
import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants;
|
||||||
|
@ -45,6 +51,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.context.ContextLoaderListener;
|
import org.springframework.web.context.ContextLoaderListener;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
@ -330,6 +337,18 @@ public abstract class AbstractNativeRestServices
|
||||||
String basePath = getBasePath( );
|
String basePath = getBasePath( );
|
||||||
this.requestSpec = getRequestSpecBuilder( ).build( );
|
this.requestSpec = getRequestSpecBuilder( ).build( );
|
||||||
RestAssured.basePath = basePath;
|
RestAssured.basePath = basePath;
|
||||||
|
RestAssured.config = RestAssuredConfig.config().objectMapperConfig(new ObjectMapperConfig().jackson2ObjectMapperFactory(
|
||||||
|
new Jackson2ObjectMapperFactory() {
|
||||||
|
@Override
|
||||||
|
public ObjectMapper create( Type cls, String charset) {
|
||||||
|
ObjectMapper om = new ObjectMapper().findAndRegisterModules();
|
||||||
|
om.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
om.setPropertyNamingStrategy( PropertyNamingStrategy.SNAKE_CASE );
|
||||||
|
return om;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RequestSpecBuilder getRequestSpecBuilder( ) {
|
protected RequestSpecBuilder getRequestSpecBuilder( ) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.archiva.redback.rest.services.v2;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
||||||
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
|
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
|
||||||
|
@ -146,6 +147,7 @@ public abstract class AbstractRestServicesTestV2
|
||||||
mapper.registerModule( new JavaTimeModule( ) );
|
mapper.registerModule( new JavaTimeModule( ) );
|
||||||
mapper.setAnnotationIntrospector( new JaxbAnnotationIntrospector( mapper.getTypeFactory() ) );
|
mapper.setAnnotationIntrospector( new JaxbAnnotationIntrospector( mapper.getTypeFactory() ) );
|
||||||
mapper.setDateFormat( new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ" ) );
|
mapper.setDateFormat( new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ" ) );
|
||||||
|
mapper.setPropertyNamingStrategy( PropertyNamingStrategy.SNAKE_CASE );
|
||||||
provider.setMapper( mapper );
|
provider.setMapper( mapper );
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,11 @@ package org.apache.archiva.redback.rest.services.v2;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
||||||
|
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
|
||||||
import org.apache.archiva.components.apacheds.ApacheDs;
|
import org.apache.archiva.components.apacheds.ApacheDs;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.GroupMapping;
|
import org.apache.archiva.redback.rest.api.model.v2.GroupMapping;
|
||||||
import org.apache.archiva.redback.rest.api.services.v2.GroupService;
|
import org.apache.archiva.redback.rest.api.services.v2.GroupService;
|
||||||
|
@ -45,6 +49,7 @@ import javax.naming.directory.BasicAttributes;
|
||||||
import javax.naming.directory.DirContext;
|
import javax.naming.directory.DirContext;
|
||||||
import javax.naming.directory.InitialDirContext;
|
import javax.naming.directory.InitialDirContext;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -77,12 +82,27 @@ public class GroupServiceTest
|
||||||
|
|
||||||
private String groupSuffix;
|
private String groupSuffix;
|
||||||
|
|
||||||
|
private JacksonJaxbJsonProvider jsonProvider;
|
||||||
|
|
||||||
|
JacksonJaxbJsonProvider getJsonProvider() {
|
||||||
|
if (jsonProvider==null) {
|
||||||
|
jsonProvider = new JacksonJaxbJsonProvider( );
|
||||||
|
ObjectMapper mapper = new ObjectMapper( );
|
||||||
|
mapper.registerModule( new JavaTimeModule( ) );
|
||||||
|
mapper.setAnnotationIntrospector( new JaxbAnnotationIntrospector( mapper.getTypeFactory() ) );
|
||||||
|
mapper.setDateFormat( new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ" ) );
|
||||||
|
mapper.setPropertyNamingStrategy( PropertyNamingStrategy.SNAKE_CASE );
|
||||||
|
jsonProvider.setMapper( mapper );
|
||||||
|
}
|
||||||
|
return jsonProvider;
|
||||||
|
}
|
||||||
|
|
||||||
protected GroupService getGroupService( String authzHeader )
|
protected GroupService getGroupService( String authzHeader )
|
||||||
{
|
{
|
||||||
GroupService service =
|
GroupService service =
|
||||||
JAXRSClientFactory.create( "http://localhost:" + getServerPort( ) + "/" + getRestServicesPath( ) + "/v2/redback/",
|
JAXRSClientFactory.create( "http://localhost:" + getServerPort( ) + "/" + getRestServicesPath( ) + "/v2/redback/",
|
||||||
GroupService.class,
|
GroupService.class,
|
||||||
Collections.singletonList( new JacksonJaxbJsonProvider( ) ) );
|
Collections.singletonList( getJsonProvider() ) );
|
||||||
|
|
||||||
// for debuging purpose
|
// for debuging purpose
|
||||||
WebClient.getConfig( service ).getHttpConduit( ).getClient( ).setReceiveTimeout( getTimeout( ) );
|
WebClient.getConfig( service ).getHttpConduit( ).getClient( ).setReceiveTimeout( getTimeout( ) );
|
||||||
|
|
|
@ -78,8 +78,8 @@ public class NativeAuthenticationServiceTest extends AbstractNativeRestServices
|
||||||
.then( ).assertThat( ).statusCode( 200 ).and( )
|
.then( ).assertThat( ).statusCode( 200 ).and( )
|
||||||
.contentType( JSON ).
|
.contentType( JSON ).
|
||||||
body( "success", equalTo( true ) )
|
body( "success", equalTo( true ) )
|
||||||
.body( "requestTime", notNullValue( ) ).extract().response();
|
.body( "request_time", notNullValue( ) ).extract().response();
|
||||||
OffsetDateTime dateTime = OffsetDateTime.parse( response.body( ).jsonPath( ).getString( "requestTime" ) );
|
OffsetDateTime dateTime = OffsetDateTime.parse( response.body( ).jsonPath( ).getString( "request_time" ) );
|
||||||
Instant afterCall = Instant.now( );
|
Instant afterCall = Instant.now( );
|
||||||
assertTrue( dateTime.toInstant( ).isAfter( beforeCall ) );
|
assertTrue( dateTime.toInstant( ).isAfter( beforeCall ) );
|
||||||
assertTrue( dateTime.toInstant( ).isBefore( afterCall ) );
|
assertTrue( dateTime.toInstant( ).isBefore( afterCall ) );
|
||||||
|
|
|
@ -266,7 +266,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices
|
||||||
return "cn=" + cn + "," + groupSuffix;
|
return "cn=" + cn + "," + groupSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGroup( DirContext context, String groupName, String dn )
|
private void createGroup( DirContext context, String group_name, String dn )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
if ( !exists( context, dn ) )
|
if ( !exists( context, dn ) )
|
||||||
|
@ -276,7 +276,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices
|
||||||
objectClass.add( "top" );
|
objectClass.add( "top" );
|
||||||
objectClass.add( "groupOfUniqueNames" );
|
objectClass.add( "groupOfUniqueNames" );
|
||||||
attributes.put( objectClass );
|
attributes.put( objectClass );
|
||||||
attributes.put( "cn", groupName );
|
attributes.put( "cn", group_name );
|
||||||
BasicAttribute basicAttribute = new BasicAttribute( "uniquemember" );
|
BasicAttribute basicAttribute = new BasicAttribute( "uniquemember" );
|
||||||
|
|
||||||
basicAttribute.add( "uid=admin," + peopleSuffix );
|
basicAttribute.add( "uid=admin," + peopleSuffix );
|
||||||
|
@ -324,7 +324,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices
|
||||||
assertNotNull( data );
|
assertNotNull( data );
|
||||||
assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
||||||
assertEquals( Integer.valueOf( 1000 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
assertEquals( Integer.valueOf( 1000 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
||||||
assertEquals( Integer.valueOf( 6 ), response.body( ).jsonPath( ).get( "pagination.totalCount" ) );
|
assertEquals( Integer.valueOf( 6 ), response.body( ).jsonPath( ).get( "pagination.total_count" ) );
|
||||||
assertEquals( 6, data.size( ) );
|
assertEquals( 6, data.size( ) );
|
||||||
String[] values = data.stream( ).map( ldapInfo -> ldapInfo.getName( ) ).sorted( ).collect( Collectors.toList( ) ).toArray( new String[0] );
|
String[] values = data.stream( ).map( ldapInfo -> ldapInfo.getName( ) ).sorted( ).collect( Collectors.toList( ) ).toArray( new String[0] );
|
||||||
assertArrayEquals( getTestGroupList( ).toArray( new String[0] ), values );
|
assertArrayEquals( getTestGroupList( ).toArray( new String[0] ), values );
|
||||||
|
@ -345,7 +345,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices
|
||||||
assertNotNull( data );
|
assertNotNull( data );
|
||||||
assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
||||||
assertEquals( Integer.valueOf( 3 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
assertEquals( Integer.valueOf( 3 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
||||||
assertEquals( Integer.valueOf( 6 ), response.body( ).jsonPath( ).get( "pagination.totalCount" ) );
|
assertEquals( Integer.valueOf( 6 ), response.body( ).jsonPath( ).get( "pagination.total_count" ) );
|
||||||
assertEquals( 3, data.size( ) );
|
assertEquals( 3, data.size( ) );
|
||||||
String[] values = data.stream( ).map( ldapInfo -> ldapInfo.getName( ) ).sorted( ).collect( Collectors.toList( ) ).toArray( new String[0] );
|
String[] values = data.stream( ).map( ldapInfo -> ldapInfo.getName( ) ).sorted( ).collect( Collectors.toList( ) ).toArray( new String[0] );
|
||||||
assertArrayEquals( getTestGroupList( ).subList( 0, 3 ).toArray( new String[0] ), values );
|
assertArrayEquals( getTestGroupList( ).subList( 0, 3 ).toArray( new String[0] ), values );
|
||||||
|
@ -364,7 +364,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices
|
||||||
assertNotNull( data );
|
assertNotNull( data );
|
||||||
assertEquals( Integer.valueOf( 2 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
assertEquals( Integer.valueOf( 2 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
||||||
assertEquals( Integer.valueOf( 1000 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
assertEquals( Integer.valueOf( 1000 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
||||||
assertEquals( Integer.valueOf( 6 ), response.body( ).jsonPath( ).get( "pagination.totalCount" ) );
|
assertEquals( Integer.valueOf( 6 ), response.body( ).jsonPath( ).get( "pagination.total_count" ) );
|
||||||
assertEquals( 4, data.size( ) );
|
assertEquals( 4, data.size( ) );
|
||||||
String[] values = data.stream( ).map( ldapInfo -> ldapInfo.getName( ) ).sorted( ).collect( Collectors.toList( ) ).toArray( new String[0] );
|
String[] values = data.stream( ).map( ldapInfo -> ldapInfo.getName( ) ).sorted( ).collect( Collectors.toList( ) ).toArray( new String[0] );
|
||||||
assertArrayEquals( getTestGroupList( ).subList( 2, getTestGroupList().size() ).toArray( new String[0] ), values );
|
assertArrayEquals( getTestGroupList( ).subList( 2, getTestGroupList().size() ).toArray( new String[0] ), values );
|
||||||
|
@ -390,7 +390,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "groupName", "ldap group" );
|
jsonAsMap.put( "group_name", "ldap group" );
|
||||||
jsonAsMap.put( "roles", Arrays.asList( "role1", "role2" ) );
|
jsonAsMap.put( "roles", Arrays.asList( "role1", "role2" ) );
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -417,7 +417,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "groupName", "ldap group" );
|
jsonAsMap.put( "group_name", "ldap group" );
|
||||||
jsonAsMap.put( "roles", Arrays.asList( "role1", "role2" ) );
|
jsonAsMap.put( "roles", Arrays.asList( "role1", "role2" ) );
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -457,7 +457,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices
|
||||||
} finally {
|
} finally {
|
||||||
// Put it back
|
// Put it back
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "groupName", "archiva-admin" );
|
jsonAsMap.put( "group_name", "archiva-admin" );
|
||||||
jsonAsMap.put( "roles", Arrays.asList( "System Administrator" ) );
|
jsonAsMap.put( "roles", Arrays.asList( "System Administrator" ) );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
|
|
@ -22,7 +22,6 @@ import io.restassured.response.Response;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.Operation;
|
import org.apache.archiva.redback.rest.api.model.v2.Operation;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.Permission;
|
import org.apache.archiva.redback.rest.api.model.v2.Permission;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.RegistrationKey;
|
import org.apache.archiva.redback.rest.api.model.v2.RegistrationKey;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.User;
|
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.UserInfo;
|
import org.apache.archiva.redback.rest.api.model.v2.UserInfo;
|
||||||
import org.apache.archiva.redback.rest.api.model.v2.VerificationStatus;
|
import org.apache.archiva.redback.rest.api.model.v2.VerificationStatus;
|
||||||
import org.apache.archiva.redback.rest.services.mock.EmailMessage;
|
import org.apache.archiva.redback.rest.services.mock.EmailMessage;
|
||||||
|
@ -89,7 +88,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
assertEquals( 2, userData.size( ) );
|
assertEquals( 2, userData.size( ) );
|
||||||
assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
||||||
assertEquals( Integer.valueOf( 1000 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
assertEquals( Integer.valueOf( 1000 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
||||||
assertEquals( Integer.valueOf( 2 ), response.body( ).jsonPath( ).get( "pagination.totalCount" ) );
|
assertEquals( Integer.valueOf( 2 ), response.body( ).jsonPath( ).get( "pagination.total_count" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
@ -114,9 +113,9 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" + suffix );
|
jsonAsMap.put( "user_id", "aragorn" + suffix );
|
||||||
jsonAsMap.put( "email", "aragorn" + reverseSuffix + "@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn" + reverseSuffix + "@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor " + modSuffix );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor " + modSuffix );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
.when( )
|
.when( )
|
||||||
.post( )
|
.post( )
|
||||||
|
@ -127,7 +126,6 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
@Test
|
@Test
|
||||||
void getMultipleUsersWithoutParams( )
|
void getMultipleUsersWithoutParams( )
|
||||||
{
|
{
|
||||||
Map<String, String> params = new HashMap<>( );
|
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.when( ).get( ).then( ).statusCode( 200 ).extract( ).response( );
|
.when( ).get( ).then( ).statusCode( 200 ).extract( ).response( );
|
||||||
assertNotNull( response );
|
assertNotNull( response );
|
||||||
|
@ -137,7 +135,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
assertEquals( userNum + 2, userData.size( ) );
|
assertEquals( userNum + 2, userData.size( ) );
|
||||||
assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
||||||
assertEquals( Integer.valueOf( 1000 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
assertEquals( Integer.valueOf( 1000 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
||||||
assertEquals( Integer.valueOf( userNum + 2 ), response.body( ).jsonPath( ).get( "pagination.totalCount" ) );
|
assertEquals( Integer.valueOf( userNum + 2 ), response.body( ).jsonPath( ).get( "pagination.total_count" ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +154,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
assertEquals( 10, userData.size( ) );
|
assertEquals( 10, userData.size( ) );
|
||||||
assertEquals( Integer.valueOf( 1 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
assertEquals( Integer.valueOf( 1 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
||||||
assertEquals( Integer.valueOf( 10 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
assertEquals( Integer.valueOf( 10 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
||||||
assertEquals( Integer.valueOf( userNum + 2 ), response.body( ).jsonPath( ).get( "pagination.totalCount" ) );
|
assertEquals( Integer.valueOf( userNum + 2 ), response.body( ).jsonPath( ).get( "pagination.total_count" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -177,7 +175,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
assertEquals( 5, userData.size( ) );
|
assertEquals( 5, userData.size( ) );
|
||||||
assertEquals( Integer.valueOf( 3 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
assertEquals( Integer.valueOf( 3 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
||||||
assertEquals( Integer.valueOf( 5 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
assertEquals( Integer.valueOf( 5 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
||||||
assertEquals( Integer.valueOf( userNum + 2 ), response.body( ).jsonPath( ).get( "pagination.totalCount" ) );
|
assertEquals( Integer.valueOf( userNum + 2 ), response.body( ).jsonPath( ).get( "pagination.total_count" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -186,7 +184,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
HashMap<String, String> params = new HashMap<>( );
|
HashMap<String, String> params = new HashMap<>( );
|
||||||
params.put( "limit", Integer.toString( 8 ) );
|
params.put( "limit", Integer.toString( 8 ) );
|
||||||
params.put( "offset", Integer.toString( 10 ) );
|
params.put( "offset", Integer.toString( 10 ) );
|
||||||
params.put( "orderBy", "fullName" );
|
params.put( "orderBy", "full_name" );
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.when( ).params( params ).get( ).then( ).statusCode( 200 ).extract( ).response( );
|
.when( ).params( params ).get( ).then( ).statusCode( 200 ).extract( ).response( );
|
||||||
List<UserInfo> userData = response.body( ).jsonPath( ).getList( "data", UserInfo.class );
|
List<UserInfo> userData = response.body( ).jsonPath( ).getList( "data", UserInfo.class );
|
||||||
|
@ -198,7 +196,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
assertEquals( 8, userData.size( ) );
|
assertEquals( 8, userData.size( ) );
|
||||||
assertEquals( Integer.valueOf( 10 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
assertEquals( Integer.valueOf( 10 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
||||||
assertEquals( Integer.valueOf( 8 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
assertEquals( Integer.valueOf( 8 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
||||||
assertEquals( Integer.valueOf( userNum + 2 ), response.body( ).jsonPath( ).get( "pagination.totalCount" ) );
|
assertEquals( Integer.valueOf( userNum + 2 ), response.body( ).jsonPath( ).get( "pagination.total_count" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -217,7 +215,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
assertEquals( 10, userData.size( ) );
|
assertEquals( 10, userData.size( ) );
|
||||||
assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
||||||
assertEquals( Integer.valueOf( 10 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
assertEquals( Integer.valueOf( 10 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
||||||
assertEquals( Integer.valueOf( userNum + 2 ), response.body( ).jsonPath( ).get( "pagination.totalCount" ) );
|
assertEquals( Integer.valueOf( userNum + 2 ), response.body( ).jsonPath( ).get( "pagination.total_count" ) );
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
void getMultipleUsersWithPagingAndQuery( ) {
|
void getMultipleUsersWithPagingAndQuery( ) {
|
||||||
|
@ -236,7 +234,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
assertEquals( 2, userData.size( ) );
|
assertEquals( 2, userData.size( ) );
|
||||||
assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) );
|
||||||
assertEquals( Integer.valueOf( 10 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
assertEquals( Integer.valueOf( 10 ), response.body( ).jsonPath( ).get( "pagination.limit" ) );
|
||||||
assertEquals( Integer.valueOf( 2 ), response.body( ).jsonPath( ).get( "pagination.totalCount" ) );
|
assertEquals( Integer.valueOf( 2 ), response.body( ).jsonPath( ).get( "pagination.total_count" ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +268,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
assertNotNull( response );
|
assertNotNull( response );
|
||||||
assertEquals( "jpa:admin", response.body( ).jsonPath( ).get( "id" ) );
|
assertEquals( "jpa:admin", response.body( ).jsonPath( ).get( "id" ) );
|
||||||
assertEquals( "admin", response.body( ).jsonPath( ).get( "user_id" ) );
|
assertEquals( "admin", response.body( ).jsonPath( ).get( "user_id" ) );
|
||||||
assertEquals( "the admin user", response.body( ).jsonPath( ).get( "fullName" ) );
|
assertEquals( "the admin user", response.body( ).jsonPath( ).get( "full_name" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -290,7 +288,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -315,7 +313,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "" );
|
jsonAsMap.put( "user_id", "" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -332,7 +330,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "me" );
|
jsonAsMap.put( "user_id", "me" );
|
||||||
jsonAsMap.put( "email", "me@lordoftherings.org" );
|
jsonAsMap.put( "email", "me@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Its just me" );
|
jsonAsMap.put( "full_name", "Its just me" );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -352,7 +350,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
|
@ -367,7 +365,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
jsonAsMap = new HashMap<>( );
|
jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "arwen" );
|
jsonAsMap.put( "user_id", "arwen" );
|
||||||
jsonAsMap.put( "email", "arwen@lordoftherings.org" );
|
jsonAsMap.put( "email", "arwen@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Arwen Daughter of Elrond" );
|
jsonAsMap.put( "full_name", "Arwen Daughter of Elrond" );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( userToken ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( userToken ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -394,7 +392,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
|
@ -407,7 +405,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
jsonAsMap = new HashMap<>( );
|
jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
|
|
||||||
|
@ -436,7 +434,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -465,7 +463,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -494,7 +492,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -506,7 +504,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
{
|
{
|
||||||
jsonAsMap = new HashMap<>( );
|
jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "email", "aragorn2@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn2@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor the Second" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor the Second" );
|
||||||
jsonAsMap.put( "password", "pAssw0rDXX" );
|
jsonAsMap.put( "password", "pAssw0rDXX" );
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -530,7 +528,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
String token = getAdminToken( );
|
String token = getAdminToken( );
|
||||||
HashMap<Object, Object> jsonAsMap = new HashMap<>( );
|
HashMap<Object, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "email", "aragorn2@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn2@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor the Second" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor the Second" );
|
||||||
jsonAsMap.put( "password", "pAssw0rDXX" );
|
jsonAsMap.put( "password", "pAssw0rDXX" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -546,7 +544,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -558,7 +556,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
{
|
{
|
||||||
jsonAsMap = new HashMap<>( );
|
jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "email", "aragorn2@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn2@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor the Second" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor the Second" );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -567,7 +565,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
.prettyPeek( )
|
.prettyPeek( )
|
||||||
.then( ).statusCode( 422 ).extract( ).response( );
|
.then( ).statusCode( 422 ).extract( ).response( );
|
||||||
assertNotNull( response );
|
assertNotNull( response );
|
||||||
assertEquals( "user.password.violation.reuse", response.body( ).jsonPath( ).get( "errorMessages[0].errorKey" ) );
|
assertEquals( "user.password.violation.reuse", response.body( ).jsonPath( ).get( "error_messages[0].error_key" ) );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -585,7 +583,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "admin" );
|
jsonAsMap.put( "user_id", "admin" );
|
||||||
jsonAsMap.put( "email", "admin@lordoftherings.org" );
|
jsonAsMap.put( "email", "admin@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Admin" );
|
jsonAsMap.put( "full_name", "Admin" );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -616,7 +614,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "locked", false );
|
jsonAsMap.put( "locked", false );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
|
@ -658,7 +656,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "locked", true );
|
jsonAsMap.put( "locked", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
|
@ -705,7 +703,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "locked", false );
|
jsonAsMap.put( "locked", false );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
|
@ -721,7 +719,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.get( "aragorn" )
|
.get( "aragorn" )
|
||||||
.then( ).statusCode( 200 ).extract( ).response( );
|
.then( ).statusCode( 200 ).extract( ).response( );
|
||||||
assertTrue( response.getBody( ).jsonPath( ).getBoolean( "passwordChangeRequired" ) );
|
assertTrue( response.getBody( ).jsonPath( ).getBoolean( "password_change_required" ) );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -738,9 +736,9 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "locked", false );
|
jsonAsMap.put( "locked", false );
|
||||||
jsonAsMap.put( "passwordChangeRequired", true );
|
jsonAsMap.put( "password_change_required", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -750,7 +748,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.get( "aragorn" )
|
.get( "aragorn" )
|
||||||
.then( ).statusCode( 200 ).extract( ).response( );
|
.then( ).statusCode( 200 ).extract( ).response( );
|
||||||
assertTrue( response.getBody( ).jsonPath( ).getBoolean( "passwordChangeRequired" ) );
|
assertTrue( response.getBody( ).jsonPath( ).getBoolean( "password_change_required" ) );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
|
@ -759,7 +757,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.get( "aragorn" )
|
.get( "aragorn" )
|
||||||
.then( ).statusCode( 200 ).extract( ).response( );
|
.then( ).statusCode( 200 ).extract( ).response( );
|
||||||
assertFalse( response.getBody( ).jsonPath( ).getBoolean( "passwordChangeRequired" ) );
|
assertFalse( response.getBody( ).jsonPath( ).getBoolean( "password_change_required" ) );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -794,10 +792,10 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "locked", false );
|
jsonAsMap.put( "locked", false );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "passwordChangeRequired", false );
|
jsonAsMap.put( "password_change_required", false );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -808,10 +806,10 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
jsonAsMap = new HashMap<>( );
|
jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "elrond" );
|
jsonAsMap.put( "user_id", "elrond" );
|
||||||
jsonAsMap.put( "email", "elrond@lordoftherings.org" );
|
jsonAsMap.put( "email", "elrond@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Elrond King of Elves" );
|
jsonAsMap.put( "full_name", "Elrond King of Elves" );
|
||||||
jsonAsMap.put( "locked", false );
|
jsonAsMap.put( "locked", false );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "passwordChangeRequired", false );
|
jsonAsMap.put( "password_change_required", false );
|
||||||
jsonAsMap.put( "password", "pAssw0rDElrond" );
|
jsonAsMap.put( "password", "pAssw0rDElrond" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -829,7 +827,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.get( "aragorn" )
|
.get( "aragorn" )
|
||||||
.then( ).statusCode( 200 ).extract( ).response( );
|
.then( ).statusCode( 200 ).extract( ).response( );
|
||||||
assertFalse( response.getBody( ).jsonPath( ).getBoolean( "passwordChangeRequired" ) );
|
assertFalse( response.getBody( ).jsonPath( ).getBoolean( "password_change_required" ) );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -849,10 +847,10 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "locked", false );
|
jsonAsMap.put( "locked", false );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "passwordChangeRequired", true );
|
jsonAsMap.put( "password_change_required", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -863,10 +861,10 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
jsonAsMap = new HashMap<>( );
|
jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "elrond" );
|
jsonAsMap.put( "user_id", "elrond" );
|
||||||
jsonAsMap.put( "email", "elrond@lordoftherings.org" );
|
jsonAsMap.put( "email", "elrond@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Elrond King of Elves" );
|
jsonAsMap.put( "full_name", "Elrond King of Elves" );
|
||||||
jsonAsMap.put( "locked", false );
|
jsonAsMap.put( "locked", false );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "passwordChangeRequired", false );
|
jsonAsMap.put( "password_change_required", false );
|
||||||
jsonAsMap.put( "password", "pAssw0rDElrond" );
|
jsonAsMap.put( "password", "pAssw0rDElrond" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.body( jsonAsMap )
|
.body( jsonAsMap )
|
||||||
|
@ -884,7 +882,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
.get( "aragorn" )
|
.get( "aragorn" )
|
||||||
.then( ).statusCode( 200 ).extract( ).response( );
|
.then( ).statusCode( 200 ).extract( ).response( );
|
||||||
assertTrue( response.getBody( ).jsonPath( ).getBoolean( "passwordChangeRequired" ) );
|
assertTrue( response.getBody( ).jsonPath( ).getBoolean( "password_change_required" ) );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -905,7 +903,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
|
@ -919,13 +917,13 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
String userToken = getUserToken( "aragorn", "pAssw0rD" );
|
String userToken = getUserToken( "aragorn", "pAssw0rD" );
|
||||||
Map<String, Object> updateMap = new HashMap<>( );
|
Map<String, Object> updateMap = new HashMap<>( );
|
||||||
updateMap.put( "email", "aragorn-swiss@lordoftherings.org" );
|
updateMap.put( "email", "aragorn-swiss@lordoftherings.org" );
|
||||||
updateMap.put( "fullName", "Aragorn King of Switzerland" );
|
updateMap.put( "full_name", "Aragorn King of Switzerland" );
|
||||||
Response response = given( ).spec( getRequestSpec( userToken ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( userToken ) ).contentType( JSON )
|
||||||
.body( updateMap )
|
.body( updateMap )
|
||||||
.when( )
|
.when( )
|
||||||
.put( "me" )
|
.put( "me" )
|
||||||
.then( ).statusCode( 200 ).extract( ).response( );
|
.then( ).statusCode( 200 ).extract( ).response( );
|
||||||
assertEquals( "Aragorn King of Switzerland", response.getBody( ).jsonPath( ).getString( "fullName" ) );
|
assertEquals( "Aragorn King of Switzerland", response.getBody( ).jsonPath( ).getString( "full_name" ) );
|
||||||
assertEquals( "aragorn-swiss@lordoftherings.org", response.getBody( ).jsonPath( ).getString( "email" ) );
|
assertEquals( "aragorn-swiss@lordoftherings.org", response.getBody( ).jsonPath( ).getString( "email" ) );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -943,7 +941,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
|
@ -958,15 +956,15 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> updateMap = new HashMap<>( );
|
Map<String, Object> updateMap = new HashMap<>( );
|
||||||
updateMap.put( "user_id", "aragorn" );
|
updateMap.put( "user_id", "aragorn" );
|
||||||
updateMap.put( "email", "aragorn-sweden@lordoftherings.org" );
|
updateMap.put( "email", "aragorn-sweden@lordoftherings.org" );
|
||||||
updateMap.put( "fullName", "Aragorn King of Sweden" );
|
updateMap.put( "full_name", "Aragorn King of Sweden" );
|
||||||
updateMap.put( "currentPassword", "pAssw0rD" );
|
updateMap.put( "current_password", "pAssw0rD" );
|
||||||
updateMap.put( "password", "x1y2z3a4b5c6d8##" );
|
updateMap.put( "password", "x1y2z3a4b5c6d8##" );
|
||||||
Response response = given( ).spec( getRequestSpec( userToken ) ).contentType( JSON )
|
Response response = given( ).spec( getRequestSpec( userToken ) ).contentType( JSON )
|
||||||
.body( updateMap )
|
.body( updateMap )
|
||||||
.when( )
|
.when( )
|
||||||
.put( "me" )
|
.put( "me" )
|
||||||
.then( ).statusCode( 200 ).extract( ).response( );
|
.then( ).statusCode( 200 ).extract( ).response( );
|
||||||
assertEquals( "Aragorn King of Sweden", response.getBody( ).jsonPath( ).getString( "fullName" ) );
|
assertEquals( "Aragorn King of Sweden", response.getBody( ).jsonPath( ).getString( "full_name" ) );
|
||||||
assertEquals( "aragorn-sweden@lordoftherings.org", response.getBody( ).jsonPath( ).getString( "email" ) );
|
assertEquals( "aragorn-sweden@lordoftherings.org", response.getBody( ).jsonPath( ).getString( "email" ) );
|
||||||
userToken = getUserToken( "aragorn", "x1y2z3a4b5c6d8##" );
|
userToken = getUserToken( "aragorn", "x1y2z3a4b5c6d8##" );
|
||||||
given( ).spec( getRequestSpec( userToken ) ).contentType( JSON ).get( "aragorn" )
|
given( ).spec( getRequestSpec( userToken ) ).contentType( JSON ).get( "aragorn" )
|
||||||
|
@ -987,7 +985,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
|
@ -1004,7 +1002,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
.get( "me" )
|
.get( "me" )
|
||||||
.then( ).statusCode( 200 ).extract( ).response( );
|
.then( ).statusCode( 200 ).extract( ).response( );
|
||||||
assertEquals( "aragorn", response.getBody( ).jsonPath( ).getString( "user_id" ) );
|
assertEquals( "aragorn", response.getBody( ).jsonPath( ).getString( "user_id" ) );
|
||||||
assertEquals( "Aragorn King of Gondor", response.getBody( ).jsonPath( ).getString( "fullName" ) );
|
assertEquals( "Aragorn King of Gondor", response.getBody( ).jsonPath( ).getString( "full_name" ) );
|
||||||
assertEquals( "aragorn@lordoftherings.org", response.getBody( ).jsonPath( ).getString( "email" ) );
|
assertEquals( "aragorn@lordoftherings.org", response.getBody( ).jsonPath( ).getString( "email" ) );
|
||||||
assertTrue( response.getBody( ).jsonPath( ).getBoolean( "validated" ) );
|
assertTrue( response.getBody( ).jsonPath( ).getBoolean( "validated" ) );
|
||||||
}
|
}
|
||||||
|
@ -1023,7 +1021,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( token ) ).contentType( JSON )
|
||||||
|
@ -1054,7 +1052,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
||||||
|
@ -1087,7 +1085,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
||||||
|
@ -1129,10 +1127,10 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
|
|
||||||
userMap.put( "user_id", "bilbo" );
|
userMap.put( "user_id", "bilbo" );
|
||||||
userMap.put( "email", "bilbo@lordoftherings.org" );
|
userMap.put( "email", "bilbo@lordoftherings.org" );
|
||||||
userMap.put( "fullName", "Bilbo Beutlin" );
|
userMap.put( "full_name", "Bilbo Beutlin" );
|
||||||
userMap.put( "validated", true );
|
userMap.put( "validated", true );
|
||||||
userMap.put( "password", "pAssw0rD" );
|
userMap.put( "password", "pAssw0rD" );
|
||||||
userMap.put( "confirmPassword", "pAssw0rD" );
|
userMap.put( "confirm_password", "pAssw0rD" );
|
||||||
requestMap.put( "user", userMap );
|
requestMap.put( "user", userMap );
|
||||||
requestMap.put( "applicationUrl", "http://localhost" );
|
requestMap.put( "applicationUrl", "http://localhost" );
|
||||||
|
|
||||||
|
@ -1174,7 +1172,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
|
|
||||||
userMap.put( "user_id", "bilbo" );
|
userMap.put( "user_id", "bilbo" );
|
||||||
userMap.put( "email", "bilbo@lordoftherings.org" );
|
userMap.put( "email", "bilbo@lordoftherings.org" );
|
||||||
userMap.put( "fullName", "Bilbo Beutlin" );
|
userMap.put( "full_name", "Bilbo Beutlin" );
|
||||||
userMap.put( "validated", true );
|
userMap.put( "validated", true );
|
||||||
userMap.put( "password", "pAssw0rD" );
|
userMap.put( "password", "pAssw0rD" );
|
||||||
userMap.put( "confirmPassword", "xxx" );
|
userMap.put( "confirmPassword", "xxx" );
|
||||||
|
@ -1201,7 +1199,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
||||||
|
@ -1250,7 +1248,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
||||||
|
@ -1287,7 +1285,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
||||||
|
@ -1319,7 +1317,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
||||||
|
@ -1359,7 +1357,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
||||||
|
@ -1392,7 +1390,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
||||||
|
@ -1429,7 +1427,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
Map<String, Object> jsonAsMap = new HashMap<>( );
|
Map<String, Object> jsonAsMap = new HashMap<>( );
|
||||||
jsonAsMap.put( "user_id", "aragorn" );
|
jsonAsMap.put( "user_id", "aragorn" );
|
||||||
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
jsonAsMap.put( "email", "aragorn@lordoftherings.org" );
|
||||||
jsonAsMap.put( "fullName", "Aragorn King of Gondor" );
|
jsonAsMap.put( "full_name", "Aragorn King of Gondor" );
|
||||||
jsonAsMap.put( "validated", true );
|
jsonAsMap.put( "validated", true );
|
||||||
jsonAsMap.put( "password", "pAssw0rD" );
|
jsonAsMap.put( "password", "pAssw0rD" );
|
||||||
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON )
|
||||||
|
@ -1473,10 +1471,10 @@ public class NativeUserServiceTest extends AbstractNativeRestServices
|
||||||
|
|
||||||
userMap.put( "user_id", "bilbo" );
|
userMap.put( "user_id", "bilbo" );
|
||||||
userMap.put( "email", "bilbo@lordoftherings.org" );
|
userMap.put( "email", "bilbo@lordoftherings.org" );
|
||||||
userMap.put( "fullName", "Bilbo Beutlin" );
|
userMap.put( "full_name", "Bilbo Beutlin" );
|
||||||
userMap.put( "validated", true );
|
userMap.put( "validated", true );
|
||||||
userMap.put( "password", "pAssw0rD" );
|
userMap.put( "password", "pAssw0rD" );
|
||||||
userMap.put( "confirmPassword", "pAssw0rD" );
|
userMap.put( "confirm_password", "pAssw0rD" );
|
||||||
requestMap.put( "user", userMap );
|
requestMap.put( "user", userMap );
|
||||||
requestMap.put( "applicationUrl", "http://localhost" );
|
requestMap.put( "applicationUrl", "http://localhost" );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue