Search in sources :

Example 11 with RepoConfigValidationV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.requests.RepoConfigValidationV4Request in project cloudbreak by hortonworks.

the class RepositoryConfigValidationServiceTest method testValidateForAmbariBaseUrlWhenTheDebRepoIsReachable.

@Test
public void testValidateForAmbariBaseUrlWhenTheDebRepoIsReachable() {
    String ambariBaseUrl = "http://s3.amazonaws.com/dev.hortonworks.com/ambari/ubuntu14/2.x/BUILDS/2.6.1.0-143";
    RepoConfigValidationV4Request request = new RepoConfigValidationV4Request();
    request.setAmbariBaseUrl(ambariBaseUrl);
    String rpmRepoDataTarget = ambariBaseUrl + RPM_REPO_REPODATA_PATH;
    String debRepoDataTarget = ambariBaseUrl + "/dists/Ambari/InRelease";
    when(urlAccessValidationService.isAccessible(rpmRepoDataTarget)).thenReturn(false);
    when(urlAccessValidationService.isAccessible(debRepoDataTarget)).thenReturn(true);
    RepoConfigValidationV4Response result = underTest.validate(request);
    ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
    verify(urlAccessValidationService, times(2)).isAccessible(argumentCaptor.capture());
    List<String> arguments = argumentCaptor.getAllValues();
    assertTrue(arguments.contains(rpmRepoDataTarget));
    assertTrue(arguments.contains(debRepoDataTarget));
    assertTrue(result.getAmbariBaseUrl());
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RepoConfigValidationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.RepoConfigValidationV4Response) RepoConfigValidationV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.util.requests.RepoConfigValidationV4Request) Test(org.junit.Test)

Example 12 with RepoConfigValidationV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.requests.RepoConfigValidationV4Request in project cloudbreak by hortonworks.

the class RepositoryConfigValidationServiceTest method testValidateForStackUtilsBaseUrlWhenNoRepoIsAvailable.

@Test
public void testValidateForStackUtilsBaseUrlWhenNoRepoIsAvailable() {
    String utilsBaseUrl = "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/sles12";
    String rpmRepoDataTarget = utilsBaseUrl + RPM_REPO_REPODATA_PATH;
    String debRepoDataTarget = utilsBaseUrl + "/dists/HDP-UTILS/InRelease";
    RepoConfigValidationV4Request request = new RepoConfigValidationV4Request();
    request.setUtilsBaseURL(utilsBaseUrl);
    when(urlAccessValidationService.isAccessible(rpmRepoDataTarget)).thenReturn(false);
    when(urlAccessValidationService.isAccessible(debRepoDataTarget)).thenReturn(false);
    RepoConfigValidationV4Response result = underTest.validate(request);
    ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
    verify(urlAccessValidationService, times(2)).isAccessible(argumentCaptor.capture());
    List<String> arguments = argumentCaptor.getAllValues();
    assertTrue(arguments.contains(rpmRepoDataTarget));
    assertTrue(arguments.contains(debRepoDataTarget));
    assertFalse(result.getUtilsBaseURL());
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RepoConfigValidationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.RepoConfigValidationV4Response) RepoConfigValidationV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.util.requests.RepoConfigValidationV4Request) Test(org.junit.Test)

Example 13 with RepoConfigValidationV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.requests.RepoConfigValidationV4Request in project cloudbreak by hortonworks.

the class RepositoryConfigValidationService method validate.

public RepoConfigValidationV4Response validate(RepoConfigValidationV4Request request) {
    RepoConfigValidationV4Response result = new RepoConfigValidationV4Response();
    if (request != null) {
        String ambariBaseUrl = request.getAmbariBaseUrl();
        if (isNotEmpty(ambariBaseUrl)) {
            result.setAmbariBaseUrl(repoUrlAvailable(ambariBaseUrl, "Ambari"));
        }
        String ambariGpgKeyUrl = request.getAmbariGpgKeyUrl();
        if (isNotEmpty(ambariGpgKeyUrl)) {
            result.setAmbariGpgKeyUrl(isAccessible(ambariGpgKeyUrl, null));
        }
        String stackBaseURL = request.getStackBaseURL();
        if (isNotEmpty(stackBaseURL)) {
            result.setStackBaseURL(repoUrlAvailable(stackBaseURL, "HDP"));
        }
        String utilsBaseURL = request.getUtilsBaseURL();
        if (isNotEmpty(utilsBaseURL)) {
            result.setUtilsBaseURL(repoUrlAvailable(utilsBaseURL, "HDP-UTILS"));
        }
        String versionDefinitionFileUrl = request.getVersionDefinitionFileUrl();
        if (isNotEmpty(versionDefinitionFileUrl)) {
            result.setVersionDefinitionFileUrl(isAccessible(versionDefinitionFileUrl, null));
        }
        String mpackUrl = request.getMpackUrl();
        if (isNotEmpty(mpackUrl)) {
            result.setMpackUrl(isAccessible(mpackUrl, null));
        }
    }
    return result;
}
Also used : RepoConfigValidationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.RepoConfigValidationV4Response)

Example 14 with RepoConfigValidationV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.requests.RepoConfigValidationV4Request in project cloudbreak by hortonworks.

the class RepositoryConfigsTests method createRepoConfigValidationReqest.

private RepoConfigValidationV4Request createRepoConfigValidationReqest(String ambariBaseUrl, String ambariGpgKeyUrl, String mPackUrl, String stackBaseUrl, String utilsBaseUrl, String versionDefinitionFileUrl) {
    RepoConfigValidationV4Request repoConfigValidationV4Request = new RepoConfigValidationV4Request();
    repoConfigValidationV4Request.setAmbariBaseUrl(ambariBaseUrl);
    repoConfigValidationV4Request.setAmbariGpgKeyUrl(ambariGpgKeyUrl);
    repoConfigValidationV4Request.setMpackUrl(mPackUrl);
    repoConfigValidationV4Request.setStackBaseURL(stackBaseUrl);
    repoConfigValidationV4Request.setUtilsBaseURL(utilsBaseUrl);
    repoConfigValidationV4Request.setVersionDefinitionFileUrl(versionDefinitionFileUrl);
    return repoConfigValidationV4Request;
}
Also used : RepoConfigValidationV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.util.requests.RepoConfigValidationV4Request)

Aggregations

RepoConfigValidationV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.util.requests.RepoConfigValidationV4Request)13 RepoConfigValidationV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.RepoConfigValidationV4Response)13 Test (org.junit.Test)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11