RED-8702: Explore document databases to store entityLog
This commit is contained in:
parent
ff3fb59c39
commit
6ffffd75d9
@ -13,6 +13,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package com.iqser.red.service.peristence.v1.server.integration.utils;
|
||||
|
||||
import static com.iqser.red.service.peristence.v1.server.integration.utils.MongoDBTestContainer.MONGO_DATABASE;
|
||||
import static com.iqser.red.service.peristence.v1.server.integration.utils.MongoDBTestContainer.MONGO_PASSWORD;
|
||||
import static com.iqser.red.service.peristence.v1.server.integration.utils.MongoDBTestContainer.MONGO_USERNAME;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -104,6 +107,8 @@ import com.iqser.red.storage.commons.utils.FileSystemBackedStorageService;
|
||||
import com.knecon.fforesight.databasetenantcommons.providers.TenantCreatedListener;
|
||||
import com.knecon.fforesight.databasetenantcommons.providers.events.TenantCreatedEvent;
|
||||
import com.knecon.fforesight.databasetenantcommons.providers.utils.MagicConverter;
|
||||
import com.knecon.fforesight.mongo.database.commons.liquibase.MongoTenantCreatedEvent;
|
||||
import com.knecon.fforesight.mongo.database.commons.liquibase.MongoTenantCreatedListener;
|
||||
import com.knecon.fforesight.tenantcommons.EncryptionDecryptionService;
|
||||
import com.knecon.fforesight.tenantcommons.TenantContext;
|
||||
import com.knecon.fforesight.tenantcommons.TenantsClient;
|
||||
@ -233,6 +238,8 @@ public abstract class AbstractPersistenceServerServiceTest {
|
||||
private EncryptionDecryptionService encryptionDecryptionService;
|
||||
@Autowired
|
||||
private TenantCreatedListener tenantCreatedListener;
|
||||
@Autowired
|
||||
private MongoTenantCreatedListener mongoTenantCreatedListener;
|
||||
|
||||
|
||||
private static String[] getAllRoles() {
|
||||
@ -360,9 +367,9 @@ public abstract class AbstractPersistenceServerServiceTest {
|
||||
redactionTenant.setMongoDBConnection(MongoDBConnection.builder()
|
||||
.host(mongoDbContainer.getHost())
|
||||
.port(String.valueOf(mongoDbContainer.getFirstMappedPort()))
|
||||
.username(MongoDBTestContainer.MONGO_USERNAME)
|
||||
.password(encryptionDecryptionService.encrypt(MongoDBTestContainer.MONGO_PASSWORD))
|
||||
.database(MongoDBTestContainer.MONGO_DATABASE)
|
||||
.username(MONGO_USERNAME)
|
||||
.password(encryptionDecryptionService.encrypt(MONGO_PASSWORD))
|
||||
.database(MONGO_DATABASE)
|
||||
.build());
|
||||
|
||||
when(tenantsClient.getTenant("redaction")).thenReturn(redactionTenant);
|
||||
@ -370,6 +377,7 @@ public abstract class AbstractPersistenceServerServiceTest {
|
||||
|
||||
try {
|
||||
tenantCreatedListener.createTenant(new TenantCreatedEvent("redaction"));
|
||||
mongoTenantCreatedListener.createTenant(new MongoTenantCreatedEvent("redaction"));
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
@ -393,8 +401,6 @@ public abstract class AbstractPersistenceServerServiceTest {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@AfterEach
|
||||
public void cleanupStorage() {
|
||||
|
||||
@ -477,8 +483,8 @@ public abstract class AbstractPersistenceServerServiceTest {
|
||||
"REDIS_HOST=" + redisContainer.getHost(),
|
||||
"MONGODB_HOST=" + mongoInstance.getHost(),
|
||||
"MONGODB_PORT=" + mongoInstance.getFirstMappedPort(),
|
||||
"MONGODB_USER=" + MongoDBTestContainer.MONGO_USERNAME,
|
||||
"MONGODB_PASSWORD=" + MongoDBTestContainer.MONGO_PASSWORD,
|
||||
"MONGODB_USER=" + MONGO_USERNAME,
|
||||
"MONGODB_PASSWORD=" + MONGO_PASSWORD,
|
||||
"fforesight.jobs.enabled=false",
|
||||
"fforesight.keycloak.enabled=false").applyTo(configurableApplicationContext.getEnvironment());
|
||||
|
||||
@ -490,23 +496,23 @@ public abstract class AbstractPersistenceServerServiceTest {
|
||||
private static void createMongoDBDatabase(MongoDBTestContainer mongoDBTestContainer) {
|
||||
|
||||
try (MongoClient mongoClient = MongoClients.create(String.format("mongodb://%s:%s@%s:%s/",
|
||||
MongoDBTestContainer.MONGO_USERNAME,
|
||||
MongoDBTestContainer.MONGO_PASSWORD,
|
||||
MONGO_USERNAME,
|
||||
MONGO_PASSWORD,
|
||||
mongoDBTestContainer.getHost(),
|
||||
mongoDBTestContainer.getFirstMappedPort()))) {
|
||||
MongoDatabase database = mongoClient.getDatabase(MongoDBTestContainer.MONGO_DATABASE);
|
||||
MongoDatabase database = mongoClient.getDatabase(MONGO_DATABASE);
|
||||
BsonDocument createUserCommand = new BsonDocument();
|
||||
createUserCommand.append("createUser", new BsonString(MongoDBTestContainer.MONGO_USERNAME));
|
||||
createUserCommand.append("pwd", new BsonString(MongoDBTestContainer.MONGO_PASSWORD));
|
||||
createUserCommand.append("createUser", new BsonString(MONGO_USERNAME));
|
||||
createUserCommand.append("pwd", new BsonString(MONGO_PASSWORD));
|
||||
BsonArray roles = new BsonArray();
|
||||
roles.add(new BsonString("readWrite"));
|
||||
roles.add(new BsonDocument("role", new BsonString("dbOwner")).append("db", new BsonString(MONGO_DATABASE)));
|
||||
createUserCommand.append("roles", roles);
|
||||
|
||||
try {
|
||||
database.runCommand(createUserCommand);
|
||||
} catch (MongoCommandException mongoCommandException) {
|
||||
// ignore user already exists
|
||||
if(mongoCommandException.getErrorCode() != 51003) {
|
||||
if (mongoCommandException.getErrorCode() != 51003) {
|
||||
throw mongoCommandException;
|
||||
}
|
||||
|
||||
@ -515,11 +521,12 @@ public abstract class AbstractPersistenceServerServiceTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableMethodSecurity
|
||||
@EnableAutoConfiguration(exclude = {RabbitAutoConfiguration.class})
|
||||
@ComponentScan(basePackages = {"com.iqser.red.service.persistence" })
|
||||
@ComponentScan("com.iqser.red.service.persistence")
|
||||
public static class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user