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.cloud;
23 import static org.junit.Assert.*;
26 import java.util.Optional;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.onap.so.BaseTest;
31 import org.onap.so.openstack.exceptions.MsoException;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.boot.test.context.SpringBootTest;
34 import org.springframework.test.context.ActiveProfiles;
35 import org.springframework.test.context.junit4.SpringRunner;
38 * This class implements test methods of the CloudConfig features.
42 public class CloudConfigTest extends BaseTest {
45 private CloudConfig con;
48 * This method implements a test for the getCloudSites method.
51 public final void testGetCloudSites () {
52 Map<String,CloudSite> siteMap = con.getCloudSites();
53 assertNotNull(siteMap);
55 CloudSite site1 = siteMap.get("regionOne");
57 assertEquals ("regionOne", site1.getRegionId());
58 assertEquals ("MT_KEYSTONE", site1.getIdentityServiceId());
59 assertEquals ("MT2", site1.getClli());
60 assertEquals ("2.5", site1.getAicVersion());
65 * This method implements a test for the getIdentityServices method.
66 * @throws MsoException
69 public final void testGetIdentityServices () throws MsoException {
70 Map<String,CloudIdentity> identityMap = con.getIdentityServices ();
71 assertNotNull(identityMap);
73 CloudIdentity identity1 = identityMap.get("MT_KEYSTONE");
75 assertEquals("john", identity1.getMsoId());
76 assertEquals("313DECE408AF7759D442D7B06DD9A6AA", identity1.getMsoPass());
77 assertEquals("admin", identity1.getAdminTenant());
78 assertEquals("_member_", identity1.getMemberRole());
79 assertEquals(false, identity1.hasTenantMetadata());
80 assertEquals("http://localhost:"+wireMockPort+"/v2.0", identity1.getIdentityUrl());
81 assertEquals(ServerType.KEYSTONE, identity1.getIdentityServerType());
82 assertEquals(AuthenticationType.USERNAME_PASSWORD, identity1.getIdentityAuthenticationType());
87 * This method implements a test for the getCloudSite method.
90 public final void testGetDefaultCloudSite () {
91 Optional<CloudSite> site = con.getCloudSite("NotThere");
92 assertTrue(site.isPresent());
93 CloudSite site1 = site.get();
94 assertEquals ("NotThere", site1.getRegionId());
95 assertEquals("MTN6", site1.getClli());
96 assertEquals("NotThere", site1.getId());
97 assertEquals ("ORDM3", site1.getIdentityServiceId());
101 public void testGetIdentityService() {
102 CloudIdentity identity = con.getIdentityService("MT_KEYSTONE");
103 assertEquals("john", identity.getMsoId());
104 assertEquals("MT_KEYSTONE", identity.getId());