diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/JacksonJsonConfigurator.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/JacksonJsonConfigurator.java index 3828c93e..6429e89f 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/JacksonJsonConfigurator.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/JacksonJsonConfigurator.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.json.JsonWriteFeature; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; @@ -47,18 +48,29 @@ public class JacksonJsonConfigurator private Logger log = LoggerFactory.getLogger( getClass() ); @Inject - public JacksonJsonConfigurator( @Named("redbackJacksonJsonMapper") ObjectMapper objectMapper, - @Name( "redbackJacksonXMLMapper" ) XmlMapper xmlMapper) + public JacksonJsonConfigurator( @Named( "redbackJacksonJsonMapper" ) ObjectMapper objectMapper, + @Name( "redbackJacksonXMLMapper" ) XmlMapper xmlMapper, @Named( "v2.redbackJacksonJsonMapper" ) ObjectMapper objectMapperV2 ) { + log.info( "configure jackson ObjectMapper" ); objectMapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES ); objectMapper.enable( DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL ); objectMapper.enable( DeserializationFeature.USE_LONG_FOR_INTS ); - objectMapper.setAnnotationIntrospector( new JaxbAnnotationIntrospector( objectMapper.getTypeFactory() ) ); + objectMapper.setAnnotationIntrospector( new JaxbAnnotationIntrospector( objectMapper.getTypeFactory( ) ) ); objectMapper.findAndRegisterModules( ); objectMapper.registerModule( new JavaTimeModule( ) ); 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.setAnnotationIntrospector( new JaxbAnnotationIntrospector( xmlMapper.getTypeFactory( ) ) ); diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultUserService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultUserService.java index 5c388474..5b011098 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultUserService.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultUserService.java @@ -44,19 +44,19 @@ import org.apache.archiva.redback.rbac.RbacManagerException; import org.apache.archiva.redback.rbac.UserAssignment; 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.v2.AvailabilityStatus; 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.PagedResult; 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.Resource; -import org.apache.archiva.redback.rest.api.model.v2.VerificationStatus; -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.SelfUserData; 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.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.v2.UserService; 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.UserManagerException; import org.apache.archiva.redback.users.UserNotFoundException; -import org.apache.archiva.redback.users.UserQuery; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -90,15 +89,12 @@ import java.security.Principal; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.BiFunction; import java.util.function.BiPredicate; import java.util.function.Function; import java.util.function.Predicate; @@ -109,25 +105,33 @@ public class DefaultUserService implements UserService { - private final Logger log = LoggerFactory.getLogger( getClass() ); + private final Logger log = LoggerFactory.getLogger( getClass( ) ); 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> FILTER_MAP = new HashMap<>( ); - private static final Map> ORDER_MAP = new HashMap<>( ); - static { - ORDER_MAP.put( "id", Comparator.comparing( org.apache.archiva.redback.users.User::getId ) ); - 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) ); - ORDER_MAP.put( "email", Comparator.comparing( org.apache.archiva.redback.users.User::getEmail) ); - ORDER_MAP.put( "created", Comparator.comparing( org.apache.archiva.redback.users.User::getAccountCreationDate) ); - ORDER_MAP.put( "lastLogin", Comparator.comparing( org.apache.archiva.redback.users.User::getLastLoginDate) ); - ORDER_MAP.put( "validated", Comparator.comparing( org.apache.archiva.redback.users.User::isValidated) ); + private static final Map> ORDER_MAP = new HashMap<>( ); + + static + { + // The simple Comparator.comparing(attribute) is not null safe + // As there are attributes that may have a null value, we have to use a comparator with nullsLast(naturalOrder) + // and the wrapping Comparator.nullsLast(Comparator.comparing(attribute)) does not work, because the attribute is not checked by the nullsLast-Comparator + ORDER_MAP.put( "id", Comparator.comparing( org.apache.archiva.redback.users.User::getId, Comparator.nullsLast( Comparator.naturalOrder( ) ) ) ); + 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( "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 ) ); } @@ -199,10 +203,13 @@ public class DefaultUserService this.securitySystem = securitySystem; } - RedbackPrincipal getPrincipal() { - if (this.securityContext!=null) { + RedbackPrincipal getPrincipal( ) + { + if ( this.securityContext != null ) + { Principal pri = this.securityContext.getUserPrincipal( ); - if (pri!=null && pri instanceof RedbackPrincipal) { + if ( pri != null && pri instanceof RedbackPrincipal ) + { return (RedbackPrincipal) pri; } } @@ -214,43 +221,43 @@ public class DefaultUserService throws RedbackServiceException { UserInfo result; - if ( Arrays.binarySearch( INVALID_CREATE_USER_NAMES, user.getUserId( ) ) >=0 ) + if ( Arrays.binarySearch( INVALID_CREATE_USER_NAMES, user.getUserId( ) ) >= 0 ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_ID_INVALID, user.getUserId() ), 422 ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_ID_INVALID, user.getUserId( ) ), 422 ); } try { - org.apache.archiva.redback.users.User u = userManager.findUser( user.getUserId() ); + org.apache.archiva.redback.users.User u = userManager.findUser( user.getUserId( ) ); if ( u != null ) { httpServletResponse.setHeader( "Location", uriInfo.getAbsolutePathBuilder( ).path( u.getUsername( ) ).build( ).toString( ) ); throw new RedbackServiceException( - ErrorMessage.of( MessageKeys.ERR_USER_EXISTS, user.getUserId() ), 303 ); + ErrorMessage.of( MessageKeys.ERR_USER_EXISTS, user.getUserId( ) ), 303 ); } } catch ( UserNotFoundException e ) { //ignore we just want to prevent non human readable error message from backend :-) - log.debug( "user {} not exists", user.getUserId() ); + log.debug( "user {} not exists", user.getUserId( ) ); } catch ( UserManagerException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_UNKNOWN, e.getMessage() ) ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_UNKNOWN, e.getMessage( ) ) ); } // data validation - if ( StringUtils.isEmpty( user.getUserId() ) ) + if ( StringUtils.isEmpty( user.getUserId( ) ) ) { throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_ID_EMPTY ), 422 ); } - if ( StringUtils.isEmpty( user.getFullName() ) ) + if ( StringUtils.isEmpty( user.getFullName( ) ) ) { throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_FULL_NAME_EMPTY ), 422 ); } - if ( StringUtils.isEmpty( user.getEmail() ) ) + if ( StringUtils.isEmpty( user.getEmail( ) ) ) { throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_EMAIL_EMPTY ), 422 ); } @@ -259,39 +266,39 @@ public class DefaultUserService { org.apache.archiva.redback.users.User u = - userManager.createUser( user.getUserId(), user.getFullName(), user.getEmail() ); - u.setPassword( user.getPassword() ); - u.setLocked( user.isLocked() ); - u.setPasswordChangeRequired( user.isPasswordChangeRequired() ); - u.setValidated( user.isValidated() ); + userManager.createUser( user.getUserId( ), user.getFullName( ), user.getEmail( ) ); + u.setPassword( user.getPassword( ) ); + u.setLocked( user.isLocked( ) ); + u.setPasswordChangeRequired( user.isPasswordChangeRequired( ) ); + u.setValidated( user.isValidated( ) ); u = userManager.addUser( u ); - if ( !user.isPasswordChangeRequired() ) + if ( !user.isPasswordChangeRequired( ) ) { u.setPasswordChangeRequired( false ); try { u = userManager.updateUser( u ); - log.debug( "user {} created", u.getUsername() ); + log.debug( "user {} created", u.getUsername( ) ); } catch ( UserNotFoundException e ) { - throw new RedbackServiceException( e.getMessage() ); + throw new RedbackServiceException( e.getMessage( ) ); } } - roleManager.assignRole( RedbackRoleConstants.REGISTERED_USER_ROLE_ID, u.getUsername() ); + roleManager.assignRole( RedbackRoleConstants.REGISTERED_USER_ROLE_ID, u.getUsername( ) ); result = getRestUser( u ); httpServletResponse.setStatus( 201 ); - httpServletResponse.setHeader( "Location", uriInfo.getAbsolutePathBuilder().path( user.getUserId() ).build( ).toString() ); + httpServletResponse.setHeader( "Location", uriInfo.getAbsolutePathBuilder( ).path( user.getUserId( ) ).build( ).toString( ) ); } catch ( RoleManagerException rpe ) { - log.error( "RoleProfile Error: {}", rpe.getMessage(), rpe ); + log.error( "RoleProfile Error: {}", rpe.getMessage( ), rpe ); throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_ASSIGN_ROLE ) ); } catch ( UserManagerException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_UNKNOWN, e.getMessage() ) ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_UNKNOWN, e.getMessage( ) ) ); } return result; } @@ -313,7 +320,7 @@ public class DefaultUserService } catch ( RbacManagerException e ) { - log.error( e.getMessage(), e ); + log.error( e.getMessage( ), e ); throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_RBACMANAGER_FAIL, e.getMessage( ) ) ); } try @@ -322,7 +329,7 @@ public class DefaultUserService } catch ( UserNotFoundException e ) { - log.error( e.getMessage(), e ); + log.error( e.getMessage( ), e ); throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_NOT_FOUND ), 404 ); } catch ( UserManagerException e ) @@ -343,7 +350,8 @@ public class DefaultUserService { try { - if ("guest".equals(userId)) { + if ( "guest".equals( userId ) ) + { return getRestUser( userManager.getGuestUser( ) ); } org.apache.archiva.redback.users.User user = userManager.findUser( userId ); @@ -355,34 +363,42 @@ public class DefaultUserService } catch ( UserManagerException e ) { - throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) ); + throw new RedbackServiceException( new ErrorMessage( e.getMessage( ) ) ); } } - Comparator getAttributeComparator(String attributeName) { + Comparator getAttributeComparator( String attributeName ) + { return ORDER_MAP.get( attributeName ); } - Comparator getComparator( List orderBy, boolean ascending) { - if (ascending) + Comparator getComparator( List orderBy, boolean ascending ) + { + if ( ascending ) { 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 getFilter(final String attribute, final String queryToken) { - if (FILTER_MAP.containsKey( attribute )) + static Predicate getFilter( final String attribute, final String queryToken ) + { + if ( FILTER_MAP.containsKey( attribute ) ) { return ( org.apache.archiva.redback.users.User u ) -> FILTER_MAP.get( attribute ).test( queryToken, u ); - } else { + } + else + { return Arrays.stream( DEFAULT_SEARCH_FIELDS ) .map( att -> getFilter( att, queryToken ) ).reduce( Predicate::or ).get( ); } } - Predicate getUserFilter(String queryTerms) { + Predicate getUserFilter( String queryTerms ) + { return Arrays.stream( queryTerms.split( "\\s+" ) ) .map( s -> { if ( s.contains( ":" ) ) @@ -397,12 +413,12 @@ public class DefaultUserService .map( att -> getFilter( att, s ) ).reduce( Predicate::or ).get( ); } } - ).reduce( Predicate::or ).get(); + ).reduce( Predicate::or ).get( ); } @Override - public PagedResult getUsers(String q, Integer offset, - Integer limit, List orderBy, String order) + public PagedResult getUsers( String q, Integer offset, + Integer limit, List orderBy, String order ) throws RedbackServiceException { boolean ascending = !"desc".equals( order ); @@ -410,19 +426,19 @@ public class DefaultUserService { // UserQuery does not work here, because the configurable user manager does only return the query for // the first user manager in the list. So we have to fetch the whole user list - List rawUsers =userManager.getUsers( ); + List rawUsers = userManager.getUsers( ); Predicate filter = getUserFilter( q ); - long size = rawUsers.stream().filter(filter ).count(); + long size = rawUsers.stream( ).filter( filter ).count( ); List users = rawUsers.stream( ) .filter( filter ) .sorted( getComparator( orderBy, ascending ) ).skip( offset ).limit( limit ) .map( user -> getRestUser( user ) ) .collect( Collectors.toList( ) ); - return new PagedResult<>( (int)size, offset, limit, users ); + return new PagedResult<>( (int) size, offset, limit, users ); } catch ( UserManagerException e ) { - throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) ); + throw new RedbackServiceException( new ErrorMessage( e.getMessage( ) ) ); } } @@ -431,21 +447,22 @@ public class DefaultUserService throws RedbackServiceException { RedbackPrincipal principal = getPrincipal( ); - if (principal==null) { + if ( principal == null ) + { throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_UNAUTHORIZED_REQUEST ), 401 ); } // check oldPassword with the current one // only 3 fields to update // ui can limit to not update password - org.apache.archiva.redback.users.User foundUser = updateUser( principal.getName(), realUser -> { + org.apache.archiva.redback.users.User foundUser = updateUser( principal.getName( ), realUser -> { try { // current password is only needed, if password change is requested if ( StringUtils.isNotBlank( user.getPassword( ) ) ) { String previousEncodedPassword = - securitySystem.getUserManager( ).findUser( principal.getName(), false ).getEncodedPassword( ); + securitySystem.getUserManager( ).findUser( principal.getName( ), false ).getEncodedPassword( ); // check oldPassword with the current one @@ -469,11 +486,11 @@ public class DefaultUserService return new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage( ) ) ); } // only 3 fields to update - if (StringUtils.isNotBlank( user.getFullName() )) + if ( StringUtils.isNotBlank( user.getFullName( ) ) ) { realUser.setFullName( user.getFullName( ) ); } - if (StringUtils.isNotBlank( user.getEmail() )) + if ( StringUtils.isNotBlank( user.getEmail( ) ) ) { realUser.setEmail( user.getEmail( ) ); } @@ -489,17 +506,18 @@ public class DefaultUserService } @Override - public UserInfo getLoggedInUser( ) + public UserInfo getLoggedInUser( ) throws RedbackServiceException { RedbackPrincipal principal = getPrincipal( ); - if (principal==null) { + if ( principal == null ) + { throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_UNAUTHORIZED_REQUEST ), 401 ); } try { - org.apache.archiva.redback.users.User foundUser = userManager.findUser( principal.getUser().getUsername(), false ); + org.apache.archiva.redback.users.User foundUser = userManager.findUser( principal.getUser( ).getUsername( ), false ); return getRestUser( foundUser ); } catch ( UserManagerException e ) @@ -509,21 +527,21 @@ public class DefaultUserService } @Override - public UserInfo updateUser( String userId, User user ) + public UserInfo updateUser( String userId, User user ) throws RedbackServiceException { try { org.apache.archiva.redback.users.User rawUser = userManager.findUser( userId, false ); - if (user.getFullName()!=null) - rawUser.setFullName( user.getFullName() ); - if (user.getEmail()!=null) - rawUser.setEmail( user.getEmail() ); - rawUser.setValidated( user.isValidated() ); - rawUser.setLocked( user.isLocked() ); + if ( user.getFullName( ) != null ) + rawUser.setFullName( user.getFullName( ) ); + if ( user.getEmail( ) != null ) + rawUser.setEmail( user.getEmail( ) ); + rawUser.setValidated( user.isValidated( ) ); + rawUser.setLocked( user.isLocked( ) ); if ( !StringUtils.isEmpty( user.getPassword( ) ) ) - rawUser.setPassword( user.getPassword() ); - rawUser.setPasswordChangeRequired( user.isPasswordChangeRequired() ); + rawUser.setPassword( user.getPassword( ) ); + rawUser.setPasswordChangeRequired( user.isPasswordChangeRequired( ) ); org.apache.archiva.redback.users.User updatedUser = userManager.updateUser( rawUser ); @@ -532,13 +550,15 @@ public class DefaultUserService catch ( UserNotFoundException e ) { throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_NOT_FOUND ), 404 ); - } catch ( PasswordRuleViolationException e ) { - List messages = e.getViolations( ).getViolations( ).stream( ).map( m -> ErrorMessage.of( m.getKey( ), m.getArgs( ) ) ).collect( Collectors.toList() ); + } + catch ( PasswordRuleViolationException e ) + { + List messages = e.getViolations( ).getViolations( ).stream( ).map( m -> ErrorMessage.of( m.getKey( ), m.getArgs( ) ) ).collect( Collectors.toList( ) ); throw new RedbackServiceException( messages, 422 ); } catch ( UserManagerException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage() ), 400 ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage( ) ), 400 ); } } @@ -559,13 +579,13 @@ public class DefaultUserService usersCache.remove( userId ); } - CacheManager cacheManager = CacheManager.getInstance(); - String[] caches = cacheManager.getCacheNames(); + CacheManager cacheManager = CacheManager.getInstance( ); + String[] caches = cacheManager.getCacheNames( ); for ( String cacheName : caches ) { if ( StringUtils.startsWith( cacheName, "org.apache.archiva.redback.rbac.jdo" ) ) { - cacheManager.getCache( cacheName ).removeAll(); + cacheManager.getCache( cacheName ).removeAll( ); } } @@ -573,7 +593,7 @@ public class DefaultUserService } @Override - public PingResult ping() + public PingResult ping( ) throws RedbackServiceException { return new PingResult( true ); @@ -593,24 +613,25 @@ public class DefaultUserService throws RedbackServiceException { UserInfo result; - if ( getAdminStatus().isExists() ) + if ( getAdminStatus( ).isExists( ) ) { log.warn( "Admin user exists already" ); - httpServletResponse.setHeader( "Location", uriInfo.getAbsolutePath().toString() ); + httpServletResponse.setHeader( "Location", uriInfo.getAbsolutePath( ).toString( ) ); throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_ADMIN_EXISTS ), 303 ); } - log.debug("Creating admin admin user '{}'", adminUser.getUserId()); - if (!RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME.equals(adminUser.getUserId())) { - log.error("Wrong admin user name {}", adminUser.getUserId()); - throw new RedbackServiceException(ErrorMessage.of( MessageKeys.ERR_USER_ADMIN_BAD_NAME ), 422); + log.debug( "Creating admin admin user '{}'", adminUser.getUserId( ) ); + if ( !RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME.equals( adminUser.getUserId( ) ) ) + { + log.error( "Wrong admin user name {}", adminUser.getUserId( ) ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_ADMIN_BAD_NAME ), 422 ); } try { org.apache.archiva.redback.users.User user = - userManager.createUser( RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME, adminUser.getFullName(), - adminUser.getEmail() ); - user.setPassword( adminUser.getPassword() ); + userManager.createUser( RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME, adminUser.getFullName( ), + adminUser.getEmail( ) ); + user.setPassword( adminUser.getPassword( ) ); user.setLocked( false ); user.setPasswordChangeRequired( false ); @@ -619,7 +640,7 @@ public class DefaultUserService userManager.addUser( user ); result = getRestUser( user ); - roleManager.assignRole( "system-administrator", user.getUsername() ); + roleManager.assignRole( "system-administrator", user.getUsername( ) ); } catch ( RoleManagerException e ) { @@ -627,24 +648,26 @@ public class DefaultUserService } catch ( UserManagerException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage() ), 400 ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage( ) ), 400 ); } httpServletResponse.setStatus( 201 ); - httpServletResponse.setHeader( "Location", uriInfo.getAbsolutePath().toString() ); + httpServletResponse.setHeader( "Location", uriInfo.getAbsolutePath( ).toString( ) ); return result; } @Override - public AvailabilityStatus getAdminStatus() + public AvailabilityStatus getAdminStatus( ) throws RedbackServiceException { try { org.apache.archiva.redback.users.User user = userManager.findUser( config.getString( UserConfigurationKeys.DEFAULT_ADMIN ) ); - if (user.getAccountCreationDate()!=null) + if ( user.getAccountCreationDate( ) != null ) { return new AvailabilityStatus( true, user.getAccountCreationDate( ).toInstant( ) ); - } else { + } + else + { return new AvailabilityStatus( true ); } } @@ -654,13 +677,13 @@ public class DefaultUserService } catch ( UserManagerException e ) { - Throwable cause = e.getCause(); + Throwable cause = e.getCause( ); if ( cause != null && cause instanceof UserNotFoundException ) { return new AvailabilityStatus( false ); } - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage() ), 400 ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage( ) ), 400 ); } return new AvailabilityStatus( false ); } @@ -675,20 +698,20 @@ public class DefaultUserService throw new RedbackServiceException( new ErrorMessage( "username.cannot.be.empty" ) ); } - UserManager userManager = securitySystem.getUserManager(); - KeyManager keyManager = securitySystem.getKeyManager(); - UserSecurityPolicy policy = securitySystem.getPolicy(); + UserManager userManager = securitySystem.getUserManager( ); + KeyManager keyManager = securitySystem.getKeyManager( ); + UserSecurityPolicy policy = securitySystem.getPolicy( ); try { org.apache.archiva.redback.users.User user = userManager.findUser( username ); AuthenticationKey authkey = keyManager.createKey( username, "Password Reset Request", - policy.getUserValidationSettings().getEmailValidationTimeout() ); + policy.getUserValidationSettings( ).getEmailValidationTimeout( ) ); String applicationUrl = getBaseUrl( ); - mailer.sendPasswordResetEmail( Arrays.asList( user.getEmail() ), authkey, applicationUrl ); + mailer.sendPasswordResetEmail( Arrays.asList( user.getEmail( ) ), authkey, applicationUrl ); log.info( "password reset request for username {}", username ); } catch ( UserNotFoundException e ) @@ -699,11 +722,11 @@ public class DefaultUserService catch ( KeyManagerException e ) { log.info( "Unable to issue password reset.", e ); - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_PASSWD_RESET_FAILED, e.getMessage() ), 400 ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_PASSWD_RESET_FAILED, e.getMessage( ) ), 400 ); } catch ( UserManagerException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage() ), 400 ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage( ) ), 400 ); } return ActionStatus.SUCCESS; @@ -713,16 +736,16 @@ public class DefaultUserService public RegistrationKey registerUser( String userId, UserRegistrationRequest userRegistrationRequest ) throws RedbackServiceException { - User user = userRegistrationRequest.getUser(); + User user = userRegistrationRequest.getUser( ); if ( user == null ) { throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_NOT_FOUND, userId ), 404 ); } - UserSecurityPolicy securityPolicy = securitySystem.getPolicy(); + UserSecurityPolicy securityPolicy = securitySystem.getPolicy( ); - boolean emailValidationRequired = securityPolicy.getUserValidationSettings().isEmailValidationRequired(); + boolean emailValidationRequired = securityPolicy.getUserValidationSettings( ).isEmailValidationRequired( ); if ( emailValidationRequired ) { @@ -740,27 +763,27 @@ public class DefaultUserService // NOTE: Do not perform Password Rules Validation Here. - if ( userManager.userExists( user.getUserId() ) ) + if ( userManager.userExists( user.getUserId( ) ) ) { throw new RedbackServiceException( - new ErrorMessage( "user.already.exists", new String[]{ user.getUserId() } ) ); + new ErrorMessage( "user.already.exists", new String[]{user.getUserId( )} ) ); } - u = userManager.createUser( user.getUserId(), user.getFullName(), user.getEmail() ); - u.setPassword( user.getPassword() ); + u = userManager.createUser( user.getUserId( ), user.getFullName( ), user.getEmail( ) ); + u.setPassword( user.getPassword( ) ); u.setValidated( false ); u.setLocked( false ); - roleManager.assignRole( RedbackRoleConstants.REGISTERED_USER_ROLE_ID, u.getUsername() ); + roleManager.assignRole( RedbackRoleConstants.REGISTERED_USER_ROLE_ID, u.getUsername( ) ); } catch ( RoleManagerException rpe ) { - log.error( "RoleProfile Error: {}", rpe.getMessage(), rpe ); + log.error( "RoleProfile Error: {}", rpe.getMessage( ), rpe ); throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_REGISTRATION_ROLE_ASSIGNMENT_FAILED, rpe.getMessage( ) ), 400 ); } catch ( UserManagerException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage() ), 400 ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage( ) ), 400 ); } if ( emailValidationRequired ) @@ -770,32 +793,32 @@ public class DefaultUserService try { AuthenticationKey authkey = - securitySystem.getKeyManager().createKey( u.getUsername(), "New User Email Validation", - securityPolicy.getUserValidationSettings().getEmailValidationTimeout() ); + securitySystem.getKeyManager( ).createKey( u.getUsername( ), "New User Email Validation", + securityPolicy.getUserValidationSettings( ).getEmailValidationTimeout( ) ); - String baseUrl = userRegistrationRequest.getApplicationUrl(); + String baseUrl = userRegistrationRequest.getApplicationUrl( ); if ( StringUtils.isBlank( baseUrl ) ) { - baseUrl = getBaseUrl(); + baseUrl = getBaseUrl( ); } - log.debug( "register user {} with email {} and app url {}", u.getUsername(), u.getEmail(), baseUrl ); + log.debug( "register user {} with email {} and app url {}", u.getUsername( ), u.getEmail( ), baseUrl ); - mailer.sendAccountValidationEmail( Arrays.asList( u.getEmail() ), authkey, baseUrl ); + mailer.sendAccountValidationEmail( Arrays.asList( u.getEmail( ) ), authkey, baseUrl ); securityPolicy.setEnabled( false ); userManager.addUser( u ); - return new RegistrationKey( authkey.getKey(), true ); + return new RegistrationKey( authkey.getKey( ), true ); } catch ( KeyManagerException e ) { log.error( "Unable to register a new user.", e ); - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_KEYMANAGER_FAIL, e.getMessage() ), 400 ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_KEYMANAGER_FAIL, e.getMessage( ) ), 400 ); } catch ( UserManagerException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage() ), 400 ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage( ) ), 400 ); } finally { @@ -811,7 +834,7 @@ public class DefaultUserService } catch ( UserManagerException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage() ), 400 ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage( ) ), 400 ); } } @@ -829,11 +852,11 @@ public class DefaultUserService public Collection getCurrentUserPermissions( ) throws RedbackServiceException { - RedbackRequestInformation redbackRequestInformation = RedbackAuthenticationThreadLocal.get(); + RedbackRequestInformation redbackRequestInformation = RedbackAuthenticationThreadLocal.get( ); String userName = UserManager.GUEST_USERNAME; - if ( redbackRequestInformation != null && redbackRequestInformation.getUser() != null ) + if ( redbackRequestInformation != null && redbackRequestInformation.getUser( ) != null ) { - userName = redbackRequestInformation.getUser().getUsername(); + userName = redbackRequestInformation.getUser( ).getUsername( ); } else { @@ -847,11 +870,11 @@ public class DefaultUserService public Collection getCurrentUserOperations( ) throws RedbackServiceException { - RedbackRequestInformation redbackRequestInformation = RedbackAuthenticationThreadLocal.get(); + RedbackRequestInformation redbackRequestInformation = RedbackAuthenticationThreadLocal.get( ); String userName = UserManager.GUEST_USERNAME; - if ( redbackRequestInformation != null && redbackRequestInformation.getUser() != null ) + if ( redbackRequestInformation != null && redbackRequestInformation.getUser( ) != null ) { - userName = redbackRequestInformation.getUser().getUsername(); + userName = redbackRequestInformation.getUser( ).getUsername( ); } else { @@ -867,54 +890,58 @@ public class DefaultUserService String principal = null; try { - AuthenticationKey authkey = securitySystem.getKeyManager().findKey( key ); + AuthenticationKey authkey = securitySystem.getKeyManager( ).findKey( key ); 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 ); } user.setValidated( true ); user.setLocked( false ); user.setPasswordChangeRequired( true ); user.setEncodedPassword( "" ); - securitySystem.getUserManager().updateUser( user ); - principal = user.getUsername(); + securitySystem.getUserManager( ).updateUser( user ); + principal = user.getUsername( ); - TokenBasedAuthenticationDataSource authsource = new TokenBasedAuthenticationDataSource(); + TokenBasedAuthenticationDataSource authsource = new TokenBasedAuthenticationDataSource( ); authsource.setPrincipal( principal ); - authsource.setToken( authkey.getKey() ); + authsource.setToken( authkey.getKey( ) ); authsource.setEnforcePasswordChange( false ); - VerificationStatus status = new VerificationStatus(false ); + VerificationStatus status = new VerificationStatus( false ); SecuritySession authStatus = securitySystem.authenticate( authsource ); - if (authStatus.isAuthenticated()) { + if ( authStatus.isAuthenticated( ) ) + { Token accessToken = jwtAuthenticator.generateToken( principal ); - status.setAccessToken( accessToken.getData() ); + status.setAccessToken( accessToken.getData( ) ); status.setSuccess( true ); - } else { + } + else + { user.setValidated( false ); user.setLocked( true ); user.setPasswordChangeRequired( false ); - securitySystem.getUserManager().updateUser( user ); + securitySystem.getUserManager( ).updateUser( user ); } - log.info( "account validated for user {}", user.getUsername() ); + log.info( "account validated for user {}", user.getUsername( ) ); return status; } catch ( MustChangePasswordException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_PASSWORD_CHANGE_REQUIRED ), Response.Status.FORBIDDEN.getStatusCode() ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_PASSWORD_CHANGE_REQUIRED ), Response.Status.FORBIDDEN.getStatusCode( ) ); } catch ( AccountLockedException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_ACCOUNT_LOCKED ), Response.Status.FORBIDDEN.getStatusCode() ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_ACCOUNT_LOCKED ), Response.Status.FORBIDDEN.getStatusCode( ) ); } catch ( AuthenticationException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_INVALID_CREDENTIALS ), Response.Status.FORBIDDEN.getStatusCode() ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_INVALID_CREDENTIALS ), Response.Status.FORBIDDEN.getStatusCode( ) ); } catch ( KeyNotFoundException e ) { @@ -933,7 +960,7 @@ public class DefaultUserService } catch ( UserManagerException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage() ), 400 ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage( ) ), 400 ); } } @@ -945,10 +972,10 @@ public class DefaultUserService List operations = new ArrayList<>( permissions.size( ) ); for ( Permission permission : permissions ) { - if ( permission.getOperation() != null ) + if ( permission.getOperation( ) != null ) { - Operation operation = new Operation(); - operation.setName( permission.getOperation().getName() ); + Operation operation = new Operation( ); + operation.setName( permission.getOperation( ).getName( ) ); operations.add( operation ); } } @@ -967,21 +994,21 @@ public class DefaultUserService List userPermissions = new ArrayList<>( permissions.size( ) ); for ( org.apache.archiva.redback.rbac.Permission p : permissions ) { - Permission permission = new Permission(); - permission.setName( p.getName() ); + Permission permission = new Permission( ); + permission.setName( p.getName( ) ); - if ( p.getOperation() != null ) + if ( p.getOperation( ) != null ) { - Operation operation = new Operation(); - operation.setName( p.getOperation().getName() ); + Operation operation = new Operation( ); + operation.setName( p.getOperation( ).getName( ) ); permission.setOperation( operation ); } - if ( p.getResource() != null ) + if ( p.getResource( ) != null ) { - Resource resource = new Resource(); - resource.setIdentifier( p.getResource().getIdentifier() ); - resource.setPattern( p.getResource().isPattern() ); + Resource resource = new Resource( ); + resource.setIdentifier( p.getResource( ).getIdentifier( ) ); + resource.setPattern( p.getResource( ).isPattern( ) ); permission.setResource( resource ); } @@ -991,8 +1018,8 @@ public class DefaultUserService } catch ( RbacManagerException e ) { - log.error( e.getMessage(), e ); - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_RBACMANAGER_FAIL, e.getMessage() ), 400 ); + log.error( e.getMessage( ), e ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_RBACMANAGER_FAIL, e.getMessage( ) ), 400 ); } } @@ -1007,45 +1034,45 @@ public class DefaultUserService { RedbackServiceException redbackServiceException = new RedbackServiceException( "issues during validating user", 422 ); - if ( StringUtils.isEmpty( user.getUserId() ) ) + if ( StringUtils.isEmpty( user.getUserId( ) ) ) { redbackServiceException.addErrorMessage( ErrorMessage.of( MessageKeys.ERR_USER_ID_EMPTY ) ); } else { - if ( !user.getUserId().matches( VALID_USERNAME_CHARS ) ) + if ( !user.getUserId( ).matches( VALID_USERNAME_CHARS ) ) { redbackServiceException.addErrorMessage( ErrorMessage.of( MessageKeys.ERR_USER_ID_INVALID ) ); } } - if ( StringUtils.isEmpty( user.getFullName() ) ) + if ( StringUtils.isEmpty( user.getFullName( ) ) ) { redbackServiceException.addErrorMessage( ErrorMessage.of( MessageKeys.ERR_USER_FULL_NAME_EMPTY ) ); } - if ( StringUtils.isEmpty( user.getEmail() ) ) + if ( StringUtils.isEmpty( user.getEmail( ) ) ) { redbackServiceException.addErrorMessage( ErrorMessage.of( MessageKeys.ERR_USER_EMAIL_EMPTY ) ); } - if ( !StringUtils.equals( user.getPassword(), user.getConfirmPassword() ) ) + if ( !StringUtils.equals( user.getPassword( ), user.getConfirmPassword( ) ) ) { redbackServiceException.addErrorMessage( ErrorMessage.of( MessageKeys.ERR_AUTH_INVALID_CREDENTIALS, "nomatch" ) ); } try { - if ( !StringUtils.isEmpty( user.getEmail() ) ) + if ( !StringUtils.isEmpty( user.getEmail( ) ) ) { - new InternetAddress( user.getEmail(), true ); + new InternetAddress( user.getEmail( ), true ); } } catch ( AddressException e ) { redbackServiceException.addErrorMessage( ErrorMessage.of( MessageKeys.ERR_USER_EMAIL_INVALID ) ); } - if ( !redbackServiceException.getErrorMessages().isEmpty() ) + if ( !redbackServiceException.getErrorMessages( ).isEmpty( ) ) { throw redbackServiceException; } @@ -1058,33 +1085,33 @@ public class DefaultUserService try { org.apache.archiva.redback.users.User tmpuser = - userManager.createUser( user.getUserId(), user.getFullName(), user.getEmail() ); + userManager.createUser( user.getUserId( ), user.getFullName( ), user.getEmail( ) ); - user.setPassword( user.getPassword() ); + user.setPassword( user.getPassword( ) ); - securitySystem.getPolicy().validatePassword( tmpuser ); + securitySystem.getPolicy( ).validatePassword( tmpuser ); - if ( ( StringUtils.isEmpty( user.getPassword() ) ) ) + if ( ( StringUtils.isEmpty( user.getPassword( ) ) ) ) { throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_INVALID_CREDENTIALS, "empty" ) ); } } catch ( UserManagerException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_INVALID_CREDENTIALS, e.getMessage() ) ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_AUTH_INVALID_CREDENTIALS, e.getMessage( ) ) ); } } - private String getBaseUrl() + private String getBaseUrl( ) { if ( httpServletRequest != null ) { if ( httpServletRequest != null ) { - return httpServletRequest.getScheme() + "://" + httpServletRequest.getServerName() + ( - httpServletRequest.getServerPort() == 80 + return httpServletRequest.getScheme( ) + "://" + httpServletRequest.getServerName( ) + ( + httpServletRequest.getServerPort( ) == 80 ? "" - : ":" + httpServletRequest.getServerPort() ) + httpServletRequest.getContextPath(); + : ":" + httpServletRequest.getServerPort( ) ) + httpServletRequest.getContextPath( ); } } return null; @@ -1100,11 +1127,14 @@ public class DefaultUserService if ( rawUser != null ) { RedbackServiceException result = updateFunction.apply( rawUser ); - if (result!=null) { + if ( result != null ) + { throw result; } userManager.updateUser( rawUser, false ); - } else { + } + else + { throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USER_NOT_FOUND, userId ), 404 ); } return rawUser; @@ -1115,7 +1145,7 @@ public class DefaultUserService } catch ( UserManagerException e ) { - throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage() ) ); + throw new RedbackServiceException( ErrorMessage.of( MessageKeys.ERR_USERMANAGER_FAIL, e.getMessage( ) ) ); } } diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/resources/META-INF/spring-context.xml b/redback-integrations/redback-rest/redback-rest-services/src/main/resources/META-INF/spring-context.xml index 42198d7c..c014be23 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/resources/META-INF/spring-context.xml +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/resources/META-INF/spring-context.xml @@ -43,12 +43,18 @@ + + + + + + @@ -94,8 +100,7 @@ - - + diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/AbstractNativeRestServices.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/AbstractNativeRestServices.java index 442224a6..2adc1e76 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/AbstractNativeRestServices.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/AbstractNativeRestServices.java @@ -18,9 +18,15 @@ package org.apache.archiva.redback.rest.services.v2; * 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 io.restassured.RestAssured; 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.specification.RequestSpecification; import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants; @@ -45,6 +51,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.ContextLoaderListener; +import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; @@ -330,6 +337,18 @@ public abstract class AbstractNativeRestServices String basePath = getBasePath( ); this.requestSpec = getRequestSpecBuilder( ).build( ); 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( ) { diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/AbstractRestServicesTestV2.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/AbstractRestServicesTestV2.java index ee4f19a0..b090b604 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/AbstractRestServicesTestV2.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/AbstractRestServicesTestV2.java @@ -20,6 +20,7 @@ package org.apache.archiva.redback.rest.services.v2; */ 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.module.jaxb.JaxbAnnotationIntrospector; @@ -146,6 +147,7 @@ public abstract class AbstractRestServicesTestV2 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 ); provider.setMapper( mapper ); return provider; } diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/GroupServiceTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/GroupServiceTest.java index 2b5f8ef2..0966ecc4 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/GroupServiceTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/GroupServiceTest.java @@ -18,7 +18,11 @@ package org.apache.archiva.redback.rest.services.v2; * 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.module.jaxb.JaxbAnnotationIntrospector; import org.apache.archiva.components.apacheds.ApacheDs; import org.apache.archiva.redback.rest.api.model.v2.GroupMapping; 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.InitialDirContext; import javax.ws.rs.core.MediaType; +import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -77,12 +82,27 @@ public class GroupServiceTest 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 ) { GroupService service = JAXRSClientFactory.create( "http://localhost:" + getServerPort( ) + "/" + getRestServicesPath( ) + "/v2/redback/", GroupService.class, - Collections.singletonList( new JacksonJaxbJsonProvider( ) ) ); + Collections.singletonList( getJsonProvider() ) ); // for debuging purpose WebClient.getConfig( service ).getHttpConduit( ).getClient( ).setReceiveTimeout( getTimeout( ) ); diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeAuthenticationServiceTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeAuthenticationServiceTest.java index 48ebab5f..9c0eda00 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeAuthenticationServiceTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeAuthenticationServiceTest.java @@ -78,8 +78,8 @@ public class NativeAuthenticationServiceTest extends AbstractNativeRestServices .then( ).assertThat( ).statusCode( 200 ).and( ) .contentType( JSON ). body( "success", equalTo( true ) ) - .body( "requestTime", notNullValue( ) ).extract().response(); - OffsetDateTime dateTime = OffsetDateTime.parse( response.body( ).jsonPath( ).getString( "requestTime" ) ); + .body( "request_time", notNullValue( ) ).extract().response(); + OffsetDateTime dateTime = OffsetDateTime.parse( response.body( ).jsonPath( ).getString( "request_time" ) ); Instant afterCall = Instant.now( ); assertTrue( dateTime.toInstant( ).isAfter( beforeCall ) ); assertTrue( dateTime.toInstant( ).isBefore( afterCall ) ); diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeGroupServiceTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeGroupServiceTest.java index 4129adbf..96d25dd0 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeGroupServiceTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeGroupServiceTest.java @@ -266,7 +266,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices 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 { if ( !exists( context, dn ) ) @@ -276,7 +276,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices objectClass.add( "top" ); objectClass.add( "groupOfUniqueNames" ); attributes.put( objectClass ); - attributes.put( "cn", groupName ); + attributes.put( "cn", group_name ); BasicAttribute basicAttribute = new BasicAttribute( "uniquemember" ); basicAttribute.add( "uid=admin," + peopleSuffix ); @@ -324,7 +324,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices assertNotNull( data ); assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) ); 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( ) ); String[] values = data.stream( ).map( ldapInfo -> ldapInfo.getName( ) ).sorted( ).collect( Collectors.toList( ) ).toArray( new String[0] ); assertArrayEquals( getTestGroupList( ).toArray( new String[0] ), values ); @@ -345,7 +345,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices assertNotNull( data ); assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) ); 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( ) ); 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 ); @@ -364,7 +364,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices assertNotNull( data ); assertEquals( Integer.valueOf( 2 ), response.body( ).jsonPath( ).get( "pagination.offset" ) ); 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( ) ); 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 ); @@ -390,7 +390,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices try { Map jsonAsMap = new HashMap<>( ); - jsonAsMap.put( "groupName", "ldap group" ); + jsonAsMap.put( "group_name", "ldap group" ); jsonAsMap.put( "roles", Arrays.asList( "role1", "role2" ) ); Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -417,7 +417,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices try { Map jsonAsMap = new HashMap<>( ); - jsonAsMap.put( "groupName", "ldap group" ); + jsonAsMap.put( "group_name", "ldap group" ); jsonAsMap.put( "roles", Arrays.asList( "role1", "role2" ) ); Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -457,7 +457,7 @@ public class NativeGroupServiceTest extends AbstractNativeRestServices } finally { // Put it back Map jsonAsMap = new HashMap<>( ); - jsonAsMap.put( "groupName", "archiva-admin" ); + jsonAsMap.put( "group_name", "archiva-admin" ); jsonAsMap.put( "roles", Arrays.asList( "System Administrator" ) ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeUserServiceTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeUserServiceTest.java index 3f9e93c0..e8f6cefd 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeUserServiceTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeUserServiceTest.java @@ -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.Permission; 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.VerificationStatus; import org.apache.archiva.redback.rest.services.mock.EmailMessage; @@ -89,7 +88,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices assertEquals( 2, userData.size( ) ); assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) ); 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 @@ -114,9 +113,9 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" + suffix ); 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" ); - Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) + given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) .when( ) .post( ) @@ -127,7 +126,6 @@ public class NativeUserServiceTest extends AbstractNativeRestServices @Test void getMultipleUsersWithoutParams( ) { - Map params = new HashMap<>( ); Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .when( ).get( ).then( ).statusCode( 200 ).extract( ).response( ); assertNotNull( response ); @@ -137,7 +135,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices assertEquals( userNum + 2, userData.size( ) ); assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) ); 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( Integer.valueOf( 1 ), response.body( ).jsonPath( ).get( "pagination.offset" ) ); 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 @@ -177,7 +175,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices assertEquals( 5, userData.size( ) ); assertEquals( Integer.valueOf( 3 ), response.body( ).jsonPath( ).get( "pagination.offset" ) ); 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 @@ -186,7 +184,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices HashMap params = new HashMap<>( ); params.put( "limit", Integer.toString( 8 ) ); params.put( "offset", Integer.toString( 10 ) ); - params.put( "orderBy", "fullName" ); + params.put( "orderBy", "full_name" ); Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .when( ).params( params ).get( ).then( ).statusCode( 200 ).extract( ).response( ); List userData = response.body( ).jsonPath( ).getList( "data", UserInfo.class ); @@ -198,7 +196,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices assertEquals( 8, userData.size( ) ); assertEquals( Integer.valueOf( 10 ), response.body( ).jsonPath( ).get( "pagination.offset" ) ); 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 @@ -217,7 +215,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices assertEquals( 10, userData.size( ) ); assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) ); 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 void getMultipleUsersWithPagingAndQuery( ) { @@ -236,7 +234,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices assertEquals( 2, userData.size( ) ); assertEquals( Integer.valueOf( 0 ), response.body( ).jsonPath( ).get( "pagination.offset" ) ); 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 ); assertEquals( "jpa:admin", response.body( ).jsonPath( ).get( "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 @@ -290,7 +288,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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" ); Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -315,7 +313,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "" ); 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" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -332,7 +330,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "me" ); jsonAsMap.put( "email", "me@lordoftherings.org" ); - jsonAsMap.put( "fullName", "Its just me" ); + jsonAsMap.put( "full_name", "Its just me" ); jsonAsMap.put( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -352,7 +350,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) @@ -367,7 +365,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "arwen" ); 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" ); given( ).spec( getRequestSpec( userToken ) ).contentType( JSON ) .body( jsonAsMap ) @@ -394,7 +392,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) @@ -407,7 +405,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); @@ -436,7 +434,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -465,7 +463,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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" ); given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON ) .body( jsonAsMap ) @@ -494,7 +492,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -506,7 +504,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices { jsonAsMap = new HashMap<>( ); 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" ); Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -530,7 +528,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices String token = getAdminToken( ); HashMap jsonAsMap = new HashMap<>( ); 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" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -546,7 +544,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -558,7 +556,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices { jsonAsMap = new HashMap<>( ); 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" ); Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -567,7 +565,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices .prettyPeek( ) .then( ).statusCode( 422 ).extract( ).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 { @@ -585,7 +583,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "admin" ); jsonAsMap.put( "email", "admin@lordoftherings.org" ); - jsonAsMap.put( "fullName", "Admin" ); + jsonAsMap.put( "full_name", "Admin" ); jsonAsMap.put( "password", "pAssw0rD" ); Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -616,7 +614,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) @@ -658,7 +656,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) @@ -705,7 +703,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) @@ -721,7 +719,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .get( "aragorn" ) .then( ).statusCode( 200 ).extract( ).response( ); - assertTrue( response.getBody( ).jsonPath( ).getBoolean( "passwordChangeRequired" ) ); + assertTrue( response.getBody( ).jsonPath( ).getBoolean( "password_change_required" ) ); } finally { @@ -738,9 +736,9 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "passwordChangeRequired", true ); + jsonAsMap.put( "password_change_required", true ); jsonAsMap.put( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -750,7 +748,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .get( "aragorn" ) .then( ).statusCode( 200 ).extract( ).response( ); - assertTrue( response.getBody( ).jsonPath( ).getBoolean( "passwordChangeRequired" ) ); + assertTrue( response.getBody( ).jsonPath( ).getBoolean( "password_change_required" ) ); try { given( ).spec( getRequestSpec( token ) ).contentType( JSON ) @@ -759,7 +757,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .get( "aragorn" ) .then( ).statusCode( 200 ).extract( ).response( ); - assertFalse( response.getBody( ).jsonPath( ).getBoolean( "passwordChangeRequired" ) ); + assertFalse( response.getBody( ).jsonPath( ).getBoolean( "password_change_required" ) ); } finally { @@ -794,10 +792,10 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "validated", true ); - jsonAsMap.put( "passwordChangeRequired", false ); + jsonAsMap.put( "password_change_required", false ); jsonAsMap.put( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -808,10 +806,10 @@ public class NativeUserServiceTest extends AbstractNativeRestServices jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "elrond" ); 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( "validated", true ); - jsonAsMap.put( "passwordChangeRequired", false ); + jsonAsMap.put( "password_change_required", false ); jsonAsMap.put( "password", "pAssw0rDElrond" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -829,7 +827,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .get( "aragorn" ) .then( ).statusCode( 200 ).extract( ).response( ); - assertFalse( response.getBody( ).jsonPath( ).getBoolean( "passwordChangeRequired" ) ); + assertFalse( response.getBody( ).jsonPath( ).getBoolean( "password_change_required" ) ); } finally { @@ -849,10 +847,10 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "validated", true ); - jsonAsMap.put( "passwordChangeRequired", true ); + jsonAsMap.put( "password_change_required", true ); jsonAsMap.put( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -863,10 +861,10 @@ public class NativeUserServiceTest extends AbstractNativeRestServices jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "elrond" ); 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( "validated", true ); - jsonAsMap.put( "passwordChangeRequired", false ); + jsonAsMap.put( "password_change_required", false ); jsonAsMap.put( "password", "pAssw0rDElrond" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .body( jsonAsMap ) @@ -884,7 +882,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON ) .get( "aragorn" ) .then( ).statusCode( 200 ).extract( ).response( ); - assertTrue( response.getBody( ).jsonPath( ).getBoolean( "passwordChangeRequired" ) ); + assertTrue( response.getBody( ).jsonPath( ).getBoolean( "password_change_required" ) ); } finally { @@ -905,7 +903,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) @@ -919,13 +917,13 @@ public class NativeUserServiceTest extends AbstractNativeRestServices String userToken = getUserToken( "aragorn", "pAssw0rD" ); Map updateMap = new HashMap<>( ); 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 ) .body( updateMap ) .when( ) .put( "me" ) .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" ) ); } finally @@ -943,7 +941,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) @@ -958,15 +956,15 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map updateMap = new HashMap<>( ); updateMap.put( "user_id", "aragorn" ); updateMap.put( "email", "aragorn-sweden@lordoftherings.org" ); - updateMap.put( "fullName", "Aragorn King of Sweden" ); - updateMap.put( "currentPassword", "pAssw0rD" ); + updateMap.put( "full_name", "Aragorn King of Sweden" ); + updateMap.put( "current_password", "pAssw0rD" ); updateMap.put( "password", "x1y2z3a4b5c6d8##" ); Response response = given( ).spec( getRequestSpec( userToken ) ).contentType( JSON ) .body( updateMap ) .when( ) .put( "me" ) .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" ) ); userToken = getUserToken( "aragorn", "x1y2z3a4b5c6d8##" ); given( ).spec( getRequestSpec( userToken ) ).contentType( JSON ).get( "aragorn" ) @@ -987,7 +985,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) @@ -1004,7 +1002,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices .get( "me" ) .then( ).statusCode( 200 ).extract( ).response( ); 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" ) ); assertTrue( response.getBody( ).jsonPath( ).getBoolean( "validated" ) ); } @@ -1023,7 +1021,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( token ) ).contentType( JSON ) @@ -1054,7 +1052,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON ) @@ -1087,7 +1085,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON ) @@ -1129,10 +1127,10 @@ public class NativeUserServiceTest extends AbstractNativeRestServices userMap.put( "user_id", "bilbo" ); userMap.put( "email", "bilbo@lordoftherings.org" ); - userMap.put( "fullName", "Bilbo Beutlin" ); + userMap.put( "full_name", "Bilbo Beutlin" ); userMap.put( "validated", true ); userMap.put( "password", "pAssw0rD" ); - userMap.put( "confirmPassword", "pAssw0rD" ); + userMap.put( "confirm_password", "pAssw0rD" ); requestMap.put( "user", userMap ); requestMap.put( "applicationUrl", "http://localhost" ); @@ -1174,7 +1172,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices userMap.put( "user_id", "bilbo" ); userMap.put( "email", "bilbo@lordoftherings.org" ); - userMap.put( "fullName", "Bilbo Beutlin" ); + userMap.put( "full_name", "Bilbo Beutlin" ); userMap.put( "validated", true ); userMap.put( "password", "pAssw0rD" ); userMap.put( "confirmPassword", "xxx" ); @@ -1201,7 +1199,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON ) @@ -1250,7 +1248,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON ) @@ -1287,7 +1285,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON ) @@ -1319,7 +1317,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON ) @@ -1359,7 +1357,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON ) @@ -1392,7 +1390,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON ) @@ -1429,7 +1427,7 @@ public class NativeUserServiceTest extends AbstractNativeRestServices Map jsonAsMap = new HashMap<>( ); jsonAsMap.put( "user_id", "aragorn" ); 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( "password", "pAssw0rD" ); given( ).spec( getRequestSpec( adminToken ) ).contentType( JSON ) @@ -1473,10 +1471,10 @@ public class NativeUserServiceTest extends AbstractNativeRestServices userMap.put( "user_id", "bilbo" ); userMap.put( "email", "bilbo@lordoftherings.org" ); - userMap.put( "fullName", "Bilbo Beutlin" ); + userMap.put( "full_name", "Bilbo Beutlin" ); userMap.put( "validated", true ); userMap.put( "password", "pAssw0rD" ); - userMap.put( "confirmPassword", "pAssw0rD" ); + userMap.put( "confirm_password", "pAssw0rD" ); requestMap.put( "user", userMap ); requestMap.put( "applicationUrl", "http://localhost" );