directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject directory-kerby git commit: [DIRKRB-276]-Fix clientPrincipal, serverPrincipal and TEST_DIR not private in Kerb Kdc Test module.Contributed by Yaning.
Date Thu, 28 May 2015 01:36:43 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master f46f994f9 -> 192826eb4


[DIRKRB-276]-Fix clientPrincipal, serverPrincipal and TEST_DIR not private in Kerb Kdc Test
module.Contributed by Yaning.


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

Branch: refs/heads/master
Commit: 192826eb435416f7867be6811683d4bed976944e
Parents: f46f994
Author: plusplusjiajia <jiajia.li@intel.com>
Authored: Thu May 28 09:41:38 2015 +0800
Committer: plusplusjiajia <jiajia.li@intel.com>
Committed: Thu May 28 09:41:38 2015 +0800

----------------------------------------------------------------------
 .../kerby/kerberos/kdc/GSSInteropTestBase.java  |  4 +++
 .../org/apache/kerby/kerberos/kdc/KdcTest.java  |  4 +++
 .../apache/kerby/kerberos/kdc/KerbyKdcTest.java |  4 +++
 .../kerby/kerberos/kdc/WithCertKdcTest.java     |  5 ++-
 .../kerby/kerberos/kdc/WithTokenKdcTest.java    |  6 +++-
 .../kerby/kerberos/kerb/server/KdcTestBase.java | 32 +++++++++++++++-----
 .../kerberos/kerb/server/GSSInteropTest.java    |  4 +++
 .../kerby/kerberos/kerb/server/KdcTest.java     |  4 +++
 .../kerb/server/MultiRequestsKdcTest.java       |  5 ++-
 9 files changed, 57 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/192826eb/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/GSSInteropTestBase.java
