drop/clear User/AccessContol stores prior to test execution

This commit is contained in:
Axel Uhl committed 2024-09-11 12:26:48 +02:00
1 parent bf1b433831
commit 014a5e12aa
2 files changed
+6

No files matched your search

@@ -93,9 +93,11 @@ public abstract class AbstractStoreMergeTest {
cfgForTarget = MongoDBConfiguration.getDefaultTestConfiguration();
targetService = cfgForTarget.getService();
causallyConsistentSessionForTarget = targetService.startCausallyConsistentSession();
new MongoDatabaseWrapperWithClientSession(causallyConsistentSessionForTarget, targetService.getDB()).withReadConcern(ReadConcern.MAJORITY).withWriteConcern(WriteConcern.MAJORITY).drop();
cfgForSource = new MongoDBConfiguration(new ConnectionString(importSourceMongoDbUri));
sourceService = cfgForSource.getService();
causallyConsistentSessionForSource = sourceService.startCausallyConsistentSession();
new MongoDatabaseWrapperWithClientSession(causallyConsistentSessionForSource, sourceService.getDB()).withReadConcern(ReadConcern.MAJORITY).withWriteConcern(WriteConcern.MAJORITY).drop();
}
protected void setUp(String sourceVariant, String targetVariant) throws IOException, UserStoreManagementException {
@@ -32,10 +32,14 @@ public class SecurityServiceAndHasPermissionsProviderTest {
@Before
public void setup() throws UserStoreManagementException {
new UserStoreImpl(PersistenceFactory.INSTANCE.getDefaultMajorityDomainObjectFactory(),
PersistenceFactory.INSTANCE.getDefaultMajorityMongoObjectFactory(), TEST_DEFAULT_TENANT).clear();
userStore = new UserStoreImpl(PersistenceFactory.INSTANCE.getDefaultMajorityDomainObjectFactory(),
PersistenceFactory.INSTANCE.getDefaultMajorityMongoObjectFactory(), TEST_DEFAULT_TENANT);
userStore.ensureDefaultRolesExist();
userStore.loadAndMigrateUsers();
new AccessControlStoreImpl(PersistenceFactory.INSTANCE.getDefaultMajorityDomainObjectFactory(),
PersistenceFactory.INSTANCE.getDefaultMajorityMongoObjectFactory(), userStore).clear();
accessControlStore = new AccessControlStoreImpl(PersistenceFactory.INSTANCE.getDefaultMajorityDomainObjectFactory(),
PersistenceFactory.INSTANCE.getDefaultMajorityMongoObjectFactory(), userStore);
}