Search in sources :

Example 6 with CloudIdentity

use of org.onap.so.db.catalog.beans.CloudIdentity in project so by onap.

the class CloudIdentityTest method testCloudIdentity.

@Test
public final void testCloudIdentity() {
    CloudIdentity id = new CloudIdentity();
    id.setAdminTenant("AdminTenant");
    id.setId("id");
    // id.setKeystoneUrl ("keystone");
    id.setIdentityUrl("keystone");
    id.setMemberRole("member");
    id.setMsoId("msoId");
    id.setMsoPass(CryptoUtils.encryptCloudConfigPassword("password"));
    id.setTenantMetadata(true);
    id.setIdentityServerType(null);
    id.setIdentityAuthenticationType(null);
    assertTrue(id.getAdminTenant().equals("AdminTenant"));
    assertTrue(id.getId().equals("id"));
    // assertTrue (id.getKeystoneUrl ().equals ("keystone"));
    assertTrue(id.getMemberRole().equals("member"));
    assertTrue(id.getMsoId().equals("msoId"));
    assertTrue(CryptoUtils.decryptCloudConfigPassword(id.getMsoPass()).equals("password"));
    assertTrue(id.getTenantMetadata());
    // assertTrue (id.toString ().contains ("keystone"));
    assertTrue(id.toString().contains("null"));
}
Also used : CloudIdentity(org.onap.so.db.catalog.beans.CloudIdentity) Test(org.junit.Test)

Example 7 with CloudIdentity

use of org.onap.so.db.catalog.beans.CloudIdentity in project so by onap.

the class CloudIdentityTest method cloneTest.

@Test
public void cloneTest() {
    cloudIdentity = setupCloudIdentity(cloudIdentity, ID, IDENTITY_URL, MSO_ID, MSO_PASS, ADMIN_TENANT, MEMBER_ROLE, TENANT_METADATA, ServerType.ORM, AuthenticationType.USERNAME_PASSWORD);
    CloudIdentity cloudIdentity2 = cloudIdentity.clone();
    assertEquals(cloudIdentity.getClass(), cloudIdentity2.getClass());
}
Also used : CloudIdentity(org.onap.so.db.catalog.beans.CloudIdentity) Test(org.junit.Test)

Example 8 with CloudIdentity

use of org.onap.so.db.catalog.beans.CloudIdentity in project so by onap.

the class CloudConfigTest method createCloudSiteRest_TEST.

@Test
@Transactional
public void createCloudSiteRest_TEST() {
    headers.set("Accept", MediaType.APPLICATION_JSON);
    headers.set("Content-Type", MediaType.APPLICATION_JSON);
    CloudSite cloudSite = new CloudSite();
    cloudSite.setId("MTN7");
    cloudSite.setClli("TESTCLLI");
    cloudSite.setRegionId("regionId");
    cloudSite.setCloudVersion("VERSION");
    cloudSite.setPlatform("PLATFORM");
    CloudIdentity cloudIdentity = new CloudIdentity();
    cloudIdentity.setId("RANDOMID-test");
    cloudIdentity.setIdentityUrl("URL");
    cloudIdentity.setMsoId("MSO_ID");
    cloudIdentity.setMsoPass("MSO_PASS");
    cloudIdentity.setAdminTenant("ADMIN_TENANT");
    cloudIdentity.setMemberRole("ROLE");
    cloudIdentity.setIdentityServerType(ServerType.KEYSTONE);
    cloudIdentity.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY);
    cloudSite.setIdentityService(cloudIdentity);
    String uri = "/cloudSite";
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:" + port + uri);
    HttpEntity<CloudSite> request = new HttpEntity<CloudSite>(cloudSite, headers);
    ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, request, String.class);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value());
    builder = UriComponentsBuilder.fromHttpUrl("http://localhost:" + port + uri + "/" + cloudSite.getId());
    HttpEntity<String> entity = new HttpEntity<String>(null, headers);
    ResponseEntity<CloudSite> actualCloudSite = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, CloudSite.class);
    builder = UriComponentsBuilder.fromHttpUrl("http://localhost:" + port + uri);
    ResponseEntity<String> cloudSiteString = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
    System.out.println(cloudSiteString.getBody());
    assertEquals(Response.Status.OK.getStatusCode(), actualCloudSite.getStatusCode().value());
    assertThat(actualCloudSite.getBody(), sameBeanAs(cloudSite).ignoring("created").ignoring("updated").ignoring("identityService.created").ignoring("identityService.updated"));
}
Also used : HttpEntity(org.springframework.http.HttpEntity) CloudSite(org.onap.so.db.catalog.beans.CloudSite) CloudIdentity(org.onap.so.db.catalog.beans.CloudIdentity) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) CatalogDbAdapterBaseTest(org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest) Transactional(javax.transaction.Transactional)

