Skip to content
Permalink
Browse files
Fixing tests for rest services
  • Loading branch information
effrafax committed Mar 11, 2017
1 parent d9146ce commit a6ee0f87706c8ee88b588861dfa61804493adffd
Showing 7 changed files with 40 additions and 14 deletions.
@@ -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
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
@@ -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"/>

@@ -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

0 comments on commit a6ee0f8

Please sign in to comment.