use of com.sequenceiq.it.cloudbreak.context.Description in project cloudbreak by hortonworks.
the class EnvironmentEditTest method authenticationEditWhenSetManagedKeyAndNotDeleteExisted.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running cloudbreak with existed ssh key", when = "change existing ssh key to managed one", then = "delete managed ssh key but not create new one")
public void authenticationEditWhenSetManagedKeyAndNotDeleteExisted(MockedTestContext testContext) {
String randomPublicKeyId = UUID.randomUUID().toString();
testContext.given(EnvironmentAuthenticationTestDto.class).withPublicKeyId(randomPublicKeyId).withPublicKey(null).given(EnvironmentTestDto.class).withCreateFreeIpa(false).when(environmentTestClient.create()).await(EnvironmentStatus.AVAILABLE).given(EnvironmentAuthenticationTestDto.class).withPublicKey(PUBLIC_KEY).withPublicKeyId(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 not be null");
}
return t;
}).validate();
}
use of com.sequenceiq.it.cloudbreak.context.Description in project cloudbreak by hortonworks.
the class AbstractMinimalTest method collectTestCaseDescription.
private TestCaseDescription collectTestCaseDescription(TestContext testContext, Method method, Object[] params) {
Description declaredAnnotation = method.getDeclaredAnnotation(Description.class);
TestCaseDescription testCaseDescription = null;
if (declaredAnnotation != null) {
testCaseDescription = new TestCaseDescriptionBuilder().given(declaredAnnotation.given()).when(declaredAnnotation.when()).then(declaredAnnotation.then());
testContext.addDescription(testCaseDescription);
} else if (method.getParameters().length == params.length) {
Parameter[] parameters = method.getParameters();
for (int i = 1; i < parameters.length; i++) {
if (parameters[i].getAnnotation(Description.class) != null) {
Object param = params[i];
if (!(param instanceof TestCaseDescription)) {
throw new IllegalArgumentException("The param annotated with @Description but the type is should be " + TestCaseDescription.class.getSimpleName());
}
testCaseDescription = (TestCaseDescription) param;
testContext.addDescription(testCaseDescription);
break;
}
}
}
return Optional.ofNullable(testCaseDescription).filter(d -> !Strings.isNullOrEmpty(d.getValue())).orElseThrow(() -> new TestCaseDescriptionMissingException(method.getName()));
}
use of com.sequenceiq.it.cloudbreak.context.Description in project cloudbreak by hortonworks.
the class ChangeImageCatalogTest method testChangeDataLakeImageCatalog.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running DataLake 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 right can perform the operation")
public void testChangeDataLakeImageCatalog(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 DL image catalog in case of DL 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(SdxInternalTestDto.class).when(sdxTestClient.createInternal()).await(SdxClusterStatusResponse.RUNNING).when(sdxTestClient.detailedDescribeInternal()).given(SdxChangeImageCatalogTestDto.class).withImageCatalog(imageCatalog1.getName()).when(sdxTestClient.changeImageCatalog()).validate();
// ACCOUNT_ADMIN can change DL image catalog in case of DL and target image catalog are created by ENV_CREATOR_A
useRealUmsUser(testContext, AuthUserKeys.ACCOUNT_ADMIN);
testContext.given(SdxChangeImageCatalogTestDto.class).withImageCatalog(imageCatalog2.getName()).when(sdxTestClient.changeImageCatalog()).validate();
// ENV_CREATOR_B can change DL image catalog in case of DL 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(EnvironmentTestDto.class.getSimpleName()).withEnvironmentAdmin().when(umsTestClient.assignResourceRole(AuthUserKeys.ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).given(UmsTestDto.class).assignTarget(imageCatalog3.getName()).withSharedResourceUser().when(umsTestClient.assignResourceRole(AuthUserKeys.ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).given(SdxChangeImageCatalogTestDto.class).withImageCatalog(imageCatalog3.getName()).when(sdxTestClient.changeImageCatalog()).validate();
}
use of com.sequenceiq.it.cloudbreak.context.Description 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();
}
use of com.sequenceiq.it.cloudbreak.context.Description in project cloudbreak by hortonworks.
the class CreateDhWithDatahubCreator method testCreateEnvironmentWithDh.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running env service", when = "valid create environment request is sent and then datahub is created", then = "environment should be created but unauthorized users should not be able to access it")
public void testCreateEnvironmentWithDh(TestContext testContext) {
useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_A);
testContext.given(CredentialTestDto.class).when(credentialTestClient.create()).given(EnvironmentTestDto.class).withCreateFreeIpa(false).when(environmentTestClient.create()).await(EnvironmentStatus.AVAILABLE).whenException(environmentTestClient.describe(), ForbiddenException.class, expectedMessage("Doesn't have 'environments/describeEnvironment' right on environment " + environmentPattern(testContext)).withWho(cloudbreakActor.useRealUmsUser(AuthUserKeys.ENV_CREATOR_B))).whenException(environmentTestClient.describe(), ForbiddenException.class, expectedMessage("Doesn't have 'environments/describeEnvironment' right on environment " + environmentPattern(testContext)).withWho(cloudbreakActor.useRealUmsUser(AuthUserKeys.ZERO_RIGHTS))).validate();
useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_A);
EnvironmentTestDto environment = testContext.get(EnvironmentTestDto.class);
resourceCreator.createNewFreeIpa(testContext, environment);
createDatalake(testContext);
String recipe1Name = testContext.given(RecipeTestDto.class).valid().when(recipeTestClient.createV4(), RunningParameter.who(cloudbreakActor.useRealUmsUser(AuthUserKeys.ACCOUNT_ADMIN))).getResponse().getName();
String recipe2Name = testContext.given(RecipeTestDto.class).valid().when(recipeTestClient.createV4(), RunningParameter.who(cloudbreakActor.useRealUmsUser(AuthUserKeys.ENV_CREATOR_B))).getResponse().getName();
testContext.given(EnvironmentTestDto.class).given(UmsTestDto.class).assignTarget(EnvironmentTestDto.class.getSimpleName()).withDatahubCreator().when(umsTestClient.assignResourceRole(AuthUserKeys.ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).withEnvironmentUser().when(umsTestClient.assignResourceRole(AuthUserKeys.ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).given(EnvironmentTestDto.class).given(DistroXTestDto.class).withRecipe(recipe1Name).whenException(distroXClient.create(), ForbiddenException.class, expectedMessage("Doesn't have 'environments/useSharedResource' right on" + " recipe " + datahubRecipePattern(recipe1Name)).withWho(cloudbreakActor.useRealUmsUser(AuthUserKeys.ENV_CREATOR_B))).withRecipe(recipe2Name).when(distroXClient.create(), RunningParameter.who(cloudbreakActor.useRealUmsUser(AuthUserKeys.ENV_CREATOR_B))).await(STACK_AVAILABLE, RunningParameter.who(cloudbreakActor.useRealUmsUser(AuthUserKeys.ACCOUNT_ADMIN))).given(RenewDistroXCertificateTestDto.class).whenException(distroXClient.renewDistroXCertificateV4(), ForbiddenException.class, expectedMessage("Doesn't have 'datahub/repairDatahub'" + " right on any of the " + environmentDatahubPattern(testContext) + " or on " + datahubPattern(testContext)).withWho(cloudbreakActor.useRealUmsUser(AuthUserKeys.ZERO_RIGHTS))).validate();
testCheckRightUtil(testContext, testContext.given(DistroXTestDto.class).getCrn());
}
Aggregations