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));
}
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);
}
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));
}
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);
}
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());
}
Aggregations