Fixing tests for rest services
This commit is contained in:
parent
d9146ce8ab
commit
a6ee0f8770
|
@ -122,6 +122,9 @@ public class RequestValidationInterceptor extends AbstractInterceptor implements
|
||||||
log.info("CSRF Filter is disabled by configuration");
|
log.info("CSRF Filter is disabled by configuration");
|
||||||
}
|
}
|
||||||
checkToken = !config.getBoolean(CFG_REST_CSRF_DISABLE_TOKEN_VALIDATION, false);
|
checkToken = !config.getBoolean(CFG_REST_CSRF_DISABLE_TOKEN_VALIDATION, false);
|
||||||
|
if (!checkToken) {
|
||||||
|
log.info("CSRF Token validation is disabled by configuration");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -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.model.User;
|
||||||
import org.apache.archiva.redback.rest.api.services.UserService;
|
import org.apache.archiva.redback.rest.api.services.UserService;
|
||||||
import org.junit.Test;
|
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
|
* @author Olivier Lamy
|
||||||
*/
|
*/
|
||||||
|
@RunWith( SpringJUnit4ClassRunner.class )
|
||||||
|
@ContextConfiguration(
|
||||||
|
locations = { "classpath:/spring-context.xml" } )
|
||||||
public class LoginServiceTest
|
public class LoginServiceTest
|
||||||
extends AbstractRestServicesTest
|
extends AbstractRestServicesTest
|
||||||
{
|
{
|
||||||
|
|
|
@ -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.archiva.redback.rest.api.services.UserService;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.junit.Test;
|
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.ForbiddenException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -34,6 +37,9 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
*/
|
*/
|
||||||
|
@RunWith( SpringJUnit4ClassRunner.class )
|
||||||
|
@ContextConfiguration(
|
||||||
|
locations = { "classpath:/spring-context.xml" } )
|
||||||
public class RoleManagementServiceTest
|
public class RoleManagementServiceTest
|
||||||
extends AbstractRestServicesTest
|
extends AbstractRestServicesTest
|
||||||
{
|
{
|
||||||
|
|
|
@ -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.JAXRSClientFactory;
|
||||||
import org.apache.cxf.jaxrs.client.WebClient;
|
import org.apache.cxf.jaxrs.client.WebClient;
|
||||||
import org.junit.Test;
|
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.ForbiddenException;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
@ -45,6 +48,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
*/
|
*/
|
||||||
|
@RunWith( SpringJUnit4ClassRunner.class )
|
||||||
|
@ContextConfiguration(
|
||||||
|
locations = { "classpath:/spring-context.xml" } )
|
||||||
public class UserServiceTest
|
public class UserServiceTest
|
||||||
extends AbstractRestServicesTest
|
extends AbstractRestServicesTest
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,3 +17,4 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
user.manager.impl=jdo
|
user.manager.impl=jdo
|
||||||
|
rest.csrffilter.disableTokenValidation=true
|
||||||
|
|
|
@ -23,25 +23,27 @@
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
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"/>
|
<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="authorizer#rbac" alias="authorizer#default"/>
|
||||||
|
|
||||||
<alias name="userManager#configurable" alias="userManager#default"/>
|
<alias name="userManager#configurable" alias="userManager#default"/>
|
||||||
|
|
|
@ -34,3 +34,5 @@ ldap.config.groups.role.snapshot-observer=Repository Observer - snapshots
|
||||||
|
|
||||||
#ldap.config.writable=true
|
#ldap.config.writable=true
|
||||||
#ldap.config.groups.use.rolename=true
|
#ldap.config.groups.use.rolename=true
|
||||||
|
|
||||||
|
rest.csrffilter.disableTokenValidation=true
|
||||||
|
|
Loading…
Reference in New Issue