Search in sources :

Example 41 with ToolGroup

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

the class DockerRegistryManagerTest method testLoadingImageTags.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadingImageTags() {
    DockerRegistry registry = generateRegistry();
    registryDao.createDockerRegistry(registry);
    ToolGroup group = generateToolGroup(registry);
    toolGroupDao.createToolGroup(group);
    Tool tool = generateTool(group);
    toolManager.create(tool, true);
    DockerClient mockClient = Mockito.mock(DockerClient.class);
    when(dockerClientFactoryMock.getDockerClient(any(DockerRegistry.class), any())).thenReturn(mockClient);
    List<String> expected = Arrays.asList("TAG1", "TAG2");
    when(mockClient.getImageTags(ANOTHER_PATH, TEST_IMAGE)).thenReturn(expected);
    Assert.assertEquals(expected, dockerRegistryManager.loadImageTags(registry, tool));
}
Also used : DockerRegistry(com.epam.pipeline.entity.pipeline.DockerRegistry) ToolGroup(com.epam.pipeline.entity.pipeline.ToolGroup) Tool(com.epam.pipeline.entity.pipeline.Tool) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 42 with ToolGroup

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

the class DockerRegistryManagerTest method testDelete.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testDelete() {
    TestUtils.configureDockerClientMock(Mockito.mock(DockerClient.class), dockerClientFactoryMock);
    DockerRegistry registry = generateRegistry();
    registryDao.createDockerRegistry(registry);
    ToolGroup group = generateToolGroup(registry);
    toolGroupDao.createToolGroup(group);
    Tool tool = generateTool(group);
    toolManager.create(tool, true);
    dockerRegistryManager.delete(registry.getId(), true);
}
Also used : DockerRegistry(com.epam.pipeline.entity.pipeline.DockerRegistry) ToolGroup(com.epam.pipeline.entity.pipeline.ToolGroup) Tool(com.epam.pipeline.entity.pipeline.Tool) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 43 with ToolGroup

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

the class DockerRegistryManagerTest method testLoadingImageDescription.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadingImageDescription() {
    DockerRegistry registry = generateRegistry();
    Date date = new Date();
    registryDao.createDockerRegistry(registry);
    ToolGroup group = generateToolGroup(registry);
    toolGroupDao.createToolGroup(group);
    Tool tool = generateTool(group);
    toolManager.create(tool, true);
    DockerClient mockClient = Mockito.mock(DockerClient.class);
    when(dockerClientFactoryMock.getDockerClient(any(DockerRegistry.class), any())).thenReturn(mockClient);
    ImageDescription expected = new ImageDescription(1L, TEST_IMAGE, TEST_TAG, date);
    when(mockClient.getImageDescription(registry, tool.getName(), TEST_TAG)).thenReturn(expected);
    Assert.assertEquals(expected, dockerRegistryManager.getImageDescription(registry, tool.getName(), TEST_TAG));
}
Also used : DockerRegistry(com.epam.pipeline.entity.pipeline.DockerRegistry) ToolGroup(com.epam.pipeline.entity.pipeline.ToolGroup) ImageDescription(com.epam.pipeline.entity.docker.ImageDescription) Date(java.util.Date) Tool(com.epam.pipeline.entity.pipeline.Tool) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 44 with ToolGroup

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

the class ToolApiServiceTest method setUp.

@Before
public void setUp() {
    TestUtils.configureDockerClientMock(dockerClient, clientFactory);
    registry = new DockerRegistry();
    registry.setPath(TEST_REPO);
    registry.setOwner(TEST_USER);
    registryDao.createDockerRegistry(registry);
    // Create SID for "test" user
    testUserSid = new AclTestDao.AclSid(true, TEST_USER);
    aclTestDao.createAclSid(testUserSid);
    AclTestDao.AclClass registryAclClass = new AclTestDao.AclClass(DockerRegistry.class.getCanonicalName());
    aclTestDao.createAclClassIfNotPresent(registryAclClass);
    AclTestDao.AclObjectIdentity registryIdentity = new AclTestDao.AclObjectIdentity(testUserSid, registry.getId(), registryAclClass.getId(), null, true);
    aclTestDao.createObjectIdentity(registryIdentity);
    AclTestDao.AclEntry registryAclEntry = new AclTestDao.AclEntry(registryIdentity, 1, testUserSid, AclPermission.WRITE.getMask(), true);
    aclTestDao.createAclEntry(registryAclEntry);
    allowedGroup = new ToolGroup();
    allowedGroup.setRegistryId(registry.getId());
    allowedGroup.setName(TEST_GROUP_NAME);
    toolGroupManager.create(allowedGroup);
    PermissionGrantVO grantVO = new PermissionGrantVO();
    grantVO.setAclClass(AclClass.TOOL_GROUP);
    grantVO.setId(allowedGroup.getId());
    grantVO.setMask(AclPermission.WRITE.getMask());
    grantVO.setPrincipal(true);
    grantVO.setUserName(TEST_USER);
    grantPermissionManager.setPermissions(grantVO);
}
Also used : DockerRegistry(com.epam.pipeline.entity.pipeline.DockerRegistry) PermissionGrantVO(com.epam.pipeline.controller.vo.PermissionGrantVO) ToolGroup(com.epam.pipeline.entity.pipeline.ToolGroup) AclTestDao(com.epam.pipeline.dao.util.AclTestDao) AclClass(com.epam.pipeline.entity.security.acl.AclClass) Before(org.junit.Before)

Example 45 with ToolGroup

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

the class ToolGroupManagerTest method testChangeOwner.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testChangeOwner() {
    ToolGroup group = createToolGroup();
    toolGroupManager.changeOwner(group.getId(), TEST_OTHER_USER);
    ToolGroup loaded = toolGroupManager.load(group.getId());
    Assert.assertEquals(TEST_OTHER_USER, loaded.getOwner());
}
Also used : ToolGroup(com.epam.pipeline.entity.pipeline.ToolGroup) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ToolGroup (com.epam.pipeline.entity.pipeline.ToolGroup)53 Transactional (org.springframework.transaction.annotation.Transactional)27 DockerRegistry (com.epam.pipeline.entity.pipeline.DockerRegistry)25 Test (org.junit.Test)20 Tool (com.epam.pipeline.entity.pipeline.Tool)14 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)10 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)10 Before (org.junit.Before)10 AclPermission (com.epam.pipeline.security.acl.AclPermission)6 List (java.util.List)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 Propagation (org.springframework.transaction.annotation.Propagation)6 DockerRegistryDao (com.epam.pipeline.dao.docker.DockerRegistryDao)4 AclTestDao (com.epam.pipeline.dao.util.AclTestDao)4 AclClass (com.epam.pipeline.entity.security.acl.AclClass)4 Optional (java.util.Optional)4 Assert (org.junit.Assert)4 WithMockUser (org.springframework.security.test.context.support.WithMockUser)4 PermissionGrantVO (com.epam.pipeline.controller.vo.PermissionGrantVO)3 ToolGroupDao (com.epam.pipeline.dao.tool.ToolGroupDao)3