You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ma...@apache.org on 2017/03/11 10:13:29 UTC
archiva-redback-core git commit: Fixing tests for rest services
Repository: archiva-redback-core
Updated Branches:
refs/heads/master d9146ce8a -> a6ee0f877
Fixing tests for rest services
Project: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/commit/a6ee0f87
Tree: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/tree/a6ee0f87
Diff: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/diff/a6ee0f87
Branch: refs/heads/master
Commit: a6ee0f87706c8ee88b588861dfa61804493adffd
Parents: d9146ce
Author: Martin Stockhammer <ma...@apache.org>
Authored: Sat Mar 11 11:12:59 2017 +0100
Committer: Martin Stockhammer <ma...@apache.org>
Committed: Sat Mar 11 11:12:59 2017 +0100
----------------------------------------------------------------------
.../RequestValidationInterceptor.java | 3 +++
.../redback/rest/services/LoginServiceTest.java | 6 +++++
.../services/RoleManagementServiceTest.java | 6 +++++
.../redback/rest/services/UserServiceTest.java | 6 +++++
.../src/test/resources/security.properties | 3 ++-
.../src/test/resources/spring-context.xml | 26 +++++++++++---------
.../src/test/security.properties | 4 ++-
7 files changed, 40 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/a6ee0f87/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/RequestValidationInterceptor.java
----------------------------------------------------------------------
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 a9afede..45ad713 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 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
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/a6ee0f87/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/LoginServiceTest.java
----------------------------------------------------------------------
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 ab5565b..e1fc37d 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.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
{
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/a6ee0f87/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/RoleManagementServiceTest.java
----------------------------------------------------------------------
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 1926314..0d02005 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.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
{
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/a6ee0f87/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/UserServiceTest.java
----------------------------------------------------------------------
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 a1d6f57..f77724f 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.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
{
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/a6ee0f87/redback-integrations/redback-rest/redback-rest-services/src/test/resources/security.properties
----------------------------------------------------------------------
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 9627c15..5f1aedc 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
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/a6ee0f87/redback-integrations/redback-rest/redback-rest-services/src/test/resources/spring-context.xml
----------------------------------------------------------------------
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 1aae21a..80f585f 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,24 +23,26 @@
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"/>
+ <alias name="userConfiguration#redback" alias="userConfiguration#default"/>
- </bean>
- <bean name="registry#commons-configuration" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry"
+ <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="userConfiguration#redback" alias="userConfiguration#default"/>
+
<alias name="authorizer#rbac" alias="authorizer#default"/>
http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/a6ee0f87/redback-integrations/redback-rest/redback-rest-services/src/test/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 29ed7f3..2c549cf 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