Fixing tests for rest services

This commit is contained in:
Martin Stockhammer 2017-03-11 11:12:59 +01:00
parent d9146ce8ab
commit a6ee0f8770
7 changed files with 44 additions and 18 deletions

View File

@ -122,6 +122,9 @@ public class RequestValidationInterceptor extends AbstractInterceptor implements
log.info("CSRF Filter is disabled by configuration");
}
checkToken = !config.getBoolean(CFG_REST_CSRF_DISABLE_TOKEN_VALIDATION, false);
if (!checkToken) {
log.info("CSRF Token validation is disabled by configuration");
}
}
@Override

View File

@ -23,10 +23,16 @@ import org.apache.archiva.redback.rest.api.model.LoginRequest;
import org.apache.archiva.redback.rest.api.model.User;
import org.apache.archiva.redback.rest.api.services.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Olivier Lamy
*/
@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration(
locations = { "classpath:/spring-context.xml" } )
public class LoginServiceTest
extends AbstractRestServicesTest
{

View File

@ -25,6 +25,9 @@ import org.apache.archiva.redback.rest.api.services.RoleManagementService;
import org.apache.archiva.redback.rest.api.services.UserService;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.ws.rs.ForbiddenException;
import java.util.Arrays;
@ -34,6 +37,9 @@ import java.util.List;
/**
* @author Olivier Lamy
*/
@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration(
locations = { "classpath:/spring-context.xml" } )
public class RoleManagementServiceTest
extends AbstractRestServicesTest
{

View File

@ -32,6 +32,9 @@ import org.apache.archiva.redback.rest.services.mock.ServicesAssert;
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
import org.apache.cxf.jaxrs.client.WebClient;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.ws.rs.ForbiddenException;
import javax.ws.rs.core.MediaType;
@ -45,6 +48,9 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Olivier Lamy
*/
@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration(
locations = { "classpath:/spring-context.xml" } )
public class UserServiceTest
extends AbstractRestServicesTest
{

View File

@ -16,4 +16,5 @@
# specific language governing permissions and limitations
# under the License.
#
user.manager.impl=jdo
user.manager.impl=jdo
rest.csrffilter.disableTokenValidation=true

View File

@ -23,25 +23,27 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean name="userConfiguration#default" class="org.apache.archiva.redback.configuration.DefaultUserConfiguration"
init-method="initialize">
<property name="configs">
<list>
<value>src/test/resources/security.properties</value>
</list>
</property>
<property name="registry" ref="registry#commons-configuration"/>
</bean>
<bean name="registry#commons-configuration" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry"
init-method="initialize">
</bean>
<alias name="userConfiguration#redback" alias="userConfiguration#default"/>
<bean name="commons-configuration" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry"
init-method="initialize">
<property name="properties">
<value>
<![CDATA[
<configuration>
<system/>
<properties fileName="${basedir}/src/test/resources/security.properties" config-optional="true"
config-at="org.apache.archiva.redback"/>
</configuration>
]]>
</value>
</property>
</bean>
<alias name="authorizer#rbac" alias="authorizer#default"/>
<alias name="userManager#configurable" alias="userManager#default"/>

View File

@ -33,4 +33,6 @@ ldap.config.groups.role.snapshot-manager=Repository Manager - snapshots
ldap.config.groups.role.snapshot-observer=Repository Observer - snapshots
#ldap.config.writable=true
#ldap.config.groups.use.rolename=true
#ldap.config.groups.use.rolename=true
rest.csrffilter.disableTokenValidation=true