cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1157237 - /cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
Date Fri, 12 Aug 2011 20:28:13 GMT
Author: sergeyb
Date: Fri Aug 12 20:28:12 2011
New Revision: 1157237

URL: http://svn.apache.org/viewvc?rev=1157237&view=rev
Log:
[CXF-3661] Adding a single proxy test

Modified:
    cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java

Modified: cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java?rev=1157237&r1=1157236&r2=1157237&view=diff
==============================================================================
--- cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
(original)
+++ cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
Fri Aug 12 20:28:12 2011
@@ -33,6 +33,7 @@ import org.apache.cxf.rs.security.common
 import org.apache.cxf.rs.security.xml.XmlEncOutInterceptor;
 import org.apache.cxf.rs.security.xml.XmlSigOutInterceptor;
 import org.apache.cxf.systest.jaxrs.security.Book;
+import org.apache.cxf.systest.jaxrs.security.BookStore;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.xml.security.encryption.XMLCipher;
 import org.junit.BeforeClass;
@@ -48,6 +49,48 @@ public class JAXRSXmlSecTest extends Abs
     }
     
     @Test
+    public void testPostBookWithEnvelopedSigAndProxy() throws Exception {
+        String address = "https://localhost:" + PORT + "/xmlsig";
+        doTestSignatureProxy(address, false);
+    }
+    
+    private void doTestSignatureProxy(String address, boolean enveloping) {
+        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+        bean.setAddress(address);
+        
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = JAXRSXmlSecTest.class.getResource("client.xml");
+        Bus springBus = bf.createBus(busFile.toString());
+        bean.setBus(springBus);
+
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put("ws-security.callback-handler", 
+                       "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback");
+        properties.put("ws-security.signature.username", "alice");
+        properties.put("ws-security.signature.properties", 
+                       "org/apache/cxf/systest/jaxrs/security/alice.properties");
+        bean.setProperties(properties);
+        XmlSigOutInterceptor sigInterceptor = new XmlSigOutInterceptor();
+        sigInterceptor.setEnveloping(enveloping);
+        bean.getOutInterceptors().add(sigInterceptor);
+        bean.setServiceClass(BookStore.class);
+        
+        BookStore store = bean.create(BookStore.class);
+        try {
+            Book book = store.addBook(new Book("CXF", 126L));
+            assertEquals(126L, book.getId());
+        } catch (ServerWebApplicationException ex) {
+            fail(ex.getMessage());
+        } catch (ClientWebApplicationException ex) {
+            if (ex.getCause() != null && ex.getCause().getMessage() != null) {
+                fail(ex.getCause().getMessage());
+            } else {
+                fail(ex.getMessage());
+            }
+        }
+    }
+    
+    @Test
     public void testPostBookWithEnvelopedSig() throws Exception {
         String address = "https://localhost:" + PORT + "/xmlsig/bookstore/books";
         doTestSignature(address, false);



Mime
View raw message