From: Martin Stockhammer Date: Tue, 31 Jan 2017 21:56:50 +0000 (+0100) Subject: Adding Header check to archiva rest services X-Git-Tag: archiva-2.2.2~21 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fc41a798858b6362a50f4b49e28028d328246602;p=archiva.git Adding Header check to archiva rest services --- diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml index 77d365cbc..c9e677db6 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml @@ -52,6 +52,7 @@ + diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java index 2453e6af8..acf9df5b0 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java @@ -138,6 +138,7 @@ public abstract class AbstractArchivaRestTest { WebClient.client( service ).header( "Authorization", authzHeader ); } + WebClient.client(service).header("Referer","http://localhost:"+port); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 ); WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); @@ -200,6 +201,7 @@ public abstract class AbstractArchivaRestTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 ); WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); @@ -214,6 +216,7 @@ public abstract class AbstractArchivaRestTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 ); WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); @@ -231,6 +234,8 @@ public abstract class AbstractArchivaRestTest WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 ); return service; } @@ -246,6 +251,7 @@ public abstract class AbstractArchivaRestTest WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 ); return service; } @@ -262,6 +268,7 @@ public abstract class AbstractArchivaRestTest { WebClient.client( service ).header( "Authorization", authzHeader ); } + WebClient.client(service).header("Referer","http://localhost:"+port); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 ); if ( useXml ) @@ -291,6 +298,7 @@ public abstract class AbstractArchivaRestTest { WebClient.client( service ).header( "Authorization", authzHeader ); } + WebClient.client(service).header("Referer","http://localhost:"+port); // to configure read timeout WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 ); // if you want to use json as exchange format xml is supported too @@ -312,6 +320,7 @@ public abstract class AbstractArchivaRestTest { WebClient.client( service ).header( "Authorization", authzHeader ); } + WebClient.client(service).header("Referer","http://localhost:"+port); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 ); WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoryGroupServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoryGroupServiceTest.java index 017505859..1fee4a342 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoryGroupServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoryGroupServiceTest.java @@ -39,6 +39,8 @@ public class RepositoryGroupServiceTest { RepositoryGroupService service = getRepositoryGroupService(); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 ); assertTrue( service.getRepositoriesGroups().isEmpty() );