Search in sources :

Example 6 with CredentialRequest

use of com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest in project cloudbreak by hortonworks.

the class AuditCredentialAuthorizationIntegrationTest method getAwsCredentialRequest.

private CredentialRequest getAwsCredentialRequest(String name) {
    CredentialRequest credentialRequest = new CredentialRequest();
    credentialRequest.setAws(getAwsKeyBasedCredentialParameters());
    credentialRequest.setCloudPlatform("AWS");
    credentialRequest.setName(name);
    return credentialRequest;
}
Also used : CredentialRequest(com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest)

Example 7 with CredentialRequest

use of com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest in project cloudbreak by hortonworks.

the class CredentialAuthorizationIntegrationTest method getAwsEditCredentialRequest.

private EditCredentialRequest getAwsEditCredentialRequest(String name) {
    EditCredentialRequest credentialRequest = new EditCredentialRequest();
    credentialRequest.setAws(getAwsKeyBasedCredentialParameters());
    credentialRequest.setCloudPlatform("AWS");
    credentialRequest.setName(name);
    return credentialRequest;
}
Also used : EditCredentialRequest(com.sequenceiq.environment.api.v1.credential.model.request.EditCredentialRequest)

Example 8 with CredentialRequest

use of com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest in project cloudbreak by hortonworks.

the class CredentialAuthorizationIntegrationTest method getAwsCredentialRequest.

private CredentialRequest getAwsCredentialRequest(String name) {
    CredentialRequest credentialRequest = new CredentialRequest();
    credentialRequest.setAws(getAwsKeyBasedCredentialParameters());
    credentialRequest.setCloudPlatform("AWS");
    credentialRequest.setName(name);
    return credentialRequest;
}
Also used : EditCredentialRequest(com.sequenceiq.environment.api.v1.credential.model.request.EditCredentialRequest) CredentialRequest(com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest)

Example 9 with CredentialRequest

use of com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest in project cloudbreak by hortonworks.

the class EnvironmentServiceIntegrationTest method testCredentialInteractiveLogin.

@Test
public void testCredentialInteractiveLogin() throws InterruptedException {
    credentialRequest.setName("testcredential");
    credentialRequest.setCloudPlatform("AZURE");
    AzureCredentialRequestParameters azureCredentialRequestParameters = new AzureCredentialRequestParameters();
    azureCredentialRequestParameters.setSubscriptionId("subid");
    azureCredentialRequestParameters.setTenantId("tenant");
    RoleBasedRequest roleBasedRequest = new RoleBasedRequest();
    roleBasedRequest.setDeploymentAddress("alma");
    roleBasedRequest.setRoleName("role");
    azureCredentialRequestParameters.setRoleBased(roleBasedRequest);
    credentialRequest.setAzure(azureCredentialRequestParameters);
    InteractiveLoginResult interactiveLoginResult = new InteractiveLoginResult(1L, Map.of("user_code", USER_CODE, "verification_url", VERIFICATION_URL));
    when(requestProvider.getInteractiveLoginRequest(any(), any())).thenReturn(interactiveLoginRequest);
    when(interactiveLoginRequest.await()).thenReturn(interactiveLoginResult);
    InteractiveCredentialResponse result = client.credentialV1Endpoint().interactiveLogin(credentialRequest);
    assertEquals(result.getUserCode(), USER_CODE);
    assertEquals(result.getVerificationUrl(), VERIFICATION_URL);
}
Also used : InteractiveLoginResult(com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginResult) AzureCredentialRequestParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.azure.AzureCredentialRequestParameters) InteractiveCredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.InteractiveCredentialResponse) RoleBasedRequest(com.sequenceiq.environment.api.v1.credential.model.parameters.azure.RoleBasedRequest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with CredentialRequest

use of com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest in project cloudbreak by hortonworks.

the class EnvironmentServiceIntegrationTest method testCredentialCreateAws.

@Test
public void testCredentialCreateAws() throws InterruptedException {
    credentialRequest.setAws(getAwsKeyBasedCredentialParameters(false, "yyy", "zzzz"));
    credentialRequest.setCloudPlatform("AWS");
    credentialRequest.setName("testcredential");
    when(requestProvider.getResourceDefinitionRequest(any(), any())).thenReturn(resourceDefinitionRequest);
    when(requestProvider.getCredentialVerificationRequest(any(), any(), anyBoolean())).thenAnswer(invocation -> new CredentialVerificationMockRequest(invocation.getArgument(0), invocation.getArgument(1)));
    when(resourceDefinitionRequest.await()).thenReturn(new ResourceDefinitionResult(1L, DEFINITION_AWS));
    CredentialResponse response = client.credentialV1Endpoint().post(credentialRequest);
    assertTrue(response.getName().equals(credentialRequest.getName()), " not saved, or response is different");
    assertTrue(credentialRepository.findByNameAndAccountId(credentialRequest.getName(), TEST_ACCOUNT_ID, List.of("AWS"), ENVIRONMENT).isPresent());
}
Also used : CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) InteractiveCredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.InteractiveCredentialResponse) ResourceDefinitionResult(com.sequenceiq.cloudbreak.cloud.event.platform.ResourceDefinitionResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

CredentialRequest (com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest)10 Test (org.junit.jupiter.api.Test)8 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)5 AwsCredentialParameters (com.sequenceiq.environment.api.v1.credential.model.parameters.aws.AwsCredentialParameters)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 EditCredentialRequest (com.sequenceiq.environment.api.v1.credential.model.request.EditCredentialRequest)4 InteractiveCredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.InteractiveCredentialResponse)4 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)3 CheckPermissionByAccount (com.sequenceiq.authorization.annotation.CheckPermissionByAccount)2 InteractiveLoginResult (com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginResult)2 ResourceDefinitionResult (com.sequenceiq.cloudbreak.cloud.event.platform.ResourceDefinitionResult)2 RoleBasedParameters (com.sequenceiq.environment.api.v1.credential.model.parameters.aws.RoleBasedParameters)2 AzureCredentialRequestParameters (com.sequenceiq.environment.api.v1.credential.model.parameters.azure.AzureCredentialRequestParameters)2 RoleBasedRequest (com.sequenceiq.environment.api.v1.credential.model.parameters.azure.RoleBasedRequest)2 CredentialResponses (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponses)2 Credential (com.sequenceiq.environment.credential.domain.Credential)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 RightCheck (com.cloudera.thunderhead.service.authorization.AuthorizationProto.RightCheck)1 Maps (com.google.common.collect.Maps)1 AuthorizationResourceAction (com.sequenceiq.authorization.resource.AuthorizationResourceAction)1