2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapter_utils.tests;
24 import org.apache.http.HttpHeaders;
25 import org.apache.http.HttpStatus;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.onap.so.BaseTest;
29 import org.onap.so.db.catalog.beans.AuthenticationType;
30 import org.onap.so.db.catalog.beans.CloudIdentity;
31 import org.onap.so.db.catalog.beans.CloudSite;
32 import org.onap.so.db.catalog.beans.ServerType;
33 import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
34 import org.onap.so.openstack.utils.MsoHeatUtils;
35 import org.springframework.beans.factory.annotation.Autowired;
37 import javax.ws.rs.core.MediaType;
38 import java.io.IOException;
40 import static com.github.tomakehurst.wiremock.client.WireMock.*;
41 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
42 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
43 import static org.junit.Assert.assertEquals;
46 * This class implements test methods of the MsoHeatUtils
50 public class MsoHeatUtilsRefactorTest extends BaseTest {
53 private MsoHeatUtils msoHeatUtils;
56 public void init() throws IOException {
57 CloudIdentity identity = new CloudIdentity();
59 identity.setId("MTN13");
60 identity.setMsoId("m93945");
61 identity.setMsoPass("93937EA01B94A10A49279D4572B48369");
62 identity.setAdminTenant("admin");
63 identity.setMemberRole("admin");
64 identity.setTenantMetadata(true);
65 identity.setIdentityUrl("http://localhost:28090/v2.0");
66 identity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD);
68 CloudSite cloudSite = new CloudSite();
69 cloudSite.setId("MTN13");
70 cloudSite.setCloudVersion("3.0");
71 cloudSite.setClli("MDT13");
72 cloudSite.setRegionId("MTN13");
73 identity.setIdentityServerType(ServerType.KEYSTONE);
74 cloudSite.setIdentityService(identity);
77 stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse()
78 .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
79 .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
80 .withStatus(HttpStatus.SC_OK)));
81 stubFor(get(urlPathEqualTo("/cloudIdentity/MTN13")).willReturn(aResponse()
82 .withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, ""))
83 .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
84 .withStatus(HttpStatus.SC_OK)));
88 public final void testGetKeystoneUrl() throws MsoCloudSiteNotFound {
89 String keyUrl = msoHeatUtils.getCloudSiteKeystoneUrl("DAN");
90 assertEquals("http://localhost:28090/v2.0", keyUrl);