Changed to unmaintained
[appc.git] / appc-config / appc-config-adaptor / provider / src / test / java / org / onap / appc / ccadaptor / EncryptionToolTest.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP : APPC\r
4  * ================================================================================\r
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Copyright (C) 2017 Amdocs\r
8  * =============================================================================\r
9  * Licensed under the Apache License, Version 2.0 (the "License");\r
10  * you may not use this file except in compliance with the License.\r
11  * You may obtain a copy of the License at\r
12  * \r
13  *      http://www.apache.org/licenses/LICENSE-2.0\r
14  * \r
15  * Unless required by applicable law or agreed to in writing, software\r
16  * distributed under the License is distributed on an "AS IS" BASIS,\r
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
18  * See the License for the specific language governing permissions and\r
19  * limitations under the License.\r
20  * \r
21  * ============LICENSE_END=========================================================\r
22  */\r
23 \r
24 package org.onap.appc.ccadaptor;\r
25 \r
26 import static org.junit.Assert.assertEquals;\r
27 \r
28 import org.junit.BeforeClass;\r
29 import org.junit.Test;\r
30 \r
31 public class EncryptionToolTest {\r
32 \r
33     private static final String PLAIN_TEXT = "encrypt";\r
34     private static final String ENCRYPTED_TEXT = "enc:JjEZHlg7VQ==";\r
35     private static final String FAKE_ENCRYPTED_TEXT = "jsaASGou!na=e";\r
36 \r
37     private static EncryptionTool encryptionTool;\r
38 \r
39     @BeforeClass\r
40     public static void setup() {\r
41         encryptionTool = EncryptionTool.getInstance();\r
42     }\r
43 \r
44     @Test\r
45     public void should_return_null_when_given_null_to_encrypt() {\r
46         assertEquals(null, encryptionTool.encrypt(null));\r
47     }\r
48 \r
49     @Test\r
50     public void should_encrypt_given_string() {\r
51         assertEquals(ENCRYPTED_TEXT, encryptionTool.encrypt(PLAIN_TEXT));\r
52     }\r
53 \r
54     @Test\r
55     public void should_return_null_when_given_null_to_decrypt() {\r
56         assertEquals(null, encryptionTool.decrypt(null));\r
57     }\r
58 \r
59     @Test\r
60     public void should_return_same_string_when_given_unencrypted_string() {\r
61         assertEquals(FAKE_ENCRYPTED_TEXT, encryptionTool.decrypt(FAKE_ENCRYPTED_TEXT));\r
62     }\r
63 \r
64     @Test\r
65     public void should_decrypt_given_string() {\r
66         assertEquals(PLAIN_TEXT, encryptionTool.decrypt(ENCRYPTED_TEXT));\r
67     }\r
68 }