Search in sources :

Example 1 with RepoConfigValidationV4Request

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

the class RepositoryConfigValidationServiceTest method testValidateForAmbariBaseUrlWhenTheRPMRepoIsReachable.

@Test
public void testValidateForAmbariBaseUrlWhenTheRPMRepoIsReachable() {
    String ambariBaseUrl = "http://s3.amazonaws.com/dev.hortonworks.com/ambari/centos6/2.x/BUILDS/2.6.1.0-143";
    RepoConfigValidationV4Request request = new RepoConfigValidationV4Request();
    request.setAmbariBaseUrl(ambariBaseUrl);
    when(urlAccessValidationService.isAccessible(anyString())).thenReturn(true);
    RepoConfigValidationV4Response result = underTest.validate(request);
    verify(urlAccessValidationService, times(1)).isAccessible(anyString());
    assertTrue(result.getAmbariBaseUrl());
    assertNull(result.getAmbariGpgKeyUrl());
    assertNull(result.getVersionDefinitionFileUrl());
    assertNull(result.getMpackUrl());
    assertNull(result.getStackBaseURL());
    assertNull(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 2 with RepoConfigValidationV4Request

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

the class RepositoryConfigValidationServiceTest method testValidateForAmbariGpgUrlWhenTheUrlIsNotReachable.

@Test
public void testValidateForAmbariGpgUrlWhenTheUrlIsNotReachable() {
    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(false);
    RepoConfigValidationV4Response result = underTest.validate(request);
    verify(urlAccessValidationService, times(1)).isAccessible(ambariGpgKeyUrl);
    assertFalse(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 3 with RepoConfigValidationV4Request

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

the class RepositoryConfigValidationServiceTest method testValidateForAmbariBaseUrlWhenNoRPMOrDebRepoIsReachable.

@Test
public void testValidateForAmbariBaseUrlWhenNoRPMOrDebRepoIsReachable() {
    String ambariBaseUrl = "http://s3.amazonaws.com/dev.hortonworks.com/ambari/centos6/2.x/BUILDS/2.6.1.0-143";
    RepoConfigValidationV4Request request = new RepoConfigValidationV4Request();
    request.setAmbariBaseUrl(ambariBaseUrl);
    when(urlAccessValidationService.isAccessible(anyString())).thenReturn(false);
    RepoConfigValidationV4Response result = underTest.validate(request);
    String rpmRepoDataTarget = ambariBaseUrl + RPM_REPO_REPODATA_PATH;
    String debRepoDataTarget = ambariBaseUrl + "/dists/Ambari/InRelease";
    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.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 4 with RepoConfigValidationV4Request

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

the class RepositoryConfigValidationServiceTest method testValidateForStackUtilsBaseUrlWhenDebRepoIsReachable.

@Test
public void testValidateForStackUtilsBaseUrlWhenDebRepoIsReachable() {
    String utilsBaseUrl = "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/ubuntu14";
    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(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.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 5 with RepoConfigValidationV4Request

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

the class RepositoryConfigValidationServiceTest method testValidateForStackUtilsBaseUrlWhenRPMRepoIsReachable.

@Test
public void testValidateForStackUtilsBaseUrlWhenRPMRepoIsReachable() {
    String hdpUtilsBaseUrl = "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/sles12";
    RepoConfigValidationV4Request request = new RepoConfigValidationV4Request();
    request.setUtilsBaseURL(hdpUtilsBaseUrl);
    String rpmRepoDataTarget = hdpUtilsBaseUrl + RPM_REPO_REPODATA_PATH;
    when(urlAccessValidationService.isAccessible(rpmRepoDataTarget)).thenReturn(true);
    RepoConfigValidationV4Response result = underTest.validate(request);
    verify(urlAccessValidationService, times(1)).isAccessible(rpmRepoDataTarget);
    assertTrue(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)

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