diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/RequestValidationInterceptor.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/RequestValidationInterceptor.java index a9afedea..45ad7138 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/RequestValidationInterceptor.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/RequestValidationInterceptor.java @@ -122,6 +122,9 @@ public void init() { 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 diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/LoginServiceTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/LoginServiceTest.java index ab5565b0..e1fc37de 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/LoginServiceTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/LoginServiceTest.java @@ -23,10 +23,16 @@ 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 { diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/RoleManagementServiceTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/RoleManagementServiceTest.java index 1926314a..0d02005b 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/RoleManagementServiceTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/RoleManagementServiceTest.java @@ -25,6 +25,9 @@ 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 @@ /** * @author Olivier Lamy */ +@RunWith( SpringJUnit4ClassRunner.class ) +@ContextConfiguration( + locations = { "classpath:/spring-context.xml" } ) public class RoleManagementServiceTest extends AbstractRestServicesTest { diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/UserServiceTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/UserServiceTest.java index a1d6f572..f77724f3 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/UserServiceTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/UserServiceTest.java @@ -32,6 +32,9 @@ 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 @@ /** * @author Olivier Lamy */ +@RunWith( SpringJUnit4ClassRunner.class ) +@ContextConfiguration( + locations = { "classpath:/spring-context.xml" } ) public class UserServiceTest extends AbstractRestServicesTest { diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/resources/security.properties b/redback-integrations/redback-rest/redback-rest-services/src/test/resources/security.properties index 9627c151..5f1aedca 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/resources/security.properties +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/resources/security.properties @@ -16,4 +16,5 @@ # specific language governing permissions and limitations # under the License. # -user.manager.impl=jdo \ No newline at end of file +user.manager.impl=jdo +rest.csrffilter.disableTokenValidation=true diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/resources/spring-context.xml b/redback-integrations/redback-rest/redback-rest-services/src/test/resources/spring-context.xml index 1aae21af..80f585f2 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/resources/spring-context.xml +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/resources/spring-context.xml @@ -23,25 +23,27 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> - - - - src/test/resources/security.properties - - - - - - - - - - + + + + + + + + + ]]> + + + + + + diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/security.properties b/redback-integrations/redback-rest/redback-rest-services/src/test/security.properties index 29ed7f30..2c549cf8 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/security.properties +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/security.properties @@ -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 \ No newline at end of file +#ldap.config.groups.use.rolename=true + +rest.csrffilter.disableTokenValidation=true