sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asa...@apache.org
Subject svn commit: r1691917 - /sling/trunk/contrib/extensions/security/src/test/java/org/apache/sling/security/impl/ContentDispositionFilterTest.java
Date Mon, 20 Jul 2015 12:05:31 GMT
Author: asanso
Date: Mon Jul 20 12:05:31 2015
New Revision: 1691917

URL: http://svn.apache.org/r1691917
Log:
SLING-4883 - Extend content disposition filter protection to jcr:data

* unit tests

Modified:
    sling/trunk/contrib/extensions/security/src/test/java/org/apache/sling/security/impl/ContentDispositionFilterTest.java

Modified: sling/trunk/contrib/extensions/security/src/test/java/org/apache/sling/security/impl/ContentDispositionFilterTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/security/src/test/java/org/apache/sling/security/impl/ContentDispositionFilterTest.java?rev=1691917&r1=1691916&r2=1691917&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/security/src/test/java/org/apache/sling/security/impl/ContentDispositionFilterTest.java
(original)
+++ sling/trunk/contrib/extensions/security/src/test/java/org/apache/sling/security/impl/ContentDispositionFilterTest.java
Mon Jul 20 12:05:31 2015
@@ -20,6 +20,7 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import junitx.util.PrivateAccessor;
 
@@ -291,7 +292,13 @@ public class ContentDispositionFilterTes
             }
         });    
         PrivateAccessor.invoke(contentDispositionFilter,"activate",  new Class[]{ComponentContext.class},new
Object[]{ctx});
-        final ContentDispositionFilter.RewriterResponse rewriterResponse = contentDispositionFilter.
new RewriterResponse(request, response);
+        
+        final AtomicInteger counter =  new AtomicInteger();        
+        final ContentDispositionFilter.RewriterResponse rewriterResponse = contentDispositionFilter.
new RewriterResponse(request, response) {          
+            public void addHeader(String name, String value) {
+                counter.incrementAndGet();
+            }
+        };
         
         context.checking(new Expectations() {
             {
@@ -307,7 +314,8 @@ public class ContentDispositionFilterTes
                 exactly(1).of(response).addHeader("Content-Disposition", "attachment");
             }
         });       
-        rewriterResponse.setContentType("text/html");
+        rewriterResponse.setContentType("text/html");        
+        Assert.assertEquals(1, counter.intValue());
     }
     
     @Test
@@ -364,7 +372,12 @@ public class ContentDispositionFilterTes
             }
         });    
         PrivateAccessor.invoke(contentDispositionFilter,"activate",  new Class[]{ComponentContext.class},new
Object[]{ctx});
-        final ContentDispositionFilter.RewriterResponse rewriterResponse = contentDispositionFilter.
new RewriterResponse(request, response);
+        final AtomicInteger counter =  new AtomicInteger();        
+        final ContentDispositionFilter.RewriterResponse rewriterResponse = contentDispositionFilter.
new RewriterResponse(request, response) {          
+            public void addHeader(String name, String value) {
+                counter.incrementAndGet();
+            }
+        };
         
         context.checking(new Expectations() {
             {
@@ -381,6 +394,7 @@ public class ContentDispositionFilterTes
             }
         });       
         rewriterResponse.setContentType("text/html");
+        Assert.assertEquals(1, counter.intValue());
     }
     
     @Test
@@ -401,7 +415,12 @@ public class ContentDispositionFilterTes
             }
         });    
         PrivateAccessor.invoke(contentDispositionFilter,"activate",  new Class[]{ComponentContext.class},new
Object[]{ctx});
-        ContentDispositionFilter.RewriterResponse rewriterResponse = contentDispositionFilter.
new RewriterResponse(request, response);
+        final AtomicInteger counter =  new AtomicInteger();        
+        final ContentDispositionFilter.RewriterResponse rewriterResponse = contentDispositionFilter.
new RewriterResponse(request, response) {          
+            public void addHeader(String name, String value) {
+                counter.incrementAndGet();
+            }
+        };
         
         context.checking(new Expectations() {
             {
@@ -416,6 +435,7 @@ public class ContentDispositionFilterTes
             }
         });       
         rewriterResponse.setContentType("text/html");
+        //Assert.assertEquals(1, counter.intValue());
     }
     
     @Test



Mime
View raw message