import com.fasterxml.jackson.annotation.JsonRootName;
-import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.CloudifyManager;
import org.onap.so.db.catalog.client.CatalogDbClient;
public class CloudConfig {
private static final String CLOUD_SITE_VERSION = "2.5";
- private static final String DEFAULT_CLOUD_SITE_ID = "default";
+ private static final String DEFAULT_CLOUD_SITE_ID = "DEFAULT";
@Autowired
private CatalogDbClient catalogDbClient;
}
}
- /**
- * Get a specific CloudIdentity, based on an ID.
- *
- * @param id
- * the ID to match
- * @return a CloudIdentity, or null of no match found
- */
- public CloudIdentity getIdentityService(String id) {
- return catalogDbClient.getCloudIdentity(id);
- }
-
/**
* Get a specific CloudifyManager, based on an ID.
* @param id the ID to match
protected OpenstackConfig getOpenstackConfig (CloudSite cloudSite, String tenantId) {
OpenstackConfig openstackConfig = new OpenstackConfig();
openstackConfig.setRegion (cloudSite.getRegionId());
- openstackConfig.setAuthUrl (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getIdentityUrl());
- openstackConfig.setUsername (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getMsoId());
- openstackConfig.setPassword (CryptoUtils.decryptCloudConfigPassword(cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getMsoPass()));
+ openstackConfig.setAuthUrl (cloudSite.getIdentityService().getIdentityUrl());
+ openstackConfig.setUsername (cloudSite.getIdentityService().getMsoId());
+ openstackConfig.setPassword (CryptoUtils.decryptCloudConfigPassword(cloudSite.getIdentityService().getMsoPass()));
openstackConfig.setTenantName (tenantId);
return openstackConfig;
}
OpenStackRequest <Stack> request = heatClient.getStacks ().create (stack);
// Begin X-Auth-User
// Obtain an MSO token for the tenant
- CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId());
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
// cloudIdentity.getMsoId(), cloudIdentity.getMsoPass()
//req
request.header ("X-Auth-User", cloudIdentity.getMsoId ());
}
// Obtain an MSO token for the tenant
- CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId());
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
LOGGER.debug("Found: " + cloudIdentity.toString());
MsoTenantUtils tenantUtils = tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
String keystone_url = null;
try {
CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
- CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId());
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
keystone_url = cloudIdentity.getIdentityUrl();
} catch (Exception e) {
throw new MsoCloudSiteNotFound(cloudSiteId);
// Add MSO User to the tenant as a member and
// apply tenant metadata if supported by the cloud site
try {
- CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSiteOpt.get().getIdentityServiceId());
+ CloudIdentity cloudIdentity = cloudSiteOpt.get().getIdentityService();
User msoUser = findUserByNameOrId (keystoneAdminClient, cloudIdentity.getMsoId ());
Role memberRole = findRoleByNameOrId (keystoneAdminClient, cloudIdentity.getMemberRole ());
}
Map <String, String> metadata = new HashMap <String, String> ();
- if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getTenantMetadata ()) {
+ if (cloudSite.getIdentityService().getTenantMetadata ()) {
OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ());
Metadata tenantMetadata = executeAndRecordOpenstackRequest (request);
if (tenantMetadata != null) {
}
Map <String, String> metadata = new HashMap <String, String> ();
- if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getTenantMetadata ()) {
+ if (cloudSite.getIdentityService().getTenantMetadata ()) {
OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ());
Metadata tenantMetadata = executeAndRecordOpenstackRequest (request);
if (tenantMetadata != null) {
* @return an authenticated Keystone object
*/
public Keystone getKeystoneAdminClient (CloudSite cloudSite) throws MsoException {
- CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId());
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
String cloudId = cloudIdentity.getId ();
String adminTenantName = cloudIdentity.getAdminTenant ();
}
// Obtain an MSO token for the tenant from the identity service
- CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId());
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
MsoTenantUtils tenantUtils = tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
final String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
Keystone keystoneTenantClient = new Keystone(keystoneUrl);
CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(
() -> new MsoCloudSiteNotFound(cloudSiteId));
- return getTenantUtilsByServerType(cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getIdentityServerType());
+ return getTenantUtilsByServerType(cloudSite.getIdentityService().getIdentityServerType());
}
public MsoTenantUtils getTenantUtilsByServerType(ServerType serverType) {
.withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
.withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/cloudSite/default")).willReturn(aResponse()
+ stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse()
.withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
.withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
cloudSite.setIdentityService(identity);
- stubFor(get(urlPathEqualTo("/cloudSite/default")).willReturn(aResponse()
+ stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse()
.withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
.withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
assertEquals ("3.0", site1.getCloudVersion());
}
-
- /**
- * This method implements a test for the getIdentityServices method.
- * @throws MsoException
- */
- @Test
- public final void testGetIdentityServices () throws MsoException {
-
- CloudIdentity identity1 = con.getIdentityService("mtn13");
-
- assertEquals("m93945", identity1.getMsoId());
- assertEquals("93937EA01B94A10A49279D4572B48369", identity1.getMsoPass());
- assertEquals("admin", identity1.getAdminTenant());
- assertEquals("admin", identity1.getMemberRole());
- assertTrue(identity1.getIdentityUrl().contains("http://localhost:"));
- assertEquals(ServerType.KEYSTONE, identity1.getIdentityServerType());
- assertEquals(AuthenticationType.USERNAME_PASSWORD, identity1.getIdentityAuthenticationType());
-
- }
-
/**
* This method implements a test for the getCloudSite method.
*/
package org.onap.so.adapters.catalogdb.catalogrest;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import java.net.URI;
-import java.util.List;
-
import javax.transaction.Transactional;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.catalogdb.CatalogDBApplication;
import org.onap.so.db.catalog.beans.AuthenticationType;
-import org.onap.so.db.catalog.beans.BuildingBlockDetail;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
-import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
-import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
-import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
-import org.onap.so.db.catalog.beans.InstanceGroup;
-import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
import org.onap.so.db.catalog.beans.ServerType;
-import org.onap.so.db.catalog.client.CatalogDbClient;
-import org.onap.so.logger.MsoLogger;
-import org.onap.so.logging.jaxrs.filter.jersey.SpringClientFilter;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
-import org.springframework.http.client.BufferingClientHttpRequestFactory;
-import org.springframework.http.client.ClientHttpRequestFactory;
-import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.util.UriComponentsBuilder;
-import uk.co.blackpepper.bowman.Client;
-import uk.co.blackpepper.bowman.ClientFactory;
-import uk.co.blackpepper.bowman.Configuration;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
--- /dev/null
+package org.onap.so.db.catalog.client;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.adapters.catalogdb.CatalogDBApplication;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.db.catalog.beans.CloudifyManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.UUID;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class CatalogDbClientTest {
+ public static final String MTN13 = "mtn13";
+ @LocalServerPort
+ private int port;
+ @Autowired
+ CatalogDbClient client;
+
+ @Before
+ public void setPort() {
+ client.removePortFromEndpoint();
+ client.setPortToEndpoint(Integer.toString(port));
+ }
+
+ @Test
+ public void testGetCloudSiteHappyPath() throws Exception {
+ CloudSite cloudSite = client.getCloudSite(MTN13);
+ Assert.assertNotNull(cloudSite);
+ Assert.assertNotNull(cloudSite.getIdentityService());
+ Assert.assertEquals("MDT13", cloudSite.getClli());
+ Assert.assertEquals("mtn13", cloudSite.getRegionId());
+ Assert.assertEquals("MTN13", cloudSite.getIdentityServiceId());
+ }
+
+ @Test
+ public void testGetCloudSiteNotFound() throws Exception {
+ CloudSite cloudSite = client.getCloudSite(UUID.randomUUID().toString());
+ Assert.assertNull(cloudSite);
+ }
+
+ @Test
+ public void testGetCloudifyManagerHappyPath() throws Exception {
+ CloudifyManager cloudifyManager = client.getCloudifyManager("mtn13");
+ Assert.assertNotNull(cloudifyManager);
+ Assert.assertEquals("http://localhost:28090/v2.0", cloudifyManager.getCloudifyUrl());
+
+ }
+
+ @Test
+ public void testGetCloudifyManagerNotFound() throws Exception {
+ CloudifyManager cloudifyManager = client.getCloudifyManager(UUID.randomUUID().toString());
+ Assert.assertNull(cloudifyManager);
+ }
+
+
+
+ @Test
+ public void testGetCloudSiteByClliAndAicVersionHappyPath() throws Exception{
+ CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13","2.5");
+ Assert.assertNotNull(cloudSite);
+ }
+
+ @Test
+ public void testGetCloudSiteByClliAndAicVersionNotFound() throws Exception{
+ CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13","232496239746328");
+ Assert.assertNull(cloudSite);
+ }
+}
insert into vnf_components(vnf_id, component_type, heat_template_id, heat_environment_id, creation_timestamp) values
('13961', 'VOLUME', '13843', '13961', '2016-05-19 20:22:02');
+
+
+INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', NULL, 'MSO_USER', '2018-07-17 14:05:08', '2018-07-17 14:05:08');
+
+INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('MTN13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', 'admin', 'admin', 1, 'KEYSTONE', 'USERNAME_PASSWORD', 'MSO_USER', '2018-07-17 14:02:33', '2018-07-17 14:02:33');
+
+INSERT INTO `cloud_sites` (`ID`, `REGION_ID`, `IDENTITY_SERVICE_ID`, `CLOUD_VERSION`, `CLLI`, `CLOUDIFY_ID`, `PLATFORM`, `ORCHESTRATOR`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'mtn13', 'MTN13', '2.5', 'MDT13', 'mtn13', NULL, 'orchestrator', 'MSO_USER', '2018-07-17 14:06:28', '2018-07-17 14:06:28');
\ No newline at end of file
import org.apache.http.HttpStatus;
import org.junit.Test;
import org.onap.so.adapters.vnf.BaseRestTestUtils;
-import org.onap.so.cloud.CloudConfig;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
public static final String NETWORK_ID = "43173f6a-d699-414b-888f-ab243dda6dfe";
public static final String NETWORK_NAME = "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0";
- @Autowired
- private CloudConfig cloudConfig;
+
@Test
public void createNetworkByModelNameNeutronModeGetNetworkException() throws IOException{
-
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenstackGet("/mockPublicUrl/v2.0/networks",HttpStatus.SC_INTERNAL_SERVER_ERROR);
@Test
public void createNetworkByModelNameNeutronModeCreateNetworkException() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetNeutronNetwork_404("dvspg-VCE_VPE-mtjnj40avbc");
@Test
public void createNetworkByModelNameNeutronMode() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetNeutronNetwork_404("dvspg-VCE_VPE-mtjnj40avbc");
@Test
public void createNetworkByModelNameAlreadyExistNeutronMode() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetAllNeutronNetworks_200("OpenstackGetNeutronNetworks.json");
@Test
public void createNetworkByModelNameAlreadyExistNeutronModeFailIfExistTrue() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetAllNeutronNetworks_200("OpenstackGetNeutronNetworks.json");
@Test
public void createNetworkByModelNameHeatMode() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetStack_404("dvspg-VCE_VPE-mtjnj40avbc");
@Test
public void createNetworkByModelNameAlreadyExistHeatMode() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackPostStack_200("OpenstackResponse_Stack.json");
@Test
public void createNetworkByModelNameAlreadyExistHeatModeFailIfExistTrue() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc");
@Test
public void createNetworkByModelNameHeatModeQueryNetworkException() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenstackGet("/mockPublicUrl/stacks/dvspg-VCE_VPE-mtjnj40avbc",HttpStatus.SC_INTERNAL_SERVER_ERROR);
@Test
public void createNetworkByModelNameHeatModeCreateNetworkException() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetStack_404("dvspg-VCE_VPE-mtjnj40avbc");
@Test
public void createNetworkByModelNameCloudSiteNotPresentError() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackPostStack_200("OpenstackResponse_Stack.json");
@Test
public void deleteNetworkHeatModeSuccess() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetStackDeleteOrUpdateComplete_200("OpenstackResponse_Stack_DeleteComplete.json");
@Test
public void deleteNetworkDeleteStackException() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetStackDeleteOrUpdateComplete_200("OpenstackResponse_Stack_DeleteComplete.json");
@Test
public void deleteNetworkError() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetStackDeleteOrUpdateComplete_200("OpenstackResponse_Stack_DeleteComplete.json");
@Test
public void deleteNetworkNeureonMode() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
@Test
public void deleteNetworkNeutronModeDeleteStackException() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
@Test
public void updateNetworkNeutronModeSuccess() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
@Test
public void updateNetworkNeutronUpdateException() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
@Test
public void updateNetworkHeatUpdateException() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", NETWORK_NAME);
@Test
public void updateNetworkHeatQueryException() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetStack_500(NETWORK_NAME);
@Test
public void updateNetworkHeatStackNotFound() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetStack_404(NETWORK_NAME);
@Test
public void updateNetworkNeutronQueryException() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetNeutronNetwork(NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR);
@Test
public void updateNetworkNeutronStackNotFound() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetNeutronNetwork(NETWORK_ID,HttpStatus.SC_NOT_FOUND);
@Test
public void queryNetworkHeatModesuccess() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", NETWORK_ID);
@Test
public void queryNetworkHeatModeQueryException() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetStack_500(NETWORK_ID);
@Test
public void queryNetworkNeutronModeSuccess() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
@Test
public void queryNetworkNeutronModeException() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetNeutronNetwork(NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR);
import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
import org.onap.so.adapters.vnf.BaseRestTestUtils;
import org.onap.so.client.policy.JettisonStyleMapperProvider;
-import org.onap.so.cloud.CloudConfig;
import org.onap.so.entity.MsoRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
public class NetworkAdapterRestTest extends BaseRestTestUtils {
- @Autowired
- private CloudConfig cloudConfig;
@Autowired
private JettisonStyleMapperProvider jettisonTypeObjectMapper;
private static final String CLOUDSITE_ID = "mtn13";
@Test
public void testCreateNetwork() throws JSONException, JsonParseException, JsonMappingException, IOException {
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
CreateNetworkRequest request = new CreateNetworkRequest();
request.setBackout(true);
request.setSkipAAI(true);
@Test
public void testCreateNetwork_JSON() throws JSONException, JsonParseException, JsonMappingException, IOException {
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
+
mockOpenStackResponseAccess(wireMockPort);
@Test
public void testDeleteNetwork() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
DeleteNetworkRequest request = new DeleteNetworkRequest();
MsoRequest msoReq = new MsoRequest();
@Test
public void testQueryNetwork_Exception() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
MsoRequest msoReq = new MsoRequest();
msoReq.setRequestId(MSO_REQUEST_ID);
msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
@Test
public void testQueryNetwork() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
mockOpenStackResponseAccess(wireMockPort);
mockOpenStackGetStackVfModule_200();
@Test
public void testUpdateNetwork() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
UpdateNetworkRequest request = new UpdateNetworkRequest();
MsoRequest msoReq = new MsoRequest();
import org.onap.so.adapters.tenantrest.DeleteTenantResponse;
import org.onap.so.adapters.vnf.BaseRestTestUtils;
import org.onap.so.client.policy.JettisonStyleMapperProvider;
-import org.onap.so.cloud.CloudConfig;
import org.onap.so.entity.MsoRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
public class TenantAdapterRestTest extends BaseRestTestUtils {
- @Autowired
- private CloudConfig cloudConfig;
@Autowired
private JettisonStyleMapperProvider jettisonTypeObjectMapper;
@Test
public void testCreateTenantCreated() throws JsonParseException, JsonMappingException, IOException {
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
CreateTenantRequest request = new CreateTenantRequest();
String cloudSiteId = "MTN13";
String requestId = "62265093-277d-4388-9ba6-449838ade586";
@Test
public void testCreateTenantExists() throws JsonParseException, JsonMappingException, IOException {
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
CreateTenantRequest request = new CreateTenantRequest();
String cloudSiteId = "MTN13";
String requestId = "62265093-277d-4388-9ba6-449838ade586";
@Test
public void testDeleteTenant() throws IOException {
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
DeleteTenantRequest request = new DeleteTenantRequest();
String cloudSiteId = "mtn13";
String tenantId = "tenantId";
@Test
public void testDeleteTenantFails() throws IOException {
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
DeleteTenantRequest request = new DeleteTenantRequest();
String cloudSiteId = "mtn13";
String tenantId = "tenantId";
@Test
public void testQuaryTenant() {
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
}
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.openstack.MsoOpenstackAdaptersApplication;
+import org.onap.so.cloud.CloudConfig;
import org.onap.so.db.catalog.beans.AuthenticationType;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
public class BaseRestTestUtils {
@Value("${wiremock.server.port}")
protected int wireMockPort;
-
+ @Autowired
+ CloudConfig cloudConfig;
+
@Autowired
@Qualifier("JettisonStyle")
protected TestRestTemplate restTemplate;
.withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
.withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/cloudSite/default")).willReturn(aResponse()
+ stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse()
.withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
.withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
.withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, ""))
.withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
+ cloudConfig.getCloudSite("MTN13").get().getIdentityService().setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
+
}
protected static String getBody(String body, int port, String urlPath) throws IOException {
import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse;
import org.onap.so.adapters.vnfrest.VfModuleRollback;
import org.onap.so.client.policy.JettisonStyleMapperProvider;
-import org.onap.so.cloud.CloudConfig;
import org.onap.so.entity.MsoRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
public class VnfAdapterRestTest extends BaseRestTestUtils {
- @Autowired
- private CloudConfig cloudConfig;
+
@Autowired
private JettisonStyleMapperProvider jettisonTypeObjectMapper;
private static final String MESSAGE_ID = "62265093-277d-4388-9ba6-449838ade586-1517252396874";
public void testCreateVfModuleWithEnableBridgeNull()
throws JSONException, JsonParseException, JsonMappingException, IOException {
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
CreateVfModuleRequest request = new CreateVfModuleRequest();
request.setBackout(true);
request.setSkipAAI(true);
@Test
public void testCreateVfModuleFail() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
CreateVfModuleRequest request = new CreateVfModuleRequest();
request.setBackout(true);
request.setSkipAAI(true);
@Test
public void testDeleteVfModule() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
DeleteVfModuleRequest request = new DeleteVfModuleRequest();
MsoRequest msoRequest = new MsoRequest();
String vfModuleStackId = "stackId";
@Test
public void testUpdateVfModule() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
UpdateVfModuleRequest request = new UpdateVfModuleRequest();
MsoRequest msoRequest = new MsoRequest();
String vfModuleStackId = "vfModuleStackId";
@Test
public void testRollbackVfModule() throws IOException {
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
-
+
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId(MSO_REQUEST_ID);
msoRequest.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
@Test
public void testQueryVfModule() throws IOException{
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
String testUrl = createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID);
String testUri = UriBuilder.fromPath("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID )
.host("localhost").port(wireMockPort).scheme("http")
}
private CreateVfModuleRequest populateCreateVfModuleRequest(){
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
CreateVfModuleRequest request = new CreateVfModuleRequest();
request.setBackout(true);
request.setSkipAAI(true);
import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest;
import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest;
import org.onap.so.adapters.vnfrest.VolumeGroupRollback;
-import org.onap.so.cloud.CloudConfig;
import org.onap.so.entity.MsoRequest;
-import org.springframework.beans.factory.annotation.Autowired;
import java.util.HashMap;
import java.util.Map;
public class VolumeGroupAdapterCommon extends BaseRestTestUtils {
- @Autowired
- protected CloudConfig cloudConfig;
+
protected static final String MSO_REQUEST_ID = "62265093-277d-4388-9ba6-449838ade586";
protected static final String MSO_SERVICE_INSTANCE_ID = "4147e06f-1b89-49c5-b21f-4faf8dc9805a";
}
protected CreateVolumeGroupRequest buildCreateVfModuleRequest() {
- cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0");
CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
request.setCloudSiteId(CLOUDSITE_ID);
request.setTenantId(TENANT_ID);
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.client.BufferingClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpRequestFactory;
-import org.springframework.http.client.SimpleClientHttpRequestFactory;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestTemplate;
import uk.co.blackpepper.bowman.Client;
import uk.co.blackpepper.bowman.ClientFactory;
import uk.co.blackpepper.bowman.Configuration;
-import uk.co.blackpepper.bowman.RestTemplateConfigurer;
import javax.annotation.PostConstruct;
import javax.ws.rs.core.UriBuilder;
-import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
}
public CatalogDbClient() {
- ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory());
+ ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory());
ClientFactory clientFactory = Configuration.builder().setClientHttpRequestFactory(factory).setRestTemplateConfigurer(restTemplate -> {
restTemplate.getInterceptors().add((new SpringClientFilter()));
return this.getSingleCloudIdentity(UriBuilder.fromUri(endpoint+"/cloudIdentity/"+id).build());
}
- public CloudSite getCloudSiteByClliAndAicVersion (String clli, String aicVersion){
- return this.getSinglCloudSite(UriBuilder.fromUri(endpoint+"/cloud_sites/search/findByClliAndCloudVersion")
- .queryParam("CLLI",clli).queryParam("AIC_VERSION",aicVersion)
+ public CloudSite getCloudSiteByClliAndAicVersion (String clli, String cloudVersion){
+ return this.getSinglCloudSite(UriBuilder.fromUri(endpoint+"/cloudSite/search/findByClliAndCloudVersion")
+ .queryParam("CLLI",clli).queryParam("CLOUD_VERSION",cloudVersion)
.build());
}
import org.onap.so.db.catalog.beans.CloudSite;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import javax.transaction.Transactional;
@Transactional
public interface CloudSiteRepository extends JpaRepository<CloudSite, String> {
- CloudSite findByClliAndCloudVersion(String clli, String aicVersion);
+ CloudSite findByClliAndCloudVersion(@Param("CLLI") String clli,@Param("CLOUD_VERSION") String cloudVersion);
}