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)); + } +}