Example 9 with CloudIdentity

use of org.onap.so.db.catalog.beans.CloudIdentity in project so by onap.

the class MsoHeatUtilsITTest method getHeatClientOpenStackConnectExceptionTest.

@Test(expected = MsoOpenstackException.class)
public final void getHeatClientOpenStackConnectExceptionTest() throws MsoException, IOException {
    CloudIdentity identity = getCloudIdentity();
    identity.setIdentityUrl("http://unreachable");
    CloudSite cloudSite = getCloudSite(identity);
    // mo mocks setup will cause 404 response from wiremock
    heatUtils.getHeatClient("MTN13", "TEST-tenant");
}
Also used : CloudIdentity(org.onap.so.db.catalog.beans.CloudIdentity) CloudSite(org.onap.so.db.catalog.beans.CloudSite) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 10 with CloudIdentity

use of org.onap.so.db.catalog.beans.CloudIdentity in project so by onap.

the class MsoMulticloudUtilsTest method createStackMulticloudClientIsNull.

@Ignore
@Test
public void createStackMulticloudClientIsNull() {
    try {
        multicloudUtilsMock.cloudConfig = cloudConfigMock;
        CloudSite cloudSite = new CloudSite();
        cloudSite.setIdentityService(new CloudIdentity());
        when(cloudConfigMock.getCloudSite("MTN13")).thenReturn(Optional.of(cloudSite));
        multicloudUtilsMock.createStack("MNT14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(), "TEST-heat", new HashMap<>(), false, 200, "TEST-env", new HashMap<>(), new HashMap<>(), false, false);
    } catch (MsoException e) {
        assertEquals("0 : Multicloud client could not be initialized", e.toString());
        return;
    }
    fail("MsoOpenstackException expected!");
}
Also used : MsoException(org.onap.so.openstack.exceptions.MsoException) CloudSite(org.onap.so.db.catalog.beans.CloudSite) CloudIdentity(org.onap.so.db.catalog.beans.CloudIdentity) VduModelInfo(org.onap.so.adapters.vdu.VduModelInfo) Ignore(org.junit.Ignore) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Aggregations

CloudIdentity (org.onap.so.db.catalog.beans.CloudIdentity)26 Test (org.junit.Test)13 CloudSite (org.onap.so.db.catalog.beans.CloudSite)12 Authentication (com.woorea.openstack.keystone.model.Authentication)8 RackspaceAuthentication (org.onap.so.cloud.authentication.models.RackspaceAuthentication)6 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)4 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)4 UsernamePassword (com.woorea.openstack.keystone.model.authentication.UsernamePassword)4 MsoAdapterException (org.onap.so.openstack.exceptions.MsoAdapterException)4 MsoCloudSiteNotFound (org.onap.so.openstack.exceptions.MsoCloudSiteNotFound)4 Keystone (com.woorea.openstack.keystone.Keystone)3 Access (com.woorea.openstack.keystone.model.Access)3 MsoException (org.onap.so.openstack.exceptions.MsoException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Identity (com.woorea.openstack.keystone.v3.model.Authentication.Identity)2 Password (com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password)2 User (com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password.User)2 Domain (com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password.User.Domain)2 Scope (com.woorea.openstack.keystone.v3.model.Authentication.Scope)2 Project (com.woorea.openstack.keystone.v3.model.Authentication.Scope.Project)2