use of com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto in project cloudbreak by hortonworks.
the class AbstractIntegrationTest method validateBaseImage.
protected void validateBaseImage(TestContext testContext, String imageUuid) {
testContext.given(ImageCatalogTestDto.class).when(imageCatalogTestClient.getV4(true)).valid();
ImageCatalogTestDto dto = testContext.get(ImageCatalogTestDto.class);
dto.getResponse().getImages().getBaseImages().stream().filter(img -> img.getUuid().equalsIgnoreCase(imageUuid)).findFirst().orElseThrow(() -> new RuntimeException(imageUuid + " base image is missing from the '" + dto.getName() + "' catalog."));
}
use of com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto in project cloudbreak by hortonworks.
the class AbstractIntegrationTest method validatePrewarmedImage.
protected void validatePrewarmedImage(TestContext testContext, String imageUuid) {
testContext.given(ImageCatalogTestDto.class).when(imageCatalogTestClient.getV4(true)).valid();
ImageCatalogTestDto dto = testContext.get(ImageCatalogTestDto.class);
dto.getResponse().getImages().getCdhImages().stream().filter(img -> img.getUuid().equalsIgnoreCase(imageUuid)).findFirst().orElseThrow(() -> new RuntimeException(imageUuid + " prewarmed image is missing from the '" + dto.getName() + "' catalog."));
}
use of com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto in project cloudbreak by hortonworks.
the class ChangeImageCatalogTest method testChangeDataLakeImageCatalogFails.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running DataLake created by ENV_CREATOR_A and image catalogs created by ENV_CREATOR_A and ENV_CREATOR_B", when = "a change image catalog request is sent", then = "ENV_CREATOR_B should get forbidden excepion by using any image catalog")
public void testChangeDataLakeImageCatalogFails(MockedTestContext testContext) {
useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_A);
createDefaultImageCatalog(testContext);
testContext.given(CredentialTestDto.class).when(credentialTestClient.create()).given(EnvironmentTestDto.class).when(environmentTestClient.create()).await(EnvironmentStatus.AVAILABLE).given(SdxInternalTestDto.class).when(sdxTestClient.createInternal()).await(SdxClusterStatusResponse.RUNNING).when(sdxTestClient.detailedDescribeInternal()).validate();
ImageCatalogTestDto imageCatalogA = resourceCreator.createNewImageCatalog(testContext);
useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_B);
ImageCatalogTestDto imageCatalogB = resourceCreator.createNewImageCatalog(testContext);
// ENV_CREATOR_B can't change DL image catalog in case of DL is created by ENV_CREATOR_A
testContext.given(SdxChangeImageCatalogTestDto.class).withImageCatalog(imageCatalogB.getName()).whenException(sdxTestClient.changeImageCatalog(), ForbiddenException.class, expectedMessage("Doesn't have 'datalake/changeImageCatalog' right on any of the environment[(]s[)] " + environmentDatalakePattern(testContext) + " or on .*")).validate();
// ENV_CREATOR_B can't change ENV_CREATOR_A's DH image catalog in case of having environment admin right but the catalog is created by ENV_CREATOR_A
testContext.given(UmsTestDto.class).assignTarget(EnvironmentTestDto.class.getSimpleName()).withEnvironmentAdmin().when(umsTestClient.assignResourceRole(AuthUserKeys.ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).given(SdxChangeImageCatalogTestDto.class).withImageCatalog(imageCatalogA.getName()).whenException(sdxTestClient.changeImageCatalog(), ForbiddenException.class, expectedMessage("Doesn't have 'environments/useSharedResource' right on imageCatalog .*")).validate();
}
use of com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto in project cloudbreak by hortonworks.
the class ChangeImageCatalogTest method testChangeDataHubImageCatalogFails.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running DataHub created by ENV_CREATOR_A and image catalogs created by ENV_CREATOR_A and ENV_CREATOR_B", when = "a change image catalog request is sent", then = "ENV_CREATOR_B should get forbidden excepion by using any image catalog")
public void testChangeDataHubImageCatalogFails(MockedTestContext testContext) {
useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_A);
createDefaultImageCatalog(testContext);
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))).validate();
ImageCatalogTestDto imageCatalogA = resourceCreator.createNewImageCatalog(testContext);
useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_B);
ImageCatalogTestDto imageCatalogB = resourceCreator.createNewImageCatalog(testContext);
// ENV_CREATOR_B can't change DH image catalog in case of DH is created by ENV_CREATOR_A
testContext.given(DistroXChangeImageCatalogTestDto.class).withImageCatalog(imageCatalogB.getName()).whenException(distroXClient.changeImageCatalog(), ForbiddenException.class, expectedMessage("Doesn't have " + "'datahub/changeImageCatalog' right on any of the environment[(]s[)] " + "[\\[]crn: crn:cdp:environments:us-west-1:.*:environment:.*[]] or on .*")).validate();
// ENV_CREATOR_B can't change ENV_CREATOR_A's DH image catalog in case of having environment admin right but the catalog is created by ENV_CREATOR_A
testContext.given(UmsTestDto.class).assignTarget(EnvironmentTestDto.class.getSimpleName()).withEnvironmentAdmin().when(umsTestClient.assignResourceRole(AuthUserKeys.ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).given(DistroXChangeImageCatalogTestDto.class).withImageCatalog(imageCatalogA.getName()).whenException(distroXClient.changeImageCatalog(), ForbiddenException.class, expectedMessage("Doesn't have 'environments/useSharedResource' right on imageCatalog .*")).validate();
}
use of com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto in project cloudbreak by hortonworks.
the class DistroXUpgradeTests method getUuid.
protected String getUuid(TestContext testContext, String prodCatalogName, String currentRuntimeVersion3rdParty) {
testContext.given(ImageCatalogTestDto.class).withName(prodCatalogName).when(imageCatalogTest.getV4(true));
ImageCatalogTestDto dto = testContext.get(ImageCatalogTestDto.class);
return dto.getResponse().getImages().getCdhImages().stream().filter(img -> img.getVersion().equals(currentRuntimeVersion3rdParty) && img.getImageSetsByProvider().keySet().stream().iterator().next().equals(testContext.commonCloudProperties().getCloudProvider().toLowerCase())).iterator().next().getUuid();
}
Aggregations