aboutsummaryrefslogtreecommitdiffstats
path: root/appc-config/appc-config-adaptor/provider
diff options
context:
space:
mode:
Diffstat (limited to 'appc-config/appc-config-adaptor/provider')
-rw-r--r--appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/EncryptionToolTest.java53
1 files changed, 38 insertions, 15 deletions
diff --git a/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/EncryptionToolTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/EncryptionToolTest.java
index afa9137db..00e036ce3 100644
--- a/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/EncryptionToolTest.java
+++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/EncryptionToolTest.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,29 +18,52 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
package org.onap.appc.ccadaptor;
-import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.BeforeClass;
import org.junit.Test;
public class EncryptionToolTest {
+ private static final String PLAIN_TEXT = "encrypt";
+ private static final String ENCRYPTED_TEXT = "enc:JjEZHlg7VQ==";
+ private static final String FAKE_ENCRYPTED_TEXT = "jsaASGou!na=e";
+
+ private static EncryptionTool encryptionTool;
+
+ @BeforeClass
+ public static void setup() {
+ encryptionTool = EncryptionTool.getInstance();
+ }
+
@Test
- public void testEncrypt() {
- EncryptionTool tool = EncryptionTool.getInstance();
- String value = tool.encrypt("encrypt");
- Assert.assertEquals("enc:JjEZHlg7VQ==", value);
+ public void should_return_null_when_given_null_to_encrypt() {
+ assertEquals(null, encryptionTool.encrypt(null));
}
@Test
- public void testDecrypt() {
- EncryptionTool tool = EncryptionTool.getInstance();
- String value = tool.decrypt("enc:JjEZHlg7VQ==");
- Assert.assertEquals("encrypt", value);
+ public void should_encrypt_given_string() {
+ assertEquals(ENCRYPTED_TEXT, encryptionTool.encrypt(PLAIN_TEXT));
}
+ @Test
+ public void should_return_null_when_given_null_to_decrypt() {
+ assertEquals(null, encryptionTool.decrypt(null));
+ }
+
+ @Test
+ public void should_return_same_string_when_given_unencrypted_string() {
+ assertEquals(FAKE_ENCRYPTED_TEXT, encryptionTool.decrypt(FAKE_ENCRYPTED_TEXT));
+ }
+
+ @Test
+ public void should_decrypt_given_string() {
+ assertEquals(PLAIN_TEXT, encryptionTool.decrypt(ENCRYPTED_TEXT));
+ }
} \ No newline at end of file