Containerization feature of SO
[so.git] / adapters / mso-adapter-utils / src / test / java / org / onap / so / cloud / CloudConfigTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.cloud;
22
23 import static org.junit.Assert.*;
24
25 import java.util.Map;
26 import java.util.Optional;
27
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;
36
37 /**
38  * This class implements test methods of the CloudConfig features.
39  *
40  *
41  */
42 public class CloudConfigTest extends BaseTest {
43
44         @Autowired
45         private CloudConfig con;
46
47    /**
48     * This method implements a test for the getCloudSites method.
49     */
50    @Test
51    public final void testGetCloudSites () {
52            Map<String,CloudSite> siteMap = con.getCloudSites();
53            assertNotNull(siteMap);
54
55            CloudSite site1 = siteMap.get("regionOne");
56
57            assertEquals ("regionOne", site1.getRegionId());
58            assertEquals ("MT_KEYSTONE", site1.getIdentityServiceId());
59            assertEquals ("MT2", site1.getClli());
60            assertEquals ("2.5", site1.getAicVersion());
61    }
62
63
64    /**
65     * This method implements a test for the getIdentityServices method.
66  * @throws MsoException 
67     */
68    @Test
69    public final void testGetIdentityServices () throws MsoException {
70            Map<String,CloudIdentity> identityMap = con.getIdentityServices ();
71            assertNotNull(identityMap);
72
73            CloudIdentity identity1 = identityMap.get("MT_KEYSTONE");
74
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());
83
84    }
85
86    /**
87     * This method implements a test for the getCloudSite method.
88     */
89    @Test
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());
98    }
99    
100    @Test
101    public void testGetIdentityService() {
102            CloudIdentity identity = con.getIdentityService("MT_KEYSTONE");
103            assertEquals("john", identity.getMsoId());
104            assertEquals("MT_KEYSTONE", identity.getId());
105    }
106
107 }