use of com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest in project cloudbreak by hortonworks.
the class CredentialValidatorTest method testValidateAwsCredentialRequestNoAwsParams.
@Test
void testValidateAwsCredentialRequestNoAwsParams() {
CredentialRequest request = new CredentialRequest();
request.setCloudPlatform("AWS");
ValidationResult result = underTest.validateAwsCredentialRequest(request);
assertTrue(result.hasError());
assertEquals("Role ARN is not found in credential request.", result.getErrors().get(0));
}
use of com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest in project cloudbreak by hortonworks.
the class CredentialValidatorTest method testValidateAwsCredentialRequestKeyBased.
@Test
void testValidateAwsCredentialRequestKeyBased() {
CredentialRequest request = new CredentialRequest();
request.setCloudPlatform("AWS");
request.setAws(new AwsCredentialParameters());
ValidationResult result = underTest.validateAwsCredentialRequest(request);
assertTrue(result.hasError());
assertEquals("Role ARN is not found in credential request.", result.getErrors().get(0));
}
use of com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest in project cloudbreak by hortonworks.
the class AuditCredentialV1Controller method post.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_AUDIT_CREDENTIAL)
public CredentialResponse post(@Valid CredentialRequest request) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
String creator = ThreadBasedUserCrnProvider.getUserCrn();
Credential credential = credentialConverter.convert(request);
credential.setType(AUDIT);
credential.setVerifyPermissions(false);
notify(ResourceEvent.CREDENTIAL_CREATED);
Set<Credential> auditCredentialsByPlatfom = credentialService.listAvailablesByAccountId(accountId, AUDIT).stream().filter(c -> c.getCloudPlatform().equals(credential.getCloudPlatform())).collect(Collectors.toSet());
if (auditCredentialsByPlatfom.isEmpty()) {
return credentialConverter.convert(credentialService.create(credential, accountId, creator, AUDIT));
} else {
throw new BadRequestException(String.format("Audit credential already exist for %s cloud.", credential.getCloudPlatform()));
}
}
use of com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest in project cloudbreak by hortonworks.
the class CredentialV1Controller method interactiveLogin.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_CREDENTIAL)
public InteractiveCredentialResponse interactiveLogin(@Valid CredentialRequest credentialRequest) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
Credential credential = credentialConverter.convert(credentialRequest);
credential.setType(ENVIRONMENT);
Map<String, String> result = credentialService.interactiveLogin(accountId, credential);
return new InteractiveCredentialResponse(result.get("user_code"), result.get("verification_url"));
}
use of com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest in project cloudbreak by hortonworks.
the class CredentialTestDto method modifyRequest.
public EditCredentialRequest modifyRequest() {
EditCredentialRequest editRequest = new EditCredentialRequest();
CredentialRequest request = getRequest();
editRequest.setName(request.getName());
editRequest.setAzure(request.getAzure());
editRequest.setAws(request.getAws());
editRequest.setGcp(request.getGcp());
editRequest.setMock(request.getMock());
editRequest.setYarn(request.getYarn());
editRequest.setCloudPlatform(request.getName());
editRequest.setDescription(request.getName());
editRequest.setCloudPlatform(getCloudPlatform().name());
return editRequest;
}
Aggregations