directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject directory-kerby git commit: DIRKRB-212 Clear the identity cache before get the identity and add more asserts in BackendTest. Contributed by Jiajia
Date Thu, 09 Apr 2015 06:37:55 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 8c9c0ad8c -> 793554443


DIRKRB-212 Clear the identity cache before get the identity and add more asserts in BackendTest.
Contributed by Jiajia


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

Branch: refs/heads/master
Commit: 7935544432e41d6e4799d94bc4172e4f7318f816
Parents: 8c9c0ad
Author: Lin <linchen7@foxmail.com>
Authored: Thu Apr 9 14:33:38 2015 +0800
Committer: Lin <linchen7@foxmail.com>
Committed: Thu Apr 9 14:33:38 2015 +0800

----------------------------------------------------------------------
 .../kerb/identity/backend/BackendTest.java      | 28 ++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/79355444/kerby-kerb/kerb-identity-test/src/main/java/org/apache/kerby/kerberos/kerb/identity/backend/BackendTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-identity-test/src/main/java/org/apache/kerby/kerberos/kerb/identity/backend/BackendTest.java
b/kerby-kerb/kerb-identity-test/src/main/java/org/apache/kerby/kerberos/kerb/identity/backend/BackendTest.java
index dcec8e5..6c904c3 100644
--- a/kerby-kerb/kerb-identity-test/src/main/java/org/apache/kerby/kerberos/kerb/identity/backend/BackendTest.java
+++ b/kerby-kerb/kerb-identity-test/src/main/java/org/apache/kerby/kerberos/kerb/identity/backend/BackendTest.java
@@ -47,8 +47,21 @@ public abstract class BackendTest {
     protected void testGet(IdentityBackend backend) {
         KrbIdentity kid = createOneIdentity(TEST_PRINCIPAL);
         backend.addIdentity(kid);
-
-        assertThat(backend.getIdentity(TEST_PRINCIPAL)).isNotNull();
+        // clear the identity cache.
+        backend.release();
+
+        KrbIdentity identity = backend.getIdentity(TEST_PRINCIPAL);
+        assertThat(identity).isNotNull();
+        assertThat(identity.getExpireTime()).isEqualTo(kid.getExpireTime());
+        assertThat(identity.isDisabled()).isEqualTo(kid.isDisabled());
+        assertThat(identity.getKeyVersion()).isEqualTo(kid.getKeyVersion());
+        for (EncryptionKey expectedKey : kid.getKeys().values()) {
+            EncryptionType actualType = EncryptionType.fromValue(expectedKey.getKeyType().getValue());
+            EncryptionKey actualKey = identity.getKey(actualType);
+            assertThat(actualKey.getKeyType().getValue()).isEqualTo(expectedKey.getKeyType().getValue());
+            assertThat(actualKey.getKeyData()).isEqualTo(expectedKey.getKeyData());
+            assertThat(actualKey.getKvno()).isEqualTo(expectedKey.getKvno());
+        }
 
         //tearDown
         backend.deleteIdentity(TEST_PRINCIPAL);
@@ -57,6 +70,8 @@ public abstract class BackendTest {
     protected void testStore(IdentityBackend backend) {
         KrbIdentity kid = createOneIdentity(TEST_PRINCIPAL);
         backend.addIdentity(kid);
+        // clear the identity cache.
+        backend.release();
         KrbIdentity kid2 = backend.getIdentity(TEST_PRINCIPAL);
 
         assertThat(kid).isEqualTo(kid2);
@@ -72,6 +87,9 @@ public abstract class BackendTest {
         kid.setDisabled(true);
         backend.updateIdentity(kid);
 
+        // clear the identity cache.
+        backend.release();
+
         assertThat(backend.getIdentity(TEST_PRINCIPAL)).isEqualTo(kid);
 
         //tearDown
@@ -81,6 +99,9 @@ public abstract class BackendTest {
     protected void testDelete(IdentityBackend backend) {
         KrbIdentity kid = createOneIdentity(TEST_PRINCIPAL);
         backend.addIdentity(kid);
+        // clear the identity cache.
+        backend.release();
+
         assertThat(backend.getIdentity(TEST_PRINCIPAL)).isNotNull();
 
         backend.deleteIdentity(TEST_PRINCIPAL);
@@ -94,6 +115,9 @@ public abstract class BackendTest {
             backend.addIdentity(identity);
         }
 
+        // clear the identity cache.
+        backend.release();
+
         List<String> principals = backend.getIdentities(2, 5);
         assertThat(principals).hasSize(3)
                 .contains(identities[2].getPrincipalName())


Mime
View raw message