cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [3/3] cxf git commit: Adding another signature negative test
Date Mon, 19 Oct 2015 15:13:27 GMT
Adding another signature negative test


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/4370feee
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/4370feee
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/4370feee

Branch: refs/heads/master
Commit: 4370feeee8c0a06ce46d4258c13ca7acb4c8bfd1
Parents: 7a928e8
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Mon Oct 19 14:31:44 2015 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Mon Oct 19 14:31:44 2015 +0100

----------------------------------------------------------------------
 .../jaxrs/security/jwt/JweJwsAlgorithmTest.java | 41 ++++++++++++++++++++
 1 file changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/4370feee/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/JweJwsAlgorithmTest.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/JweJwsAlgorithmTest.java
b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/JweJwsAlgorithmTest.java
index e70545c..eab8f62 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/JweJwsAlgorithmTest.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/jwt/JweJwsAlgorithmTest.java
@@ -348,4 +348,45 @@ public class JweJwsAlgorithmTest extends AbstractBusClientServerTestBase
{
         assertEquals(returnedBook.getName(), "book");
         assertEquals(returnedBook.getId(), 123L);
     }
+    
+    @org.junit.Test
+    public void testManualSignature() throws Exception {
+
+        URL busFile = JweJwsAlgorithmTest.class.getResource("client.xml");
+
+        List<Object> providers = new ArrayList<Object>();
+        providers.add(new JacksonJsonProvider());
+
+        String address = "http://localhost:" + PORT + "/jws/bookstore/books";
+        WebClient client = 
+            WebClient.create(address, providers, busFile.toString());
+        client.type("application/json").accept("application/json");
+
+        Map<String, Object> properties = new HashMap<String, Object>();
+        WebClient.getConfig(client).getRequestContext().putAll(properties);
+        
+        String header = "eyJhbGciOiJSUzI1NiIsImN0eSI6Impzb24ifQ";
+        String payload = "eyJCb29rIjp7ImlkIjoxMjMsIm5hbWUiOiJib29rIn19";
+        String sig = "mZJVPy83atFNxQMeJqkVbR8t1srr9LgKBGT0hgiymjNepRgqedvFG5B8E8UPAzfzNLsos91gGdneUEKrWauU4GoDPTzngX"
+            + "798aDP6lsn5bUoTMKLfaWp9uzHDIzLMjGkabn92nrIpdK4JKDYNjdSUJIT2L97jggg0aoLhJQHVw2LdF1fpYdM-HCyccNW"
+            + "HQbAR7bDZdITZFnDi8b22QfHCqeLV7m4mBvNDtNX337wtoUKyjPYBMoWc12hHDCwQyu_gfW6zFioF5TGx-Ifg8hrFlnyUr"
+            + "vnSdP-FUtXiGeWBIvE_L6gD7DfM4u9hkK757vTjjMR_pF2CW3pfSH-Ha8v0A";
+
+        // Successful test
+        Response response = client.post(header + "." + payload + "." + sig);
+        assertEquals(response.getStatus(), 200);
+        
+        Book returnedBook = response.readEntity(Book.class);
+        assertEquals(returnedBook.getName(), "book");
+        assertEquals(returnedBook.getId(), 123L);
+        
+        // No signature
+        response = client.post(header + "." + payload + ".");
+        assertNotEquals(response.getStatus(), 200);
+        
+        // Modified signature
+        String sig2 = sig.replace('y', 'z');
+        response = client.post(header + "." + payload + "." + sig2);
+        assertNotEquals(response.getStatus(), 200);
+    }
 }


Mime
View raw message