use of com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto in project cloudbreak by hortonworks.
the class ChangeImageCatalogTest method testChangeDataHubImageCatalog.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running DataHub and image catalogs created by ENV_CREATOR_A", when = "a change image catalog request is sent to use an image catalog created by ENV_CREATOR_A", then = "ENV_CREATOR_A, ACCOUNT_ADMIN and ENV_CREATOR_B with shared resource user and environment admin rights can perform the operation")
public void testChangeDataHubImageCatalog(MockedTestContext testContext) {
useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_A);
createDefaultImageCatalog(testContext);
ImageCatalogTestDto imageCatalog1 = resourceCreator.createNewImageCatalog(testContext);
ImageCatalogTestDto imageCatalog2 = resourceCreator.createNewImageCatalog(testContext);
ImageCatalogTestDto imageCatalog3 = resourceCreator.createNewImageCatalog(testContext);
// ENV_CREATOR_A can change DH image catalog in case of DH and target image catalog are created by ENV_CREATOR_A
testContext.given(CredentialTestDto.class).when(credentialTestClient.create()).given(EnvironmentTestDto.class).when(environmentTestClient.create()).await(EnvironmentStatus.AVAILABLE).given(FreeIpaTestDto.class).when(freeIpaTestClient.create()).await(Status.AVAILABLE).given(SdxInternalTestDto.class).when(sdxTestClient.createInternal()).await(SdxClusterStatusResponse.RUNNING).when(sdxTestClient.detailedDescribeInternal()).given(DistroXTestDto.class).when(distroXClient.create()).await(STACK_AVAILABLE, RunningParameter.who(cloudbreakActor.useRealUmsUser(AuthUserKeys.ACCOUNT_ADMIN))).given(DistroXChangeImageCatalogTestDto.class).withImageCatalog(imageCatalog1.getName()).when(distroXClient.changeImageCatalog()).validate();
// ENV_CREATOR_B can change DH image catalog in case of DH and target image catalog are created by ENV_CREATOR_A and
// ENV_CREATOR_B has environment admin right in terms of the environment created by ENV_CREATOR_A and
// ENV_CREATOR_B has shared resource right in terms of the image catalog created by ENV_CREATOR_A
useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_B);
testContext.given(UmsTestDto.class).assignTarget(imageCatalog2.getName()).withSharedResourceUser().when(umsTestClient.assignResourceRole(AuthUserKeys.ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).given(UmsTestDto.class).assignTarget(EnvironmentTestDto.class.getSimpleName()).withEnvironmentAdmin().when(umsTestClient.assignResourceRole(AuthUserKeys.ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).given(DistroXChangeImageCatalogTestDto.class).withImageCatalog(imageCatalog2.getName()).when(distroXClient.changeImageCatalog()).validate();
// ACCOUNT_ADMIN can change DH image catalog in case of DH and target image catalog are created by ENV_CREATOR_A
useRealUmsUser(testContext, AuthUserKeys.ACCOUNT_ADMIN);
testContext.given(DistroXChangeImageCatalogTestDto.class).withImageCatalog(imageCatalog3.getName()).when(distroXClient.changeImageCatalog()).validate();
}
Aggregations