----------------------------------------------------------------------
diff --git a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/GSSInteropTestBase.java
b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/GSSInteropTestBase.java
index 8d3f476..e020601 100644
--- a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/GSSInteropTestBase.java
+++ b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/GSSInteropTestBase.java
@@ -48,6 +48,8 @@ import org.apache.kerby.kerberos.kerb.server.TestKdcServer;
  * This is an interop test using the Java GSS APIs against the Kerby KDC
  */
 public abstract class GSSInteropTestBase extends KdcTest {
+    private String clientPrincipal;
+    private String serverPrincipal;
     
     @Override
     protected void setUpKdcServer() throws Exception {
@@ -62,7 +64,9 @@ public abstract class GSSInteropTestBase extends KdcTest {
         
         kdcRealm = kdcServer.getKdcRealm();
         clientPrincipal = "drankye@" + kdcRealm;
+        setClientPrincipal(clientPrincipal);
         serverPrincipal = "test-service/localhost@" + kdcRealm;
+        setServerPrincipal(serverPrincipal);
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/192826eb/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/KdcTest.java
----------------------------------------------------------------------
diff --git a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/KdcTest.java b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/KdcTest.java
index dd827b5..98f2dd1 100644
--- a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/KdcTest.java
+++ b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/KdcTest.java
@@ -29,10 +29,13 @@ import java.io.File;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public abstract class KdcTest extends KdcTestBase {
+    private String clientPrincipal;
+    private String serverPrincipal;
 
     @Override
     protected void createPrincipals() {
         super.createPrincipals();
+        clientPrincipal = getClientPrincipal();
         kdcServer.createPrincipal(clientPrincipal, TEST_PASSWORD);
     }
 
@@ -51,6 +54,7 @@ public abstract class KdcTest extends KdcTestBase {
             tgt = krbClnt.requestTgtWithPassword(clientPrincipal, TEST_PASSWORD);
             assertThat(tgt).isNotNull();
 
+            serverPrincipal = getServerPrincipal();
             tkt = krbClnt.requestServiceTicketWithTgt(tgt, serverPrincipal);
             assertThat(tkt).isNotNull();
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/192826eb/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/KerbyKdcTest.java
----------------------------------------------------------------------
diff --git a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/KerbyKdcTest.java
b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/KerbyKdcTest.java
index 96c18fe..89df1c1 100644
--- a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/KerbyKdcTest.java
+++ b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/KerbyKdcTest.java
@@ -30,6 +30,8 @@ import java.io.File;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public abstract class KerbyKdcTest extends KdcTestBase {
+    private String clientPrincipal;
+    private String serverPrincipal;
 
     @Override
     protected void prepareKdcServer() throws Exception {
@@ -40,6 +42,7 @@ public abstract class KerbyKdcTest extends KdcTestBase {
     @Override
     protected void createPrincipals() {
         super.createPrincipals();
+        clientPrincipal = getClientPrincipal();
         kdcServer.createPrincipal(clientPrincipal, TEST_PASSWORD);
     }
 
@@ -58,6 +61,7 @@ public abstract class KerbyKdcTest extends KdcTestBase {
             tgt = krbClnt.requestTgtWithPassword(clientPrincipal, TEST_PASSWORD);
             assertThat(tgt).isNotNull();
 
+            serverPrincipal = getServerPrincipal();
             tkt = krbClnt.requestServiceTicketWithTgt(tgt, serverPrincipal);
             assertThat(tkt).isNotNull();
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/192826eb/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithCertKdcTest.java
----------------------------------------------------------------------
diff --git a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithCertKdcTest.java
b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithCertKdcTest.java
index d61428c..f7124cb 100644
--- a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithCertKdcTest.java
+++ b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithCertKdcTest.java
@@ -45,7 +45,8 @@ import static org.assertj.core.api.Assertions.assertThat;
  */
 public class WithCertKdcTest extends KdcTestBase {
     private PkiLoader pkiLoader;
-
+    private String clientPrincipal;
+    private String serverPrincipal;
     private Certificate userCert;
     private PrivateKey userKey;
 
@@ -67,6 +68,7 @@ public class WithCertKdcTest extends KdcTestBase {
     @Override
     protected void prepareKdcServer() throws Exception {
         super.prepareKdcServer();
+        clientPrincipal = getClientPrincipal();
         kdcServer.createPrincipals(clientPrincipal);
     }
 
@@ -86,6 +88,7 @@ public class WithCertKdcTest extends KdcTestBase {
         }
         assertThat(tgt).isNull();
 
+        serverPrincipal = getServerPrincipal();
         ServiceTicket tkt = krbClnt.requestServiceTicketWithTgt(tgt, serverPrincipal);
         assertThat(tkt).isNull();
     }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/192826eb/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithTokenKdcTest.java
----------------------------------------------------------------------
diff --git a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithTokenKdcTest.java
b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithTokenKdcTest.java
index 3af335c..05290a8 100644
--- a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithTokenKdcTest.java
+++ b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/WithTokenKdcTest.java
@@ -41,7 +41,6 @@ import java.util.List;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class WithTokenKdcTest extends KdcTestBase {
-
     static final String SUBJECT = "test-sub";
     static final String AUDIENCE = "krbtgt@EXAMPLE.COM";
     static final String ISSUER = "oauth2.com";
@@ -53,6 +52,9 @@ public class WithTokenKdcTest extends KdcTestBase {
 
     private AuthToken authToken;
 
+    private String clientPrincipal;
+    private String serverPrincipal;
+
     @Before
     public void setUp() throws Exception {
         KrbRuntime.setTokenProvider(new JwtTokenProvider());
@@ -95,6 +97,7 @@ public class WithTokenKdcTest extends KdcTestBase {
     @Override
     protected void createPrincipals() {
         super.createPrincipals();
+        clientPrincipal = getClientPrincipal();
         kdcServer.createPrincipal(clientPrincipal, TEST_PASSWORD);
     }
 
@@ -119,6 +122,7 @@ public class WithTokenKdcTest extends KdcTestBase {
         assertThat(tgt.getEncKdcRepPart()).isNotNull();
         assertThat(tgt.getSessionKey()).isNotNull();
 
+        serverPrincipal = getServerPrincipal();
         ServiceTicket tkt = krbClnt.requestServiceTicketWithTgt(tgt, serverPrincipal);
         assertThat(tkt).isNotNull();
         assertThat(tkt.getRealm()).isEqualTo(kdcRealm);

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/192826eb/kerby-kerb/kerb-kdc-test/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcTestBase.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-kdc-test/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcTestBase.java
b/kerby-kerb/kerb-kdc-test/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcTestBase.java
index f1c7115..f750d31 100644
--- a/kerby-kerb/kerb-kdc-test/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcTestBase.java
+++ b/kerby-kerb/kerb-kdc-test/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcTestBase.java
@@ -37,11 +37,11 @@ import java.net.ServerSocket;
 
 public abstract class KdcTestBase {
     protected static final String TEST_PASSWORD = "123456";
-    private static File TEST_DIR;
+    private static File testDir;
 
     protected String kdcRealm;
-    protected String clientPrincipal;
-    protected String serverPrincipal;
+    private String clientPrincipal;
+    private String serverPrincipal;
 
     protected String hostname = "localhost";
     protected int tcpPort = -1;
@@ -75,17 +75,33 @@ public abstract class KdcTestBase {
             basedir = new File(".").getCanonicalPath();
         }
         File targetdir= new File(basedir, "target");
-        TEST_DIR = new File(targetdir, "tmp");
-        TEST_DIR.mkdirs();
+        testDir = new File(targetdir, "tmp");
+        testDir.mkdirs();
     }
 
     @AfterClass
     public static void deleteTestDir() throws IOException {
-        FileUtils.deleteDirectory(TEST_DIR);
+        FileUtils.deleteDirectory(testDir);
     }
 
     public File getTestDir() {
-        return TEST_DIR;
+        return testDir;
+    }
+
+    protected void setClientPrincipal(String clientPrincipal) {
+        this.clientPrincipal = clientPrincipal;
+    }
+
+    protected String getClientPrincipal() {
+        return this.clientPrincipal;
+    }
+
+    protected void setServerPrincipal(String serverPrincipal) {
+        this.serverPrincipal = serverPrincipal;
+    }
+
+    protected String getServerPrincipal() {
+        return this.serverPrincipal;
     }
 
     protected boolean allowUdp() {
@@ -104,7 +120,7 @@ public abstract class KdcTestBase {
     }
 
     public String writeToTestDir(String content, String fileName) throws IOException {
-        File file = new File(TEST_DIR, fileName);
+        File file = new File(testDir, fileName);
         if (file.exists()) {
             file.delete();
         }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/192826eb/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/GSSInteropTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/GSSInteropTest.java
b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/GSSInteropTest.java
index e9d19e1..601cca8 100644
--- a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/GSSInteropTest.java
+++ b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/GSSInteropTest.java
@@ -46,6 +46,8 @@ import java.util.Set;
  * This is an interop test using the Java GSS APIs against the Kerby KDC
  */
 public class GSSInteropTest extends KdcTest {
+    private String clientPrincipal;
+    private String serverPrincipal;
 
     @Override
     protected void setUpKdcServer() throws Exception {
@@ -59,7 +61,9 @@ public class GSSInteropTest extends KdcTest {
 
         kdcRealm = kdcServer.getKdcRealm();
         clientPrincipal = "drankye@" + kdcRealm;
+        setClientPrincipal(clientPrincipal);
         serverPrincipal = "test-service/localhost@" + kdcRealm;
+        setServerPrincipal(serverPrincipal);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/192826eb/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/KdcTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/KdcTest.java
b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/KdcTest.java
index 12d3aa9..d27a7bc 100644
--- a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/KdcTest.java
+++ b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/KdcTest.java
@@ -28,10 +28,13 @@ import java.io.File;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public abstract class KdcTest extends KdcTestBase {
+    private String clientPrincipal;
+    private String serverPrincipal;
 
     @Override
     protected void createPrincipals() {
         super.createPrincipals();
+        clientPrincipal = getClientPrincipal();
         kdcServer.createPrincipal(clientPrincipal, TEST_PASSWORD);
     }
 
@@ -50,6 +53,7 @@ public abstract class KdcTest extends KdcTestBase {
             tgt = krbClnt.requestTgtWithPassword(clientPrincipal, TEST_PASSWORD);
             assertThat(tgt).isNotNull();
 
+            serverPrincipal = getServerPrincipal();
             tkt = krbClnt.requestServiceTicketWithTgt(tgt, serverPrincipal);
             assertThat(tkt).isNotNull();
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/192826eb/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/MultiRequestsKdcTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/MultiRequestsKdcTest.java
b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/MultiRequestsKdcTest.java
index ebaf76a..48d6ce9 100644
--- a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/MultiRequestsKdcTest.java
+++ b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/MultiRequestsKdcTest.java
@@ -29,12 +29,14 @@ import java.io.File;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class MultiRequestsKdcTest extends KdcTestBase {
-
+    private String clientPrincipal;
+    private String serverPrincipal;
     private String password = "123456";
 
     @Override
     protected void createPrincipals() {
         super.createPrincipals();
+        clientPrincipal = getClientPrincipal();
         kdcServer.createPrincipal(clientPrincipal, password);
     }
 
@@ -55,6 +57,7 @@ public class MultiRequestsKdcTest extends KdcTestBase {
             tgt = krbClnt.requestTgtWithPassword(clientPrincipal, password);
             assertThat(tgt).isNotNull();
 
+            serverPrincipal = getServerPrincipal();
             tkt = krbClnt.requestServiceTicketWithTgt(tgt, serverPrincipal);
             assertThat(tkt).isNotNull();
         } catch (Exception e) {


Mime
View raw message