Search in sources :

Example 11 with S3bucketDataStorage

use of com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage in project cloud-pipeline by epam.

the class RoleDaoTest method shouldUpdateStorage.

@Test
public void shouldUpdateStorage() {
    Role testRole = roleDao.createRole(TEST_ROLE);
    S3bucketDataStorage s3bucketDataStorage = ObjectCreatorUtils.createS3Bucket(null, TEST_STORAGE_PATH, TEST_STORAGE_PATH, TEST_USER1);
    dataStorageDao.createDataStorage(s3bucketDataStorage);
    testRole.setUserDefault(true);
    testRole.setDefaultStorageId(s3bucketDataStorage.getId());
    testRole.setName(TEST_ROLE_UPDATED);
    roleDao.updateRole(testRole);
    Optional<Role> loaded = roleDao.loadRole(testRole.getId());
    assertThat(loaded.isPresent(), equalTo(true));
    Role role = loaded.get();
    assertThat(role.getName(), equalTo(TEST_ROLE_UPDATED));
    assertThat(role.getDefaultStorageId(), equalTo(s3bucketDataStorage.getId()));
    assertThat(role.isUserDefault(), equalTo(true));
}
Also used : ExtendedRole(com.epam.pipeline.entity.user.ExtendedRole) Role(com.epam.pipeline.entity.user.Role) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest)

Example 12 with S3bucketDataStorage

use of com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage in project cloud-pipeline by epam.

the class UserDaoTest method shouldReturnUserByStorageId.

@Test
public void shouldReturnUserByStorageId() {
    S3bucketDataStorage s3bucketDataStorage = ObjectCreatorUtils.createS3Bucket(null, "test", "test", TEST_USER1);
    dataStorageDao.createDataStorage(s3bucketDataStorage);
    PipelineUser user = new PipelineUser();
    user.setUserName(TEST_USER1);
    user.setDefaultStorageId(s3bucketDataStorage.getId());
    userDao.createUser(user, Arrays.asList(DefaultRoles.ROLE_ADMIN.getId(), DefaultRoles.ROLE_USER.getId()));
    Assert.assertThat(userDao.loadUsersByStorageId(s3bucketDataStorage.getId()), hasSize(1));
}
Also used : PipelineUser(com.epam.pipeline.entity.user.PipelineUser) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest)

Example 13 with S3bucketDataStorage

use of com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage in project cloud-pipeline by epam.

the class ObjectCreatorUtils method clone.

public static S3bucketDataStorage clone(S3bucketDataStorage s3Bucket) {
    S3bucketDataStorage storage = new S3bucketDataStorage(s3Bucket.getId(), s3Bucket.getName(), s3Bucket.getPath(), s3Bucket.getStoragePolicy(), s3Bucket.getMountPoint());
    storage.setParentFolderId(s3Bucket.getParentFolderId());
    storage.setParent(s3Bucket.getParent());
    storage.setMountOptions(s3Bucket.getMountOptions());
    storage.setOwner(s3Bucket.getOwner());
    storage.setDescription(s3Bucket.getDescription());
    storage.setRegionId(s3Bucket.getRegionId());
    storage.setAllowedCidrs(new ArrayList<>(s3Bucket.getAllowedCidrs()));
    return storage;
}
Also used : S3bucketDataStorage(com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage)

Example 14 with S3bucketDataStorage

use of com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage in project cloud-pipeline by epam.

the class DataStorageEventServiceTest method shouldAddS3Event.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldAddS3Event() {
    doNothing().when(entityManager).setManagers(anyListOf(SecuredEntityManager.class));
    when(issueManager.loadIssuesForEntity(any())).thenReturn(Arrays.asList(Issue.builder().id(1L).build(), Issue.builder().id(2L).build()));
    when(dataStorageManager.load(1L)).thenReturn(new S3bucketDataStorage(1L, "", ""));
    doNothing().when(eventDao).insertUpdateEvent(anyString(), anyLong());
    dataStorageEventService.updateEventsWithChildrenAndIssues(1L);
    verify(eventDao).insertUpdateEvent("S3", 1L);
    verify(eventDao).insertUpdateEvent(ISSUE, 1L);
    verify(eventDao).insertUpdateEvent(ISSUE, 2L);
    verifyNoMoreInteractions(eventDao);
}
Also used : SecuredEntityManager(com.epam.pipeline.manager.security.SecuredEntityManager) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

S3bucketDataStorage (com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage)14 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)7 Test (org.junit.Test)7 Folder (com.epam.pipeline.entity.pipeline.Folder)3 SecuredEntityManager (com.epam.pipeline.manager.security.SecuredEntityManager)3 Transactional (org.springframework.transaction.annotation.Transactional)3 StoragePolicy (com.epam.pipeline.entity.datastorage.StoragePolicy)2 NFSDataStorage (com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage)2 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)2 AclClass (com.epam.pipeline.entity.security.acl.AclClass)2 MessageConstants (com.epam.pipeline.common.MessageConstants)1 MessageHelper (com.epam.pipeline.common.MessageHelper)1 DataStorageVO (com.epam.pipeline.controller.vo.DataStorageVO)1 EntityVO (com.epam.pipeline.controller.vo.EntityVO)1 UpdateDataStorageItemVO (com.epam.pipeline.controller.vo.data.storage.UpdateDataStorageItemVO)1 DataStorageDao (com.epam.pipeline.dao.datastorage.DataStorageDao)1 AbstractSecuredEntity (com.epam.pipeline.entity.AbstractSecuredEntity)1 BaseEntity (com.epam.pipeline.entity.BaseEntity)1 RunConfiguration (com.epam.pipeline.entity.configuration.RunConfiguration)1 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)1