aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication')
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java103
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java68
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java55
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java55
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java44
5 files changed, 0 insertions, 325 deletions
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java
deleted file mode 100644
index 2cfce276d8..0000000000
--- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * ===================================================================
- * 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============================================
- *
- * ECOMP and OpenECOMP are trademarks
- * and service marks of AT&T Intellectual Property.
- *
- */
-
-package org.openecomp.mso.cloud.authentication;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import com.woorea.openstack.keystone.model.Authentication;
-import org.junit.Test;
-import org.openecomp.mso.cloud.CloudIdentity;
-import org.openecomp.mso.cloud.CloudIdentity.IdentityAuthenticationType;
-import org.openecomp.mso.cloud.authentication.wrappers.RackspaceAPIKeyWrapper;
-
-public class AuthenticationMethodFactoryTest {
-
- private static final Class WRAPPER_CLASS = RackspaceAPIKeyWrapper.class;
- private static final String AUTHENTICATION_TYPE = "authenticationTest";
-
- @Test
- public void register_NoExceptionThrown() throws IllegalAccessException, InstantiationException {
- AuthenticationMethodFactory.register(AUTHENTICATION_TYPE, WRAPPER_CLASS);
- }
-
- @Test
- public void register_throwExceptionWhenAuthTypeIsNull() throws InstantiationException, IllegalAccessException {
- try {
- AuthenticationMethodFactory.register(null, WRAPPER_CLASS);
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).isNotEmpty().contains("Authentication Type to register cannot be null "
- + "or an empty name string");
- }
- }
-
- @Test
- public void register_throwExceptionWhenAuthTypeIsEmpty() throws InstantiationException, IllegalAccessException {
- try {
- AuthenticationMethodFactory.register("", WRAPPER_CLASS);
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).isNotEmpty().contains("Authentication Type to register cannot be null "
- + "or an empty name string");
- }
- }
-
- @Test
- public void register_throwExceptionWhenWrapperIsNull() throws IllegalAccessException, InstantiationException {
- try {
- AuthenticationMethodFactory.register(AUTHENTICATION_TYPE, null);
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).isNotEmpty()
- .contains("Wrapper Class to register for Authentication cannot be null");
- }
- }
-
- @Test
- public void getAuthentication_NoExceptionThrown() {
- CloudIdentity cloudIdentity = new CloudIdentity();
- cloudIdentity.setIdentityAuthenticationType(IdentityAuthenticationType.RACKSPACE_APIKEY);
- cloudIdentity.setMsoId("msoIdTest");
- cloudIdentity.setMsoPass("123");
- Authentication result = AuthenticationMethodFactory.getAuthenticationFor(cloudIdentity);
- assertThat(result).isNotNull();
- }
-
- @Test
- public void getAuthentication_ThrowExWhenCloudSiteIsNull() {
- try {
- AuthenticationMethodFactory.getAuthenticationFor(null);
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).isNotEmpty().contains("Cloud identity cannot be null");
- }
- }
-
- @Test
- public void getAuthentication_ThrowExWhenIdentityAuthenticationTypeIsNotSet() {
- try {
- AuthenticationMethodFactory.getAuthenticationFor(new CloudIdentity());
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).isNotEmpty()
- .contains("Cloud identity authentication type cannot be null or empty");
- }
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java
deleted file mode 100644
index b6c1c7373f..0000000000
--- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * ===================================================================
- * 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============================================
- *
- * ECOMP and OpenECOMP are trademarks
- * and service marks of AT&T Intellectual Property.
- *
- */
-
-package org.openecomp.mso.cloud.authentication;
-
-import static org.junit.Assert.assertTrue;
-
-import com.woorea.openstack.keystone.model.Authentication;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-import org.junit.Test;
-import org.openecomp.mso.cloud.CloudIdentity;
-import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication;
-
-/**
- * A few JUnit tests to evaluate the new factory that manages authentication
- * types and their associated wrapper classes. Here it is assumed that core types
- * only are tested.
- *
- */
-public class AuthenticationMethodTest {
-
- /**
- *
- */
- public AuthenticationMethodTest() {
- // TODO Auto-generated constructor stub
- }
-
- @Test
- public void testCustomRackspaceAuthFromCloudIdentity() {
- CloudIdentity ci = new CloudIdentity();
- ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
- ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
- ci.setMsoId("test");
- Authentication auth = ci.getAuthentication();
- assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
- }
-
- @Test
- public void testCoreUsernamePasswordAuthFromCloudIdentity() {
- CloudIdentity ci = new CloudIdentity();
- ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.USERNAME_PASSWORD);
- ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
- ci.setMsoId("someuser");
- Authentication auth = ci.getAuthentication();
- assertTrue(UsernamePassword.class.equals(auth.getClass()));
- }
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java
deleted file mode 100644
index 33f91c641e..0000000000
--- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * ===================================================================
- * 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============================================
- *
- * ECOMP and OpenECOMP are trademarks
- * and service marks of AT&T Intellectual Property.
- *
- */
-
-package org.openecomp.mso.cloud.authentication.wrappers;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import com.woorea.openstack.keystone.model.Authentication;
-import org.junit.Test;
-import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication;
-
-public class RackspaceAPIKeyWrapperTest {
-
- @Test
- public void getAuthenticationSuccessful() {
- RackspaceAPIKeyWrapper testedObject = new RackspaceAPIKeyWrapper();
- Authentication authentication = testedObject.getAuthentication(WrapperTestUtility.createCloudIdentity());
-
- assertThat(authentication).isInstanceOf(RackspaceAuthentication.class);
- RackspaceAuthentication rackspaceAuthentication = (RackspaceAuthentication) authentication;
- assertThat(rackspaceAuthentication.getToken().getUsername())
- .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_ID);
- assertThat(rackspaceAuthentication.getToken().getApiKey())
- .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_PASS);
- }
-
- @Test
- public void getAuthenticationThrowsException() {
- assertThatThrownBy(() -> new RackspaceAPIKeyWrapper().getAuthentication(null))
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessage(WrapperTestUtility.EXCEPTION_MESSAGE);
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java
deleted file mode 100644
index 0cfe287dfe..0000000000
--- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * ===================================================================
- * 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============================================
- *
- * ECOMP and OpenECOMP are trademarks
- * and service marks of AT&T Intellectual Property.
- *
- */
-
-package org.openecomp.mso.cloud.authentication.wrappers;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import com.woorea.openstack.keystone.model.Authentication;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-import org.junit.Test;
-
-public class UsernamePasswordWrapperTest {
-
- @Test
- public void getAuthenticationSuccessful() {
- UsernamePasswordWrapper testedObject = new UsernamePasswordWrapper();
- Authentication authentication = testedObject.getAuthentication(WrapperTestUtility.createCloudIdentity());
-
- assertThat(authentication).isInstanceOf(UsernamePassword.class);
- UsernamePassword usernamePassword = (UsernamePassword) authentication;
- assertThat(usernamePassword.getPasswordCredentials().getUsername())
- .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_ID);
- assertThat(usernamePassword.getPasswordCredentials().getPassword())
- .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_PASS);
- }
-
- @Test
- public void getAuthenticationThrowsException() {
- assertThatThrownBy(() -> new UsernamePasswordWrapper().getAuthentication(null)).
- isInstanceOf(IllegalArgumentException.class).
- hasMessage(WrapperTestUtility.EXCEPTION_MESSAGE);
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java
deleted file mode 100644
index 3cbc48d090..0000000000
--- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * ===================================================================
- * 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============================================
- *
- * ECOMP and OpenECOMP are trademarks
- * and service marks of AT&T Intellectual Property.
- *
- */
-
-package org.openecomp.mso.cloud.authentication.wrappers;
-
-import org.openecomp.mso.cloud.CloudIdentity;
-
-final class WrapperTestUtility {
-
- static final String CLOUD_IDENTITY_MSO_ID = "msoIdTest";
- static final String CLOUD_IDENTITY_MSO_PASS = "msoPassTest";
- static final String EXCEPTION_MESSAGE = "Provided cloud identity is null, cannot extract username and "
- + "password";
-
- private WrapperTestUtility() {
- }
-
- static CloudIdentity createCloudIdentity() {
- CloudIdentity cloudIdentity = new CloudIdentity();
- cloudIdentity.setMsoId(CLOUD_IDENTITY_MSO_ID);
- cloudIdentity.setMsoPass(CloudIdentity.encryptPassword(CLOUD_IDENTITY_MSO_PASS));
- return cloudIdentity;
- }
-}