diff options
Diffstat (limited to 'adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud')
5 files changed, 58 insertions, 221 deletions
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java index 668b1806ac..c6db998b2b 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java @@ -22,86 +22,71 @@ package org.onap.so.cloud; import static org.junit.Assert.*; -import java.util.Map; import java.util.Optional; import org.junit.Test; -import org.junit.runner.RunWith; import org.onap.so.BaseTest; +import org.onap.so.db.catalog.beans.AuthenticationType; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.ServerType; import org.onap.so.openstack.exceptions.MsoException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; /** * This class implements test methods of the CloudConfig features. * * */ -public class CloudConfigTest extends BaseTest { +public class CloudConfigTest extends BaseTest{ @Autowired private CloudConfig con; - /** - * This method implements a test for the getCloudSites method. - */ - @Test - public final void testGetCloudSites () { - Map<String,CloudSite> siteMap = con.getCloudSites(); - assertNotNull(siteMap); - - CloudSite site1 = siteMap.get("regionOne"); - - assertEquals ("regionOne", site1.getRegionId()); - assertEquals ("MT_KEYSTONE", site1.getIdentityServiceId()); - assertEquals ("MT2", site1.getClli()); - assertEquals ("2.5", site1.getAicVersion()); - } - - - /** - * This method implements a test for the getIdentityServices method. - * @throws MsoException - */ - @Test - public final void testGetIdentityServices () throws MsoException { - Map<String,CloudIdentity> identityMap = con.getIdentityServices (); - assertNotNull(identityMap); - - CloudIdentity identity1 = identityMap.get("MT_KEYSTONE"); - - assertEquals("john", identity1.getMsoId()); - assertEquals("313DECE408AF7759D442D7B06DD9A6AA", identity1.getMsoPass()); - assertEquals("admin", identity1.getAdminTenant()); - assertEquals("_member_", identity1.getMemberRole()); - assertEquals(false, identity1.hasTenantMetadata()); - assertEquals("http://localhost:"+wireMockPort+"/v2.0", identity1.getIdentityUrl()); - assertEquals(ServerType.KEYSTONE, identity1.getIdentityServerType()); - assertEquals(AuthenticationType.USERNAME_PASSWORD, identity1.getIdentityAuthenticationType()); - - } - - /** - * This method implements a test for the getCloudSite method. - */ - @Test - public final void testGetDefaultCloudSite () { - Optional<CloudSite> site = con.getCloudSite("NotThere"); - assertTrue(site.isPresent()); - CloudSite site1 = site.get(); - assertEquals ("NotThere", site1.getRegionId()); - assertEquals("MTN6", site1.getClli()); - assertEquals("NotThere", site1.getId()); - assertEquals ("ORDM3", site1.getIdentityServiceId()); - } - - @Test - public void testGetIdentityService() { - CloudIdentity identity = con.getIdentityService("MT_KEYSTONE"); - assertEquals("john", identity.getMsoId()); - assertEquals("MT_KEYSTONE", identity.getId()); - } - + /** + * This method implements a test for the getCloudSite method. + */ + @Test + public final void testGetCloudSite () { + CloudSite site1 = con.getCloudSite("MTN13").get(); + + assertEquals ("mtn13", site1.getRegionId()); + assertEquals ("mtn13", site1.getIdentityServiceId()); + assertEquals ("MDT13", site1.getClli()); + 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. + */ + @Test + public final void testGetDefaultCloudSite () { + Optional<CloudSite> site = con.getCloudSite("NotThere"); + assertTrue(site.isPresent()); + CloudSite site1 = site.get(); + assertEquals ("NotThere", site1.getRegionId()); + assertEquals("MDT13", site1.getClli()); + assertEquals("NotThere", site1.getId()); + } + } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudIdentityTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudIdentityTest.java deleted file mode 100644 index db2ba05bf1..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudIdentityTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloud; - - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.security.GeneralSecurityException; - -import org.junit.Test; -import org.onap.so.utils.CryptoUtils; - -public class CloudIdentityTest { - - private CloudIdentity cloudIdentity = new CloudIdentity(); - private static final String ID = "testId"; - private static final String IDENTITY_URL = "testIdentityUrl"; - private static final String MSO_ID = "testMsoId"; - private static final String MSO_PASS = "testMsoPassword"; - private static final String ADMIN_TENANT = "testAdminTenant"; - private static final String MEMBER_ROLE = "testMemberRole"; - private static final Boolean TENANT_METADATA = true; - - @Test - public final void testCloudIdentity () { - CloudIdentity id = new CloudIdentity (); - id.setAdminTenant ("AdminTenant"); - id.setId ("id"); -// id.setKeystoneUrl ("keystone"); - id.setIdentityUrl ("keystone"); - id.setMemberRole ("member"); - id.setMsoId ("msoId"); - id.setMsoPass (CryptoUtils.encryptCloudConfigPassword("password")); - id.setTenantMetadata (true); - id.setIdentityServerType(null); - id.setIdentityAuthenticationType(null); - - - assertTrue (id.getAdminTenant ().equals ("AdminTenant")); - assertTrue (id.getId ().equals ("id")); -// assertTrue (id.getKeystoneUrl ().equals ("keystone")); - assertTrue (id.getMemberRole ().equals ("member")); - assertTrue (id.getMsoId ().equals ("msoId")); - assertTrue (CryptoUtils.decryptCloudConfigPassword(id.getMsoPass()).equals ("password")); - assertTrue (id.hasTenantMetadata ()); -// assertTrue (id.toString ().contains ("keystone")); - assertTrue(id.toString().contains("null")); - } - - @Test - public final void testEncryption () throws GeneralSecurityException { - String encrypted = CryptoUtils.encryptCloudConfigPassword("password"); - assertTrue (encrypted != null); - assertTrue (!encrypted.equals ("password")); - } - - @Test - public void cloneTest() { - cloudIdentity = setupCloudIdentity(cloudIdentity, ID, IDENTITY_URL, MSO_ID, MSO_PASS, ADMIN_TENANT, - MEMBER_ROLE, TENANT_METADATA, ServerType.ORM, AuthenticationType.USERNAME_PASSWORD); - CloudIdentity cloudIdentity2 = cloudIdentity.clone(); - - assertEquals(cloudIdentity.getClass(), cloudIdentity2.getClass()); - } - - private CloudIdentity setupCloudIdentity(CloudIdentity obj, String id, String identityUrl, - String msoId, String msoPass, String adminTenant, String memberRole, Boolean tenantMetadata, - ServerType identityServerType, AuthenticationType identityAuthenticationType) { - obj.setId(id); - obj.setIdentityUrl(identityUrl); - obj.setMsoId(msoId); - obj.setMsoPass(msoPass); - obj.setAdminTenant(adminTenant); - obj.setMemberRole(memberRole); - obj.setTenantMetadata(tenantMetadata); - obj.setIdentityServerType(identityServerType); - obj.setIdentityAuthenticationType(identityAuthenticationType); - - return obj; - } -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java index 89c15b0deb..096d5dad8b 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java @@ -21,7 +21,9 @@ package org.onap.so.cloud; import org.junit.Test; -import org.onap.so.openpojo.rules.EqualsAndHashCodeTester; +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.openpojo.rules.ToStringTester; import com.openpojo.reflection.PojoClass; @@ -51,7 +53,6 @@ public class CloudPojoTest { .with(new SetterTester()) .with(new GetterTester()) .with(new ToStringTester()) - .with(new EqualsAndHashCodeTester()) .build(); validator.validate(pojoClass); } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudifyManagerTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudifyManagerTest.java deleted file mode 100644 index 9a660b4d40..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudifyManagerTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloud; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -public class CloudifyManagerTest { - - private CloudifyManager cloudifyManager = new CloudifyManager(); - private static final String ID = "testId"; - private static final String CLOUDIFY_URL = "testCloudifyUrl"; - private static final String USERNAME = "testUsername"; - private static final String PASSWORD = "testPassword"; - private static final String VERSION = "testVersion"; - - @Test - public void cloneTest() { - cloudifyManager.setId(ID); - cloudifyManager.setCloudifyUrl(CLOUDIFY_URL); - cloudifyManager.setUsername(USERNAME); - cloudifyManager.setPassword(PASSWORD); - cloudifyManager.setVersion(VERSION); - - CloudifyManager clone = cloudifyManager.clone(); - assertEquals(cloudifyManager, clone); - } -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java index e1c533757b..d676bcab3a 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java @@ -24,11 +24,11 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.so.BaseTest; import org.onap.so.cloud.Application; -import org.onap.so.cloud.AuthenticationType; -import org.onap.so.cloud.CloudIdentity; +import org.onap.so.db.catalog.beans.AuthenticationType; +import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.cloud.authentication.models.RackspaceAuthentication; -import org.onap.so.openstack.exceptions.MsoException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; @@ -43,10 +43,7 @@ import com.woorea.openstack.keystone.model.authentication.UsernamePassword; * only are tested. * */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class) -@ActiveProfiles("test") -public class AuthenticationMethodTest { +public class AuthenticationMethodTest extends BaseTest { @Autowired private AuthenticationMethodFactory authenticationMethodFactory; |