mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-17 01:31:01 +00:00
Added failing tests to verify that preferences are currently not
correctly removed when a user is being deleted
This commit is contained in:
1 parent
5004b250f0
commit
aaa04bb2fb
3 files changed
+44
-1
No files matched your search
+15
@@ -212,6 +212,21 @@ public class PreferenceObjectBasedNotificationSetTest {
|
||||
Assert.assertTrue(Util.equals(users(store.getUserByName(user1)), mock.calls));
|
||||
}
|
||||
|
||||
/**
|
||||
* There was a bug that caused the preferences not to be removed when a user was deleted.
|
||||
*/
|
||||
@Test
|
||||
public void deleteUserWithMappingTest() throws UserManagementException {
|
||||
store.createUser(user1, mail);
|
||||
store.registerPreferenceConverter(prefKey, prefConverter);
|
||||
store.setPreferenceObject(user1, prefKey, values1);
|
||||
PreferenceObjectBasedNotificationSetImpl notificationSet = new PreferenceObjectBasedNotificationSetImpl(prefKey, store);
|
||||
store.deleteUser(user1);
|
||||
Assert.assertTrue(Util.equals(notificationSet.getUsersnamesToNotifyFor(A), values()));
|
||||
Assert.assertTrue(Util.equals(notificationSet.getUsersnamesToNotifyFor(B), values()));
|
||||
Assert.assertTrue(Util.equals(notificationSet.getUsersnamesToNotifyFor(C), values()));
|
||||
}
|
||||
|
||||
private static HashSet<String> values(String... values) {
|
||||
return new HashSet<>(Arrays.asList(values));
|
||||
}
|
||||
|
||||
+15
-1
@@ -10,6 +10,7 @@ import com.mongodb.DB;
|
||||
import com.mongodb.MongoException;
|
||||
import com.sap.sse.mongodb.MongoDBConfiguration;
|
||||
import com.sap.sse.mongodb.MongoDBService;
|
||||
import com.sap.sse.security.shared.UserManagementException;
|
||||
import com.sap.sse.security.userstore.mongodb.UserStoreImpl;
|
||||
import com.sap.sse.security.userstore.mongodb.impl.CollectionNames;
|
||||
|
||||
@@ -18,7 +19,8 @@ import junit.framework.Assert;
|
||||
public class UserPreferenceObjectAndConverterTest {
|
||||
|
||||
private UserStoreImpl store;
|
||||
|
||||
|
||||
private final String email = "anonymous@sapsailing.com";
|
||||
private String user1 = "me";
|
||||
private String user2 = "somebody_else";
|
||||
|
||||
@@ -104,6 +106,18 @@ public class UserPreferenceObjectAndConverterTest {
|
||||
store.setPreferenceObject(user1, prefKey1, null);
|
||||
Assert.assertEquals(null, store.getPreferenceObject(user1, prefKey1));
|
||||
}
|
||||
|
||||
/**
|
||||
* There was a bug that caused the preferences not to be removed when a user was deleted.
|
||||
*/
|
||||
@Test
|
||||
public void deleteUserWithPreferenceObjectTest() throws UserManagementException {
|
||||
store.createUser(user1, email);
|
||||
store.registerPreferenceConverter(prefKey1, prefConverter);
|
||||
store.setPreferenceObject(user1, prefKey1, pref1);
|
||||
store.deleteUser(user1);
|
||||
Assert.assertNull(store.getPreferenceObject(user1, prefKey1));
|
||||
}
|
||||
|
||||
public static class SimplePreferenceForSerialization implements Serializable {
|
||||
private static final long serialVersionUID = -580569932709860895L;
|
||||
|
||||
+14
@@ -13,6 +13,7 @@ import com.mongodb.DB;
|
||||
import com.mongodb.MongoException;
|
||||
import com.sap.sse.mongodb.MongoDBConfiguration;
|
||||
import com.sap.sse.mongodb.MongoDBService;
|
||||
import com.sap.sse.security.UserStore;
|
||||
import com.sap.sse.security.shared.UserManagementException;
|
||||
import com.sap.sse.security.userstore.mongodb.UserStoreImpl;
|
||||
import com.sap.sse.security.userstore.mongodb.impl.CollectionNames;
|
||||
@@ -89,4 +90,17 @@ public class UserStoreWithPersistenceTest {
|
||||
newStore();
|
||||
assertNull(store.getPreference(username, prefKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* There was a bug that caused the preferences not to be removed when a user was deleted.
|
||||
*/
|
||||
@Test
|
||||
public void testDeleteUserWithPreferences() throws UserManagementException {
|
||||
store.createUser(username, email);
|
||||
store.setPreference(username, prefKey, prefValue);
|
||||
store.deleteUser(username);
|
||||
assertNull(store.getPreference(username, prefKey));
|
||||
newStore();
|
||||
assertNull(store.getPreference(username, prefKey));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user