Search in sources :

Example 6 with DockerRegistry

use of com.epam.pipeline.entity.pipeline.DockerRegistry in project cloud-pipeline by epam.

the class DockerRegistryDaoTest method initTestHierarchy.

private List<DockerRegistry> initTestHierarchy() {
    DockerRegistry createdRegistry = new DockerRegistry();
    createdRegistry.setPath(REGISTRY_PATH);
    createdRegistry.setOwner(TEST_USER);
    registryDao.createDockerRegistry(createdRegistry);
    DockerRegistry createdRegistry2 = new DockerRegistry();
    createdRegistry2.setPath(ANOTHER_REGISTRY_PATH);
    createdRegistry2.setOwner(TEST_USER);
    registryDao.createDockerRegistry(createdRegistry2);
    ToolGroup library = createToolGroup(createdRegistry);
    ToolGroup library2 = createToolGroup(createdRegistry2);
    toolGroupDao.createToolGroup(library);
    toolGroupDao.createToolGroup(library2);
    createdRegistry.setGroups(Collections.singletonList(library));
    createdRegistry2.setGroups(Collections.singletonList(library2));
    Tool tool = createTool(TOOL_IMAGE, createdRegistry.getId(), library);
    toolDao.createTool(tool);
    library.setTools(Collections.singletonList(tool));
    createdRegistry.setTools(Collections.singletonList(tool));
    Tool tool2 = createTool(ANOTHER_TOOL_IMAGE, createdRegistry2.getId(), library2);
    toolDao.createTool(tool2);
    library2.setTools(Collections.singletonList(tool2));
    return Arrays.asList(createdRegistry, createdRegistry2);
}
Also used : DockerRegistry(com.epam.pipeline.entity.pipeline.DockerRegistry) ToolGroup(com.epam.pipeline.entity.pipeline.ToolGroup) Tool(com.epam.pipeline.entity.pipeline.Tool)

Example 7 with DockerRegistry

use of com.epam.pipeline.entity.pipeline.DockerRegistry in project cloud-pipeline by epam.

the class DockerRegistryDaoTest method updateDockerRegistry.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void updateDockerRegistry() throws Exception {
    DockerRegistry created = getDockerRegistry();
    registryDao.createDockerRegistry(created);
    created.setDescription(EMPTY);
    registryDao.updateDockerRegistry(created);
    DockerRegistry loaded = registryDao.loadDockerRegistry(created.getId());
    Assert.assertEquals(EMPTY, loaded.getDescription());
}
Also used : DockerRegistry(com.epam.pipeline.entity.pipeline.DockerRegistry) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with DockerRegistry

use of com.epam.pipeline.entity.pipeline.DockerRegistry in project cloud-pipeline by epam.

the class DockerRegistryDaoTest method testLoadAllRegistriesContent.

@Test
@Ignore
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testLoadAllRegistriesContent() {
    List<DockerRegistry> created = initTestHierarchy();
    Set<Long> createdRegistryIds = created.stream().map(BaseEntity::getId).collect(Collectors.toSet());
    List<DockerRegistry> dockerRegistries = registryDao.loadAllRegistriesContent();
    Assert.assertFalse(dockerRegistries.isEmpty());
    for (int i = 0; i < dockerRegistries.size(); i++) {
        DockerRegistry loadedRegistry = dockerRegistries.get(i);
        if (createdRegistryIds.contains(loadedRegistry.getId())) {
            Assert.assertFalse(loadedRegistry.getGroups().isEmpty());
            Assert.assertEquals(loadedRegistry.getGroups().get(0).getName(), created.get(i).getGroups().get(0).getName());
            Assert.assertEquals(loadedRegistry.getGroups().get(0).getDescription(), created.get(i).getGroups().get(0).getDescription());
            for (int j = 0; j < created.get(i).getGroups().get(0).getTools().size(); j++) {
                Tool tool = created.get(i).getGroups().get(0).getTools().get(j);
                Tool loadedTool = loadedRegistry.getGroups().get(0).getTools().get(j);
                Assert.assertEquals(tool.getId(), loadedTool.getId());
                Assert.assertEquals(tool.getImage(), loadedTool.getImage());
                Assert.assertEquals(tool.getCpu(), loadedTool.getCpu());
            }
        }
    }
}
Also used : DockerRegistry(com.epam.pipeline.entity.pipeline.DockerRegistry) Tool(com.epam.pipeline.entity.pipeline.Tool) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with DockerRegistry

use of com.epam.pipeline.entity.pipeline.DockerRegistry in project cloud-pipeline by epam.

the class ToolGroupDaoTest method setUp.

@Before
public void setUp() throws Exception {
    registry = new DockerRegistry();
    registry.setPath(TEST_REPO);
    registry.setOwner(TEST_USER);
    registryDao.createDockerRegistry(registry);
    registry2 = new DockerRegistry();
    registry2.setPath(TEST_REPO2);
    registry2.setOwner(TEST_USER);
    registryDao.createDockerRegistry(registry2);
}
Also used : DockerRegistry(com.epam.pipeline.entity.pipeline.DockerRegistry) Before(org.junit.Before)

Example 10 with DockerRegistry

use of com.epam.pipeline.entity.pipeline.DockerRegistry in project cloud-pipeline by epam.

the class ToolVulnerabilityDaoTest method setUp.

@Before
public void setUp() throws Exception {
    DockerRegistry registry = DockerRegistryDaoTest.getDockerRegistry();
    dockerRegistryDao.createDockerRegistry(registry);
    ToolGroup group = ToolGroupDaoTest.getToolGroup("test", registry);
    toolGroupDao.createToolGroup(group);
    tool = generateTool();
    tool.setToolGroupId(group.getId());
    tool.setRegistryId(registry.getId());
    toolDao.createTool(tool);
}
Also used : DockerRegistry(com.epam.pipeline.entity.pipeline.DockerRegistry) ToolGroup(com.epam.pipeline.entity.pipeline.ToolGroup) Before(org.junit.Before)

Aggregations

DockerRegistry (com.epam.pipeline.entity.pipeline.DockerRegistry)57 Transactional (org.springframework.transaction.annotation.Transactional)24 ToolGroup (com.epam.pipeline.entity.pipeline.ToolGroup)22 Tool (com.epam.pipeline.entity.pipeline.Tool)19 Test (org.junit.Test)14 Before (org.junit.Before)10 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)7 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)6 MessageHelper (com.epam.pipeline.common.MessageHelper)4 AclClass (com.epam.pipeline.entity.security.acl.AclClass)4 DockerClient (com.epam.pipeline.manager.docker.DockerClient)4 DockerRegistryManager (com.epam.pipeline.manager.docker.DockerRegistryManager)4 IOException (java.io.IOException)4 List (java.util.List)4 Optional (java.util.Optional)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 MessageConstants (com.epam.pipeline.common.MessageConstants)3 PermissionGrantVO (com.epam.pipeline.controller.vo.PermissionGrantVO)3 AbstractSecuredEntity (com.epam.pipeline.entity.AbstractSecuredEntity)3 ToolVersionScanResult (com.epam.pipeline.entity.scan.ToolVersionScanResult)3