Search in sources :

Example 1 with EnvironmentTestDto

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());
}
Also used : EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) ForbiddenException(javax.ws.rs.ForbiddenException) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test) AbstractIntegrationTest(com.sequenceiq.it.cloudbreak.testcase.AbstractIntegrationTest)

Example 2 with EnvironmentTestDto

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);
}
Also used : EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test) AbstractIntegrationTest(com.sequenceiq.it.cloudbreak.testcase.AbstractIntegrationTest)

Example 3 with EnvironmentTestDto

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);
}
Also used : EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) CredentialTestDto(com.sequenceiq.it.cloudbreak.dto.credential.CredentialTestDto) Description(com.sequenceiq.it.cloudbreak.context.Description) AbstractMockTest(com.sequenceiq.it.cloudbreak.testcase.mock.AbstractMockTest) Test(org.testng.annotations.Test)

Example 4 with EnvironmentTestDto

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();
}
Also used : EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) DistroXImageTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.image.DistroXImageTestDto) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) BadRequestException(javax.ws.rs.BadRequestException) DistroXClusterTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.cluster.DistroXClusterTestDto) Description(com.sequenceiq.it.cloudbreak.context.Description) AbstractClouderaManagerTest(com.sequenceiq.it.cloudbreak.testcase.mock.clouderamanager.AbstractClouderaManagerTest) Test(org.testng.annotations.Test)

Example 5 with EnvironmentTestDto

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;
}
Also used : EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto)

Aggregations

EnvironmentTestDto (com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto)9 Description (com.sequenceiq.it.cloudbreak.context.Description)7 Test (org.testng.annotations.Test)7 AbstractIntegrationTest (com.sequenceiq.it.cloudbreak.testcase.AbstractIntegrationTest)5 CredentialTestDto (com.sequenceiq.it.cloudbreak.dto.credential.CredentialTestDto)3 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)3 ForbiddenException (javax.ws.rs.ForbiddenException)2 SecurityAccessRequest (com.sequenceiq.environment.api.v1.environment.model.request.SecurityAccessRequest)1 DistroXClusterTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.cluster.DistroXClusterTestDto)1 DistroXImageTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.image.DistroXImageTestDto)1 SdxInternalTestDto (com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto)1 UmsTestDto (com.sequenceiq.it.cloudbreak.dto.ums.UmsTestDto)1 AbstractMockTest (com.sequenceiq.it.cloudbreak.testcase.mock.AbstractMockTest)1 AbstractClouderaManagerTest (com.sequenceiq.it.cloudbreak.testcase.mock.clouderamanager.AbstractClouderaManagerTest)1 BadRequestException (javax.ws.rs.BadRequestException)1