aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/test/java/org
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-02-22 10:25:39 +0100
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-02-23 12:10:04 +0100
commite35347d6521133807e92f397820fa18a5412aee7 (patch)
tree645178cbc2f46787140ce1d8ef469a9ab4d5bd4a /adapters/mso-adapter-utils/src/test/java/org
parent077d14997f5663e570948a0c497e8fae80a0f5d5 (diff)
add junit for cloud wrappers
Change-Id: I699b10ee2cb6e8b57ca56e8a9baae8aa41000540 Issue-ID: SO-430 Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src/test/java/org')
-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
3 files changed, 154 insertions, 0 deletions
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
new file mode 100644
index 0000000000..33f91c641e
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java
@@ -0,0 +1,55 @@
+/*
+ * ============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
new file mode 100644
index 0000000000..0cfe287dfe
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java
@@ -0,0 +1,55 @@
+/*
+ * ============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
new file mode 100644
index 0000000000..3cbc48d090
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java
@@ -0,0 +1,44 @@
+/*
+ * ============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;
+ }
+}