Search in sources :

Example 11 with RepoConfigValidationV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.RepoConfigValidationV4Response in project cloudbreak by hortonworks.

the class RepositoryConfigValidationServiceTest method testValidateForRequestsWithNullValuedFields.

@Test
public void testValidateForRequestsWithNullValuedFields() {
    RepoConfigValidationV4Request request = new RepoConfigValidationV4Request();
    RepoConfigValidationV4Response result = underTest.validate(request);
    assertNull(result.getAmbariBaseUrl());
    assertNull(result.getAmbariGpgKeyUrl());
    assertNull(result.getVersionDefinitionFileUrl());
    assertNull(result.getMpackUrl());
    assertNull(result.getStackBaseURL());
    assertNull(result.getUtilsBaseURL());
}
Also used : 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 RepoConfigValidationV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.RepoConfigValidationV4Response 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 13 with RepoConfigValidationV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.RepoConfigValidationV4Response 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 14 with RepoConfigValidationV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.RepoConfigValidationV4Response 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)

Aggregations

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