From e1e5054e32fad26ea1ec72e0ae176af8d714b4df Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Thu, 14 Apr 2016 18:22:54 +0200 Subject: [PATCH] started adding a failing test case for bug3599 --- .../test/SimpleSecurityReplicationTest.java | 6 ++++ .../sap/sse/security/test/UserStoreTest.java | 30 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 java/com.sap.sse.security.test/src/com/sap/sse/security/test/UserStoreTest.java diff --git a/java/com.sap.sse.security.replication.test/src/com/sap/sse/security/replication/test/SimpleSecurityReplicationTest.java b/java/com.sap.sse.security.replication.test/src/com/sap/sse/security/replication/test/SimpleSecurityReplicationTest.java index 97a3fdedb07..72d73daa1e8 100755 --- a/java/com.sap.sse.security.replication.test/src/com/sap/sse/security/replication/test/SimpleSecurityReplicationTest.java +++ b/java/com.sap.sse.security.replication.test/src/com/sap/sse/security/replication/test/SimpleSecurityReplicationTest.java @@ -40,6 +40,12 @@ public class SimpleSecurityReplicationTest extends AbstractSecurityReplicationTe assertEquals(emailValidationSecret, replicatedErnie.getValidationSecret()); assertEquals(fullName, replicatedErnie.getFullName()); assertEquals(company, replicatedErnie.getCompany()); + + // check that incremental replication of access token handling works + final String accessToken = master.createAccessToken(username); + replicaReplicator.waitUntilQueueIsEmpty(); + Thread.sleep(3000); + assertEquals(username, replica.getUserByAccessToken(accessToken).getName()); } @Test diff --git a/java/com.sap.sse.security.test/src/com/sap/sse/security/test/UserStoreTest.java b/java/com.sap.sse.security.test/src/com/sap/sse/security/test/UserStoreTest.java new file mode 100644 index 00000000000..eae68170b41 --- /dev/null +++ b/java/com.sap.sse.security.test/src/com/sap/sse/security/test/UserStoreTest.java @@ -0,0 +1,30 @@ +package com.sap.sse.security.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +import com.sap.sse.security.UserStore; +import com.sap.sse.security.userstore.mongodb.UserStoreImpl; + +public class UserStoreTest { + @Test + public void testClear() { + final UserStore userStore = new UserStoreImpl(); + final String username = "abc"; + final String accessToken = "ak"; + userStore.setAccessToken(username, accessToken); + final String prefKey = "pk"; + final String prefValue = "pv"; + userStore.setPreference(username, prefKey, prefValue); + assertEquals(prefValue, userStore.getPreference(username, prefKey)); + assertEquals(username, userStore.getUserByAccessToken(accessToken).getName()); + assertEquals(accessToken, userStore.getAccessToken(username)); + + userStore.clear(); + assertNull(userStore.getPreference(username, prefKey)); + assertNull(userStore.getUserByAccessToken(accessToken)); + assertNull(userStore.getAccessToken(username)); + } +}