use of com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto in project cloudbreak by hortonworks.
the class EnvStopStartWithEnvAdmin method testCreateEnvironmentWithDhAndStopWithEnvAdmin.
@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 testCreateEnvironmentWithDhAndStopWithEnvAdmin(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);
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)).withEnvironmentAdmin().when(umsTestClient.assignResourceRole(AuthUserKeys.ENV_ADMIN_A, regionAwareInternalCrnGeneratorFactory)).given(EnvironmentTestDto.class).given(DistroXTestDto.class).when(distroXClient.create(), RunningParameter.who(cloudbreakActor.useRealUmsUser(AuthUserKeys.ENV_CREATOR_B))).await(STACK_AVAILABLE, RunningParameter.who(cloudbreakActor.useRealUmsUser(AuthUserKeys.ACCOUNT_ADMIN))).given(EnvironmentTestDto.class).when(environmentTestClient.stop(), RunningParameter.who(cloudbreakActor.useRealUmsUser(AuthUserKeys.ENV_ADMIN_A))).await(EnvironmentStatus.ENV_STOPPED, RunningParameter.who(cloudbreakActor.useRealUmsUser(AuthUserKeys.ENV_ADMIN_A))).given(EnvironmentTestDto.class).when(environmentTestClient.start(), RunningParameter.who(cloudbreakActor.useRealUmsUser(AuthUserKeys.ENV_ADMIN_A))).await(EnvironmentStatus.AVAILABLE, RunningParameter.who(cloudbreakActor.useRealUmsUser(AuthUserKeys.ENV_ADMIN_A))).validate();
testCheckRightUtil(testContext, testContext.given(DistroXTestDto.class).getCrn());
}
use of com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto in project cloudbreak by hortonworks.
the class DataHubListFilteringTest method testDataHubListFiltering.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there are datahubs", when = "users share with each other", then = "they see the other's datahub in the list")
public void testDataHubListFiltering(TestContext testContext) {
useRealUmsUser(testContext, AuthUserKeys.USER_ENV_CREATOR_A);
resourceCreator.createDefaultCredential(testContext);
EnvironmentTestDto environment = resourceCreator.createDefaultEnvironment(testContext);
resourceCreator.createNewFreeIpa(testContext, environment);
resourceCreator.createDefaultDataLake(testContext);
DistroXTestDto datahubA = resourceCreator.createDefaultDataHubAndWaitAs(testContext, Optional.of(AuthUserKeys.USER_ACCOUNT_ADMIN));
testContext.given(UmsTestDto.class).assignTarget(EnvironmentTestDto.class.getSimpleName()).withDatahubCreator().when(umsTestClient.assignResourceRole(AuthUserKeys.USER_ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).withEnvironmentUser().when(umsTestClient.assignResourceRole(AuthUserKeys.USER_ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).validate();
assertUserSeesAll(testContext, AuthUserKeys.USER_ENV_CREATOR_A, datahubA.getName());
assertUserSeesAll(testContext, AuthUserKeys.USER_ACCOUNT_ADMIN, datahubA.getName());
assertUserSeesAll(testContext, AuthUserKeys.USER_ENV_CREATOR_B, datahubA.getName());
useRealUmsUser(testContext, AuthUserKeys.USER_ENV_CREATOR_B);
DistroXTestDto dataHubB = resourceCreator.createNewDataHubAndWaitAs(testContext, Optional.of(AuthUserKeys.USER_ACCOUNT_ADMIN));
assertUserSeesAll(testContext, AuthUserKeys.USER_ENV_CREATOR_A, datahubA.getName(), dataHubB.getName());
assertUserSeesAll(testContext, AuthUserKeys.USER_ACCOUNT_ADMIN, datahubA.getName(), dataHubB.getName());
assertUserSeesAll(testContext, AuthUserKeys.USER_ENV_CREATOR_B, datahubA.getName(), dataHubB.getName());
testContext.given(UmsTestDto.class).assignTarget(DistroXTestDto.class.getSimpleName()).withDatahubAdmin().when(umsTestClient.assignResourceRole(AuthUserKeys.USER_ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).validate();
assertUserSeesAll(testContext, AuthUserKeys.USER_ENV_CREATOR_A, datahubA.getName(), dataHubB.getName());
assertUserSeesAll(testContext, AuthUserKeys.USER_ACCOUNT_ADMIN, datahubA.getName(), dataHubB.getName());
assertUserSeesAll(testContext, AuthUserKeys.USER_ENV_CREATOR_B, datahubA.getName(), dataHubB.getName());
useRealUmsUser(testContext, AuthUserKeys.USER_ACCOUNT_ADMIN);
}
use of com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto in project cloudbreak by hortonworks.
the class FreeIpaListFilteringTest method testFreeIpaListFiltering.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there are freeipas", when = "users share with each other", then = "they see the other's freeipa in the list")
public void testFreeIpaListFiltering(TestContext testContext) {
useRealUmsUser(testContext, AuthUserKeys.USER_ENV_CREATOR_A);
resourceCreator.createDefaultCredential(testContext);
EnvironmentTestDto environmentA = resourceCreator.createDefaultEnvironment(testContext);
resourceCreator.createDefaultFreeIpa(testContext);
useRealUmsUser(testContext, AuthUserKeys.USER_ENV_CREATOR_B);
CredentialTestDto credential = resourceCreator.createNewCredential(testContext);
EnvironmentTestDto environmentB = resourceCreator.createNewEnvironment(testContext, credential);
resourceCreator.createNewFreeIpa(testContext, environmentB);
assertUserSeesAll(testContext, AuthUserKeys.USER_ENV_CREATOR_A, environmentA.getCrn());
assertUserSeesAll(testContext, AuthUserKeys.USER_ENV_CREATOR_B, environmentB.getCrn());
assertUserSeesAll(testContext, AuthUserKeys.USER_ACCOUNT_ADMIN, environmentA.getCrn(), environmentB.getCrn());
assertUserDoesNotSeeAnyOf(testContext, AuthUserKeys.USER_ENV_CREATOR_A, environmentB.getCrn());
assertUserDoesNotSeeAnyOf(testContext, AuthUserKeys.USER_ENV_CREATOR_B, environmentA.getCrn());
testContext.given(UmsTestDto.class).assignTarget(EnvironmentTestDto.class.getSimpleName()).withEnvironmentAdmin().when(umsTestClient.assignResourceRole(AuthUserKeys.USER_ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).validate();
testContext.given(UmsTestDto.class).assignTarget(environmentB.getName()).withEnvironmentUser().when(umsTestClient.assignResourceRole(AuthUserKeys.USER_ENV_CREATOR_A, regionAwareInternalCrnGeneratorFactory)).validate();
assertUserSeesAll(testContext, AuthUserKeys.USER_ENV_CREATOR_A, environmentA.getCrn(), environmentB.getCrn());
assertUserSeesAll(testContext, AuthUserKeys.USER_ENV_CREATOR_B, environmentA.getCrn(), environmentB.getCrn());
assertUserSeesAll(testContext, AuthUserKeys.USER_ACCOUNT_ADMIN, environmentA.getCrn(), environmentB.getCrn());
useRealUmsUser(testContext, AuthUserKeys.USER_ACCOUNT_ADMIN);
}
use of com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto in project cloudbreak by hortonworks.
the class DistroXClusterCreationTest method testWhenEnvIsStoppedUnableToCreateDistroX.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "a stopped environment", when = "a DistroX creation request sent", then = "its creation should not be started due to the unavailability of the environment")
public void testWhenEnvIsStoppedUnableToCreateDistroX(MockedTestContext testContext) {
EnvironmentTestDto environment = testContext.get(EnvironmentTestDto.class);
givenAnEnvironmentInStoppedState(testContext).given(DIX_NET_KEY, DistroXNetworkTestDto.class).given(DIX_IMG_KEY, DistroXImageTestDto.class).withImageCatalog().withImageId(IMAGE_CATALOG_ID).given(CM_FOR_DISTRO_X, DistroXClouderaManagerTestDto.class).given(CLUSTER_KEY, DistroXClusterTestDto.class).withBlueprintName(getBlueprintName(testContext)).withValidateBlueprint(false).withClouderaManager(CM_FOR_DISTRO_X).given(DistroXTestDto.class).withCluster(CLUSTER_KEY).withImageSettings(DIX_IMG_KEY).withNetwork(DIX_NET_KEY).whenException(distroXClient.create(), BadRequestException.class, expectedMessage(String.format("If you want to provision a Data Hub then the FreeIPA instance must be running in the '%s' Environment.", environment.getName()))).validate();
}
use of com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto in project cloudbreak by hortonworks.
the class DistroXTestDto method valid.
@Override
public DistroXTestDtoBase<DistroXTestDto> valid() {
DistroXTestDtoBase<DistroXTestDto> valid = super.valid();
EnvironmentTestDto environmentTestDto = getTestContext().get(EnvironmentTestDto.class);
if (environmentTestDto != null && environmentTestDto.getResponse() != null) {
valid.withEnvironmentName(environmentTestDto.getName());
}
return valid;
}
Aggregations