use of com.epam.pipeline.entity.pipeline.DockerRegistry in project cloud-pipeline by epam.
the class ToolGroupApiServiceTest method setUp.
@Before
public void setUp() throws Exception {
TestUtils.configureDockerClientMock(dockerClient, clientFactory);
registry = new DockerRegistry();
registry.setPath(TEST_REPO);
registry.setOwner(TEST_USER);
registryDao.createDockerRegistry(registry);
existingGroup = new ToolGroup();
existingGroup.setRegistryId(registry.getId());
existingGroup.setName(TEST_GROUP_NAME);
existingGroup.setOwner(TEST_USER);
toolGroupDao.createToolGroup(existingGroup);
// Create SID for "test" user
testUserSid = new AclTestDao.AclSid(true, TEST_USER);
aclTestDao.createAclSid(testUserSid);
user2Sid = new AclTestDao.AclSid(true, TEST_USER2);
aclTestDao.createAclSid(user2Sid);
// And for USER group, which all users are belong to
userGroupSid = new AclTestDao.AclSid(false, "ROLE_USER");
aclTestDao.createAclSid(userGroupSid);
// Mock ACL stuff
AclTestDao.AclClass groupAclClass = new AclTestDao.AclClass(ToolGroup.class.getCanonicalName());
aclTestDao.createAclClassIfNotPresent(groupAclClass);
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.AclObjectIdentity groupIdentity = new AclTestDao.AclObjectIdentity(testUserSid, existingGroup.getId(), groupAclClass.getId(), registryIdentity, true);
aclTestDao.createObjectIdentity(groupIdentity);
// Make group private
AclTestDao.AclEntry groupAclEntry = new AclTestDao.AclEntry(groupIdentity, 1, userGroupSid, AclPermission.ALL_DENYING_PERMISSIONS.getMask(), false);
aclTestDao.createAclEntry(groupAclEntry);
// TEST_USER is allowed to write
groupAclEntry = new AclTestDao.AclEntry(groupIdentity, 2, testUserSid, AclPermission.WRITE.getMask(), true);
aclTestDao.createAclEntry(groupAclEntry);
// All Test users can write to registry
AclTestDao.AclEntry registryAclEntry = new AclTestDao.AclEntry(registryIdentity, 1, testUserSid, AclPermission.WRITE.getMask(), true);
aclTestDao.createAclEntry(registryAclEntry);
registryAclEntry.setSid(user2Sid);
registryAclEntry.setOrder(2);
aclTestDao.createAclEntry(registryAclEntry);
existingTool = ToolApiServiceTest.generateTool();
existingTool.setToolGroup(existingGroup.getName());
existingTool.setToolGroupId(existingGroup.getId());
existingTool.setRegistryId(registry.getId());
existingTool.setOwner(TEST_USER);
toolDao.createTool(existingTool);
}
use of com.epam.pipeline.entity.pipeline.DockerRegistry in project cloud-pipeline by epam.
the class DockerRegistryLoaderTest method shouldLoadDockerRegistryTest.
@Test
void shouldLoadDockerRegistryTest() throws EntityNotFoundException {
DockerRegistry expectedRegistry = new DockerRegistry();
expectedRegistry.setId(1L);
expectedRegistry.setDescription(TEST_DESCRIPTION);
expectedRegistry.setName(TEST_NAME);
expectedRegistry.setPath(TEST_PATH);
expectedRegistry.setOwner(TEST_NAME);
expectedRegistry.setUserName(USER_NAME);
DockerRegistryLoader dockerRegistryLoader = new DockerRegistryLoader(apiClient);
when(apiClient.loadDockerRegistry(anyLong())).thenReturn(expectedRegistry);
Optional<EntityContainer<DockerRegistry>> container = dockerRegistryLoader.loadEntity(1L);
EntityContainer<DockerRegistry> registryEntityContainer = container.orElseThrow(AssertionError::new);
DockerRegistry actualRegistry = registryEntityContainer.getEntity();
assertNotNull(actualRegistry);
verifyRegistry(expectedRegistry, actualRegistry);
verifyPipelineUser(registryEntityContainer.getOwner());
verifyPermissions(PERMISSIONS_CONTAINER_WITH_OWNER, registryEntityContainer.getPermissions());
verifyMetadata(EXPECTED_METADATA, new ArrayList<>(registryEntityContainer.getMetadata().values()));
}
Aggregations