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.openecomp.mso.adapter_utils.tests;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertNull;
27 import org.junit.BeforeClass;
28 import org.junit.Test;
30 import org.openecomp.mso.cloud.CloudConfig;
31 import org.openecomp.mso.cloud.CloudConfigFactory;
32 import org.openecomp.mso.cloud.CloudIdentity;
33 import org.openecomp.mso.cloud.CloudSite;
37 * This class implements test methods of the CloudConfig features.
41 public class CloudConfigTest {
43 private static CloudConfig con;
44 private static CloudConfigFactory cloudConfigFactory= new CloudConfigFactory();
46 public CloudConfigTest () {
51 * This method is called before any test occurs.
52 * It creates a fake tree from scratch
55 public static final void prepare () {
56 ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
57 String config = classLoader.getResource("cloud_config.json").toString().substring(5);
59 cloudConfigFactory.initializeCloudConfig(config,1);
60 con = cloudConfigFactory.getCloudConfig();
64 * This method implements a test for the getCloudConfig method.
67 public final void testGetCloudConfig () {
72 * This method implements a test for the getCloudSites method.
75 public final void testGetCloudSites () {
76 Map<String,CloudSite> siteMap = con.getCloudSites();
77 assertNotNull(siteMap);
79 CloudSite site1 = siteMap.get("MT");
80 CloudSite site2 = siteMap.get("DAN");
81 CloudSite site3 = siteMap.get("MTINJVCC101");
83 assertEquals (site1.getRegionId(), "regionOne");
84 assertEquals (site1.getIdentityServiceId(), "MT_KEYSTONE");
85 assertEquals (site2.getRegionId(), "RegionOne");
86 assertEquals (site2.getIdentityServiceId(), "DAN_KEYSTONE");
87 assertEquals (site3.getRegionId(), "regionTwo");
88 assertEquals (site3.getIdentityServiceId(), "MTINJVCC101_DCP");
94 * This method implements a test for the getIdentityServices method.
97 public final void testGetIdentityServices () {
98 Map<String,CloudIdentity> identityMap = con.getIdentityServices ();
99 assertNotNull(identityMap);
101 CloudIdentity identity1 = identityMap.get("MT_KEYSTONE");
102 CloudIdentity identity2 = identityMap.get("DAN_KEYSTONE");
103 CloudIdentity identity3 = identityMap.get("MTINJVCC101_DCP");
104 CloudIdentity identity4 = identityMap.get("MTSNJA3DCP1");
106 // assertEquals (identity1.getKeystoneUrl(), "http://localhost:5000/v2.0");
107 // assertEquals (identity1.getIdentityUrl(), "http://localhost:5000/v2.0");
108 assertEquals (identity1.getMsoId(), "john");
109 assertEquals (identity1.getMsoPass(), "changeme");
110 assertEquals (identity1.getAdminTenant(), "admin");
111 assertEquals (identity1.getMemberRole(), "_member_");
112 assertEquals (identity1.hasTenantMetadata(), false);
114 // assertEquals (identity2.getKeystoneUrl(), "http://localhost:5000/v2.0");
115 // assertEquals (identity2.getIdentityUrl(), "http://localhost:5000/v2.0");
116 assertEquals (identity2.getMsoId(), "mockId");
117 assertEquals (identity2.getMsoPass(), "stack123");
118 assertEquals (identity2.getAdminTenant(), "service");
119 assertEquals (identity2.getMemberRole(), "_member_");
120 assertEquals (identity2.hasTenantMetadata(), false);
122 // assertEquals (identity3.getKeystoneUrl(), "http://localhost:5000/v2.0");
123 // assertEquals (identity3.getIdentityUrl(), "http://localhost:5000/v2.0");
124 assertEquals (identity3.getMsoId(), "mockIdToo");
125 assertEquals (identity3.getMsoPass(), "AICG@mm@@2015");
126 assertEquals (identity3.getAdminTenant(), "service");
127 assertEquals (identity3.getMemberRole(), "admin");
128 assertEquals (identity3.hasTenantMetadata(), true);
130 // assertEquals (identity4.getKeystoneUrl(), "https://localhost:5000/v2.0");
131 // assertEquals (identity4.getIdentityUrl(), "https://localhost:5000/v2.0");
132 assertEquals (identity4.getMsoId(), "mockIdToo");
133 assertEquals (identity4.getMsoPass(), "2315QRS2015srq");
134 assertEquals (identity4.getAdminTenant(), "service");
135 assertEquals (identity4.getMemberRole(), "admin");
136 assertEquals (identity4.hasTenantMetadata(), true);
141 * This method implements a test for the getCloudSite method.
144 public final void testGetCloudSite () {
145 CloudSite site1 = con.getCloudSite("MT");
146 assertNotNull(site1);
147 assertEquals (site1.getRegionId(), "regionOne");
148 assertEquals (site1.getIdentityServiceId(), "MT_KEYSTONE");
155 * This method implements a test for the getIdentityService method.
158 public final void testGetIdentityService () {
159 CloudIdentity identity1 = con.getIdentityService("MT_KEYSTONE");
160 assertNotNull(identity1);
161 // assertEquals (identity1.getKeystoneUrl(), "http://localhost:5000/v2.0");
162 // assertEquals (identity1.getIdentityUrl(), "http://localhost:5000/v2.0");
163 assertEquals (identity1.getMsoId(), "john");
164 assertEquals (identity1.getMsoPass(), "changeme");
165 assertEquals (identity1.getAdminTenant(), "admin");
166 assertEquals (identity1.getMemberRole(), "_member_");
167 assertEquals (identity1.hasTenantMetadata(), false);
169 CloudIdentity identity2 = con.getIdentityService("Test");
170 assertNull(identity2);