You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2015/02/06 13:10:27 UTC

[4/7] archiva-redback-core git commit: fix unit test

fix unit test


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/88a2ef7a
Tree: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/tree/88a2ef7a
Diff: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/diff/88a2ef7a

Branch: refs/heads/master
Commit: 88a2ef7a1c903af4744d7d6e39ac9ff0be7ae10f
Parents: 0e1a45a
Author: Olivier Lamy <ol...@apache.org>
Authored: Fri Jan 30 22:14:42 2015 +1100
Committer: Olivier Lamy <ol...@apache.org>
Committed: Thu Feb 5 21:35:04 2015 +1100

----------------------------------------------------------------------
 .../redback/rest/services/DefaultUserService.java  |  2 +-
 .../services/interceptors/AbstractInterceptor.java | 10 ++++++++--
 .../interceptors/PermissionsInterceptor.java       | 17 +++++++++++------
 .../src/test/resources/log4j2-test.xml             |  2 +-
 4 files changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/88a2ef7a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultUserService.java
----------------------------------------------------------------------
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultUserService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultUserService.java
index 200eaa4..611b607 100644
--- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultUserService.java
+++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultUserService.java
@@ -80,7 +80,7 @@ public class DefaultUserService
     implements UserService
 {
 
-    private Logger log = LoggerFactory.getLogger( getClass() );
+    private final Logger log = LoggerFactory.getLogger( getClass() );
 
     private static final String VALID_USERNAME_CHARS = "[a-zA-Z_0-9\\-.@]*";
 

http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/88a2ef7a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/AbstractInterceptor.java
----------------------------------------------------------------------
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/AbstractInterceptor.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/AbstractInterceptor.java
index 45b3031..5d2dd5e 100644
--- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/AbstractInterceptor.java
+++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/AbstractInterceptor.java
@@ -19,9 +19,9 @@ package org.apache.archiva.redback.rest.services.interceptors;
  * under the License.
  */
 
+import org.apache.archiva.redback.authorization.RedbackAuthorization;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.message.Message;
-import org.apache.archiva.redback.authorization.RedbackAuthorization;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -65,8 +65,14 @@ public abstract class AbstractInterceptor
 
         Method method = operationResourceInfo.getAnnotatedMethod();
 
-        log.debug( " method name {}", method == null ? "null" : method.getName() );
         RedbackAuthorization redbackAuthorization = method.getAnnotation( RedbackAuthorization.class );
+
+        log.debug( "class {}, resourceClass {}, method {}, redbackAuthorization {}", //
+                   operationResourceInfo.getClassResourceInfo().getServiceClass(), //
+                   operationResourceInfo.getClassResourceInfo().getResourceClass(), //
+                   method, //
+                   redbackAuthorization );
+
         return redbackAuthorization;
     }
 }

http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/88a2ef7a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/PermissionsInterceptor.java
----------------------------------------------------------------------
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/PermissionsInterceptor.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/PermissionsInterceptor.java
index 23fba4a..f2d4284 100644
--- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/PermissionsInterceptor.java
+++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/PermissionsInterceptor.java
@@ -66,6 +66,7 @@ public class PermissionsInterceptor
 
     public void filter( ContainerRequestContext containerRequestContext )
     {
+
         Message message = JAXRSUtils.getCurrentMessage();
 
         RedbackAuthorization redbackAuthorization = getRedbackAuthorization( message );
@@ -79,8 +80,8 @@ public class PermissionsInterceptor
             }
             String[] permissions = redbackAuthorization.permissions();
             //olamy: no value is an array with an empty String
-            if ( permissions != null && permissions.length > 0 && !( permissions.length == 1 && StringUtils.isEmpty(
-                permissions[0] ) ) )
+            if ( permissions != null && permissions.length > 0 //
+                && !( permissions.length == 1 && StringUtils.isEmpty( permissions[0] ) ) )
             {
                 HttpServletRequest request = getHttpServletRequest( message );
                 SecuritySession securitySession = httpAuthenticator.getSecuritySession( request.getSession( true ) );
@@ -90,7 +91,8 @@ public class PermissionsInterceptor
                 {
                     try
                     {
-                        authenticationResult = httpAuthenticator.getAuthenticationResult( request, getHttpServletResponse( message ) );
+                        authenticationResult =
+                            httpAuthenticator.getAuthenticationResult( request, getHttpServletResponse( message ) );
                     }
                     catch ( AuthenticationException e )
                     {
@@ -139,10 +141,11 @@ public class PermissionsInterceptor
                         catch ( AuthorizationException e )
                         {
                             log.debug( e.getMessage(), e );
-                            containerRequestContext.abortWith( Response.status( Response.Status.FORBIDDEN ).build() );
-                            return;
+
                         }
                     }
+                    containerRequestContext.abortWith( Response.status( Response.Status.FORBIDDEN ).build() );
+                    return;
 
                 }
                 else
@@ -165,10 +168,12 @@ public class PermissionsInterceptor
                 return;
             }
         }
-        log.warn( "http path {} doesn't contain any informations regarding permissions ",
+
+        log.warn( "http path {} doesn't contain any informations regarding permissions ", //
                   message.get( Message.REQUEST_URI ) );
         // here we failed to authenticate so 403 as there is no detail on karma for this
         // it must be marked as it's exposed
         containerRequestContext.abortWith( Response.status( Response.Status.FORBIDDEN ).build() );
+
     }
 }

http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/88a2ef7a/redback-integrations/redback-rest/redback-rest-services/src/test/resources/log4j2-test.xml
----------------------------------------------------------------------
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/resources/log4j2-test.xml b/redback-integrations/redback-rest/redback-rest-services/src/test/resources/log4j2-test.xml
index 33521cf..2d3ff01 100644
--- a/redback-integrations/redback-rest/redback-rest-services/src/test/resources/log4j2-test.xml
+++ b/redback-integrations/redback-rest/redback-rest-services/src/test/resources/log4j2-test.xml
@@ -21,7 +21,7 @@
 
   <appenders>
     <Console name="console" target="SYSTEM_OUT">
-      <PatternLayout pattern="%highlight{%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n}" />
+      <PatternLayout pattern="%highlight{%d{HH:mm:ss.SSS} [%L] [%t] %-5level %logger{36} - %msg%n}" />
     </Console>
   </appenders>