use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class ImageCatalogTest method testGetImageCatalogWhenCatalogDoesNotContainTheRequestedProvider.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "image catalog get the default catalog with AWS provider but catalog does not contain AWS entry", when = "calling get on the default", then = "the response does not contains AWS images")
public void testGetImageCatalogWhenCatalogDoesNotContainTheRequestedProvider(MockedTestContext testContext) {
String imgCatalogName = resourcePropertyProvider().getName();
testContext.given(imgCatalogName, ImageCatalogTestDto.class).withName(imgCatalogName).withUrl(getImageCatalogMockServerSetup().getImageCatalogUrl()).when(imageCatalogTestClient.createV4(), key(imgCatalogName)).when(new ImageCatalogGetImagesByNameAction(CloudPlatform.AWS), key(imgCatalogName)).then((testContext1, entity, cloudbreakClient) -> {
ImagesV4Response catalog = entity.getResponseByProvider();
if (!catalog.getBaseImages().isEmpty()) {
throw new IllegalArgumentException("The Images response should NOT contain results for AWS provider.");
}
return entity;
}).validate();
}
use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class ImageCatalogTest method testGetImageCatalogsRequestFromExistingImageCatalog.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "image catalog get request", when = "calling get request on catalog endpoint", then = "getting back the catalog request")
public void testGetImageCatalogsRequestFromExistingImageCatalog(MockedTestContext testContext) {
String imgCatalogName = resourcePropertyProvider().getName();
testContext.given(imgCatalogName, ImageCatalogTestDto.class).withName(imgCatalogName).withUrl(getImageCatalogMockServerSetup().getImageCatalogUrl()).when(imageCatalogTestClient.createV4(), key(imgCatalogName)).select(ImageCatalogTestDto::getRequest, key(imgCatalogName)).when((testContext1, entity, cloudbreakClient) -> {
ImageCatalogV4Request request = cloudbreakClient.getDefaultClient().imageCatalogV4Endpoint().getRequest(cloudbreakClient.getWorkspaceId(), imgCatalogName);
entity.setRequest(request);
return entity;
}).then((testContext1, entity, cloudbreakClient) -> {
ImageCatalogV4Request imgCatReq = testContext1.getSelected(imgCatalogName);
if (entity.getRequest().equals(imgCatReq)) {
throw new IllegalArgumentException("The requests are not identical.");
}
return entity;
}).validate();
}
use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class ImageCatalogTest method testUpdateImageCatalog.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "image catalog update request", when = "calling update request with new url", then = "the image catalog list should contains the new url")
public void testUpdateImageCatalog(MockedTestContext testContext) {
String imgCatalogName = resourcePropertyProvider().getName();
testContext.given(imgCatalogName, ImageCatalogTestDto.class).withName(imgCatalogName).withUrl(getImageCatalogMockServerSetup().getImageCatalogUrl()).when(imageCatalogTestClient.createV4(), key(imgCatalogName)).select(ImageCatalogTestDto::getResponse, key(imgCatalogName)).when((testContext1, entity, cloudbreakClient) -> {
ImageCatalogV4Response originalResponse = entity.getResponse();
UpdateImageCatalogV4Request updateRequest = new UpdateImageCatalogV4Request();
updateRequest.setCrn(originalResponse.getCrn());
updateRequest.setName(originalResponse.getName());
updateRequest.setUrl(IMG_CATALOG_URL);
ImageCatalogV4Response updateResponse = cloudbreakClient.getDefaultClient().imageCatalogV4Endpoint().update(cloudbreakClient.getWorkspaceId(), updateRequest);
entity.setResponse(updateResponse);
return entity;
}, key(imgCatalogName)).then((testContext1, entity, cloudbreakClient) -> {
ImageCatalogV4Response originalRepsonse = testContext1.getSelected(imgCatalogName);
if (originalRepsonse.getUrl().equals(entity.getResponse().getUrl())) {
throw new IllegalArgumentException("The catalog URL should not be the same after update.");
}
return entity;
}, key(imgCatalogName)).validate();
}
use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class UsedImagesTest method verifyImagesAreUsed.
private <T extends CloudbreakTestDto> T verifyImagesAreUsed(TestContext testContext, T testDto) {
testContext.given(UsedImagesTestDto.class).when(utilTestClient.usedImages()).then((tc, usedImagesTestDto, client) -> {
List<UsedImageStacksV4Response> usedImages = usedImagesTestDto.getResponse().getUsedImages();
UsedImageStacksV4Response usedImageStacksV4Response = usedImages.stream().filter(usedImage -> usedImage.getImage().getImageId().contains(sdxImageUuid)).findFirst().orElseThrow(() -> new TestFailException(String.format("SDX image is NOT in use with ID:: %s", sdxImageUuid)));
LOGGER.info("Used SDX image ID:: {}", usedImageStacksV4Response.getImage().getImageId());
return usedImagesTestDto;
}).given(FreeipaUsedImagesTestDto.class).when(freeIpaTestClient.usedImages()).then((tc, usedImagesTestDto, client) -> {
List<UsedImageStacksV1Response> usedImages = usedImagesTestDto.getResponse().getUsedImages();
UsedImageStacksV1Response usedImageStacksV1Response = usedImages.stream().filter(usedImage -> usedImage.getImage().getImageId().contains(freeipaImageUuid)).findFirst().orElseThrow(() -> new TestFailException(String.format("FreeIpa image is NOT in use with ID:: %s", freeipaImageUuid)));
LOGGER.info("Used FreeIpa image ID:: {}", usedImageStacksV1Response.getImage().getImageId());
return usedImagesTestDto;
}).validate();
return testDto;
}
use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class EnvironmentEditTest method authenticationEditWhenSetExistingKeyAndDeleteManagedSuccessfully.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running cloudbreak managed ssh key", when = "change managed ssh key to existing one", then = "delete managed ssh key but not create new one")
public void authenticationEditWhenSetExistingKeyAndDeleteManagedSuccessfully(MockedTestContext testContext) {
String randomPublicKeyId = UUID.randomUUID().toString();
testContext.given(HttpMock.class).mockSpi().getPublicKey().get().pathVariable("publicKeyId", randomPublicKeyId).thenReturn(Map.of("publicKeyId", randomPublicKeyId, "publicKey", "asd")).given(EnvironmentTestDto.class).withCreateFreeIpa(false).when(environmentTestClient.create()).await(EnvironmentStatus.AVAILABLE).given(EnvironmentAuthenticationTestDto.class).withPublicKeyId(randomPublicKeyId).withPublicKey(null).given(EnvironmentTestDto.class).when(environmentTestClient.changeAuthentication()).when(environmentTestClient.describe()).then((tc, t, c) -> {
String publicKeyId = t.getResponse().getAuthentication().getPublicKeyId();
String publicKey = t.getResponse().getAuthentication().getPublicKey();
if (!randomPublicKeyId.equals(publicKeyId)) {
throw new TestFailException("The auth public key id was not changed, but it should be changed");
}
if (publicKey != null) {
throw new TestFailException("The auth public key should be null");
}
return t;
}).validate();
}
Aggregations