cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1457142 - in /cxf/branches/2.7.x-fixes: ./ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSJaasSecurityTest.java
Date Fri, 15 Mar 2013 21:52:18 GMT
Author: sergeyb
Date: Fri Mar 15 21:52:18 2013
New Revision: 1457142

URL: http://svn.apache.org/r1457142
Log:
Merged revisions 1457140 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1457140 | sergeyb | 2013-03-15 21:49:37 +0000 (Fri, 15 Mar 2013) | 1 line
  
  [CXF-4894] Adding few tests
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSJaasSecurityTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1457140

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSJaasSecurityTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSJaasSecurityTest.java?rev=1457142&r1=1457141&r2=1457142&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSJaasSecurityTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSJaasSecurityTest.java
Fri Mar 15 21:52:18 2013
@@ -25,7 +25,9 @@ import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Response;
 
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.systest.jaxrs.Book;
 
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -70,7 +72,7 @@ public class JAXRSJaasSecurityTest exten
         pol.setPassword("bar1");
         WebClient.getConfig(wc).getHttpConduit().setAuthorization(pol);
         
-        wc.accept("text/xml");
+        wc.accept("application/xml");
         
         //wc.header(HttpHeaders.AUTHORIZATION, 
         //          "Basic " + base64Encode("foo" + ":" + "bar1"));
@@ -82,6 +84,42 @@ public class JAXRSJaasSecurityTest exten
     }
     
     @Test
+    public void testJaasFilterWebClientAuthorizationPolicy() throws Exception {
+        String endpointAddress =
+            "http://localhost:" + PORT + "/service/jaas2/bookstorestorage/thosebooks/123";

+        WebClient wc = WebClient.create(endpointAddress);
+        AuthorizationPolicy pol = new AuthorizationPolicy();
+        pol.setUserName("bob");
+        pol.setPassword("bobspassword");
+        WebClient.getConfig(wc).getHttpConduit().setAuthorization(pol);
+        wc.accept("application/xml");
+        Book book = wc.get(Book.class);
+        assertEquals(123L, book.getId());
+    }
+    
+    @Test
+    public void testJaasFilterWebClientAuthorizationPolicy2() throws Exception {
+        String endpointAddress =
+            "http://localhost:" + PORT + "/service/jaas2/bookstorestorage/thosebooks/123";

+        WebClient wc = WebClient.create(endpointAddress, "bob", "bobspassword", null);
+        //WebClient.getConfig(wc).getOutInterceptors().add(new LoggingOutInterceptor());
+        wc.accept("application/xml");
+        Book book = wc.get(Book.class);
+        assertEquals(123L, book.getId());
+    }
+    
+    @Test
+    public void testJaasFilterProxyAuthorizationPolicy() throws Exception {
+        String endpointAddress =
+            "http://localhost:" + PORT + "/service/jaas2"; 
+        SecureBookStoreNoAnnotations proxy = 
+            JAXRSClientFactory.create(endpointAddress, SecureBookStoreNoAnnotations.class,
+                                      "bob", "bobspassword", null);
+        Book book = proxy.getThatBook(123L);
+        assertEquals(123L, book.getId());
+    }
+    
+    @Test
     public void testJaasFilterAuthenticationFailureWithRedirection() throws Exception {
         String endpointAddress =
             "http://localhost:" + PORT + "/service/jaas2/bookstorestorage/thosebooks/123";




Mime
View raw message