use of com.walmartlabs.concord.server.ConcordObjectMapper in project concord by walmartlabs.
the class ProcessStateManagerTest method testUpdateState.
@Test
public void testUpdateState() throws Exception {
ProcessKey processKey = new ProcessKey(UUID.randomUUID(), OffsetDateTime.now());
Path baseDir = Files.createTempDirectory("testImport");
writeTempFile(baseDir.resolve("file-1"), "123".getBytes());
writeTempFile(baseDir.resolve("file-2"), "456".getBytes());
//
ProcessKeyCache processKeyCache = new ProcessKeyCache(new ProcessQueueDao(getConfiguration(), new ConcordObjectMapper(new ObjectMapper())));
ProcessConfiguration stateCfg = new ProcessConfiguration(Duration.of(24, ChronoUnit.HOURS), Collections.singletonList(Constants.Files.CONFIGURATION_FILE_NAME));
ProcessStateManager stateManager = new ProcessStateManager(getConfiguration(), mock(SecretStoreConfiguration.class), stateCfg, mock(PolicyManager.class), mock(ProcessLogManager.class), processKeyCache);
stateManager.importPath(processKey, null, baseDir, (p, attrs) -> true);
Path tmpDir = Files.createTempDirectory("testExport");
boolean result = stateManager.export(processKey, copyTo(tmpDir));
assertTrue(result);
assertFileContent("123", tmpDir.resolve("file-1"));
assertFileContent("456", tmpDir.resolve("file-2"));
// --- update
writeTempFile(baseDir.resolve("file-1"), "123-up".getBytes());
stateManager.importPath(processKey, null, baseDir, (p, attrs) -> true);
result = stateManager.export(processKey, copyTo(tmpDir));
assertTrue(result);
assertFileContent("123-up", tmpDir.resolve("file-1"));
assertFileContent("456", tmpDir.resolve("file-2"));
}
use of com.walmartlabs.concord.server.ConcordObjectMapper in project concord by walmartlabs.
the class ProcessStateManagerTest method testLargeImport.
@Test
public void testLargeImport() throws Exception {
ProcessKey processKey = new ProcessKey(UUID.randomUUID(), OffsetDateTime.now());
int files = 100;
int chunkSize = 1024 * 1024;
int fileSize = 10 * chunkSize;
byte[] ab = new byte[chunkSize];
Arrays.fill(ab, (byte) 0);
Path baseDir = Files.createTempDirectory("test");
for (int i = 0; i < files; i++) {
Path p = baseDir.resolve("file" + i);
try (OutputStream out = Files.newOutputStream(p, StandardOpenOption.CREATE)) {
for (int j = 0; j < fileSize; j += chunkSize) {
out.write(ab);
}
}
}
ProcessKeyCache processKeyCache = new ProcessKeyCache(new ProcessQueueDao(getConfiguration(), new ConcordObjectMapper(new ObjectMapper())));
ProcessConfiguration stateCfg = new ProcessConfiguration(Duration.of(24, ChronoUnit.HOURS), Collections.singletonList(Constants.Files.CONFIGURATION_FILE_NAME));
ProcessStateManager stateManager = new ProcessStateManager(getConfiguration(), mock(SecretStoreConfiguration.class), stateCfg, mock(PolicyManager.class), mock(ProcessLogManager.class), processKeyCache);
stateManager.importPath(processKey, "/", baseDir, (p, attrs) -> true);
}
use of com.walmartlabs.concord.server.ConcordObjectMapper in project concord by walmartlabs.
the class SecretDaoTest method testOnCascade.
@Test
public void testOnCascade() {
UUID orgId = OrganizationManager.DEFAULT_ORG_ID;
String projectName = "project#" + System.currentTimeMillis();
ProjectDao projectDao = new ProjectDao(getConfiguration(), new ConcordObjectMapper(TestObjectMapper.INSTANCE));
UUID projectId = projectDao.insert(orgId, projectName, "test", null, null, null, null, new byte[0], null, null);
String secretName = "secret#" + System.currentTimeMillis();
SecretDao secretDao = new SecretDao(getConfiguration());
UUID secretId = secretDao.insert(orgId, null, secretName, null, SecretType.KEY_PAIR, SecretEncryptedByType.SERVER_KEY, "concord", SecretVisibility.PUBLIC, INSERT);
secretDao.updateData(secretId, new byte[] { 0, 1, 2 });
secretDao.update(secretId, secretName, UUID.fromString("4b9d496a-c3a0-4e1b-804c-ac3fccddcb27"), null, new byte[0], null, projectId, orgId);
String repoName = "repo#" + System.currentTimeMillis();
RepositoryDao repositoryDao = new RepositoryDao(getConfiguration(), new ConcordObjectMapper(TestObjectMapper.INSTANCE));
UUID repoId = repositoryDao.insert(projectId, repoName, "n/a", null, null, null, secretId, false, null, false);
// ---
secretDao.delete(secretId);
// ---
RepositoryEntry r = repositoryDao.get(projectId, repoId);
assertNotNull(r);
assertNull(r.getSecretName());
}
use of com.walmartlabs.concord.server.ConcordObjectMapper in project concord by walmartlabs.
the class ProjectDaoTest method setUp.
@BeforeEach
public void setUp() {
repositoryDao = new RepositoryDao(getConfiguration(), new ConcordObjectMapper(TestObjectMapper.INSTANCE));
projectDao = new ProjectDao(getConfiguration(), new ConcordObjectMapper(TestObjectMapper.INSTANCE));
}
use of com.walmartlabs.concord.server.ConcordObjectMapper in project concord by walmartlabs.
the class ProcessKeyCacheTest method testNotFound.
@Test
public void testNotFound() {
ProcessQueueDao dao = new ProcessQueueDao(getConfiguration(), new ConcordObjectMapper(TestObjectMapper.INSTANCE));
ProcessKeyCache keyCache = new ProcessKeyCache(dao);
ProcessKey key = keyCache.get(UUID.randomUUID());
assertNull(key);
}
Aggregations