Search in sources :

Example 6 with RepoConfigValidationV4Response

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

the class RepositoryConfigValidationServiceTest method testValidateForStackBaseUrlWhenDebRepoIsReachable.

@Test
public void testValidateForStackBaseUrlWhenDebRepoIsReachable() {
    String stackBaseUrl = "http://public-repo-1.hortonworks.com/HDP/ubuntu14/2.x/updates/2.5.5.0";
    String rpmRepoDataTarget = stackBaseUrl + RPM_REPO_REPODATA_PATH;
    String debRepoDataTarget = stackBaseUrl + "/dists/HDP/InRelease";
    RepoConfigValidationV4Request request = new RepoConfigValidationV4Request();
    request.setStackBaseURL(stackBaseUrl);
    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.getStackBaseURL());
}
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 7 with RepoConfigValidationV4Response

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

the class RepositoryConfigValidationServiceTest method testValidateForStackBaseUrlWhenNoRepoIsAvailable.

@Test
public void testValidateForStackBaseUrlWhenNoRepoIsAvailable() {
    String stackBaseUrl = "http://public-repo-1.hortonworks.com/HDP/ubuntu14/2.x/updates/2.5.5.0";
    RepoConfigValidationV4Request request = new RepoConfigValidationV4Request();
    request.setStackBaseURL(stackBaseUrl);
    when(urlAccessValidationService.isAccessible(anyString())).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();
    String rpmRepoDataTarget = stackBaseUrl + RPM_REPO_REPODATA_PATH;
    String debRepoDataTarget = stackBaseUrl + "/dists/HDP/InRelease";
    assertTrue(arguments.contains(rpmRepoDataTarget));
    assertTrue(arguments.contains(debRepoDataTarget));
    assertFalse(result.getStackBaseURL());
}
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 8 with RepoConfigValidationV4Response

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

the class RepositoryConfigValidationServiceTest method testValidateForAmbariGpgKeyUrlWhenTheUrlIsReachable.

@Test
public void testValidateForAmbariGpgKeyUrlWhenTheUrlIsReachable() {
    String ambariGpgKeyUrl = "http://s3.amazonaws.com/dev.hortonworks.com/ambari/centos6/2.x/BUILDS/2.6.1.0-143/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins";
    RepoConfigValidationV4Request request = new RepoConfigValidationV4Request();
    request.setAmbariGpgKeyUrl(ambariGpgKeyUrl);
    when(urlAccessValidationService.isAccessible(ambariGpgKeyUrl)).thenReturn(true);
    RepoConfigValidationV4Response result = underTest.validate(request);
    verify(urlAccessValidationService, times(1)).isAccessible(ambariGpgKeyUrl);
    assertTrue(result.getAmbariGpgKeyUrl());
}
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 9 with RepoConfigValidationV4Response

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

the class RepositoryConfigValidationServiceTest method testValidateForStackBaseUrlWhenRPMRepoIsReachable.

@Test
public void testValidateForStackBaseUrlWhenRPMRepoIsReachable() {
    String stackBaseUrl = "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.5.5.0";
    RepoConfigValidationV4Request request = new RepoConfigValidationV4Request();
    request.setStackBaseURL(stackBaseUrl);
    String rpmRepoDataTarget = stackBaseUrl + RPM_REPO_REPODATA_PATH;
    when(urlAccessValidationService.isAccessible(rpmRepoDataTarget)).thenReturn(true);
    RepoConfigValidationV4Response result = underTest.validate(request);
    verify(urlAccessValidationService, times(1)).isAccessible(rpmRepoDataTarget);
    assertTrue(result.getStackBaseURL());
}
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 10 with RepoConfigValidationV4Response

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

the class RepositoryConfigValidationServiceTest method testValidateForRequestsIsNull.

@Test
public void testValidateForRequestsIsNull() {
    RepoConfigValidationV4Response result = underTest.validate(null);
    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) Test(org.junit.Test)

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