directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [3/3] directory-kerby git commit: More tests
Date Thu, 22 Oct 2015 10:40:56 GMT
More tests


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/e567dfdc
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/e567dfdc
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/e567dfdc

Branch: refs/heads/master
Commit: e567dfdceddcfa5c9cde9cd0191d128d40e769fd
Parents: b58fb7f
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Thu Oct 22 11:40:44 2015 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Thu Oct 22 11:40:44 2015 +0100

----------------------------------------------------------------------
 .../kerberos/kdc/WithAccessTokenKdcTest.java     | 19 +++++++++++++++++++
 .../kerberos/kdc/WithIdentityTokenKdcTest.java   | 19 +++++++++++++++++++
 2 files changed, 38 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e567dfdc/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithAccessTokenKdcTest.java
----------------------------------------------------------------------
diff --git a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithAccessTokenKdcTest.java
b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithAccessTokenKdcTest.java
index 0664529..6c8020e 100644
--- a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithAccessTokenKdcTest.java
+++ b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithAccessTokenKdcTest.java
@@ -115,6 +115,25 @@ public class WithAccessTokenKdcTest extends WithTokenKdcTestBase {
         performTest();
     }
     
+    @Test
+    public void testSignedEncryptedTokenBadSigningKey() throws Exception {
+        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
+        KeyPair keyPair = keyGen.generateKeyPair();
+        
+        InputStream is = WithTokenKdcTestBase.class.getResourceAsStream("/oauth2.com_public_key.pem");
+        PublicKey publicKey = PublicKeyReader.loadPublicKey(is);
+        
+        prepareToken(getServerPrincipal(), ISSUER, AUDIENCE, keyPair.getPrivate(), publicKey);
+        
+        try {
+            performTest();
+            Assert.fail("Failure expected on a bad key");
+        } catch (Exception ex) {
+            // expected
+            Assert.assertTrue(ex instanceof KrbException);
+        }
+    }
+    
     private void performTest() throws Exception {
         createCredentialCache(getClientPrincipal(), getClientPassword());
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e567dfdc/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithIdentityTokenKdcTest.java
----------------------------------------------------------------------
diff --git a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithIdentityTokenKdcTest.java
b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithIdentityTokenKdcTest.java
index eb89df6..b0dd04d 100644
--- a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithIdentityTokenKdcTest.java
+++ b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithIdentityTokenKdcTest.java
@@ -117,6 +117,25 @@ public class WithIdentityTokenKdcTest extends WithTokenKdcTestBase {
         performTest();
     }
     
+    @Test
+    public void testSignedEncryptedTokenBadSigningKey() throws Exception {
+        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
+        KeyPair keyPair = keyGen.generateKeyPair();
+        
+        InputStream is = WithTokenKdcTestBase.class.getResourceAsStream("/oauth2.com_public_key.pem");
+        PublicKey publicKey = PublicKeyReader.loadPublicKey(is);
+        
+        prepareToken(null, ISSUER, AUDIENCE, keyPair.getPrivate(), publicKey);
+        
+        try {
+            performTest();
+            Assert.fail("Failure expected on a bad key");
+        } catch (Exception ex) {
+            // expected
+            Assert.assertTrue(ex instanceof KrbException);
+        }
+    }
+    
     private void performTest() throws Exception {
 
         createCredentialCache(getClientPrincipal(), getClientPassword());


Mime
View raw message