2 * ============LICENSE_START=======================================================
\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
13 * http://www.apache.org/licenses/LICENSE-2.0
\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
21 * ============LICENSE_END=========================================================
\r
24 package org.onap.appc.ccadaptor;
\r
26 import static org.junit.Assert.assertEquals;
\r
28 import org.junit.BeforeClass;
\r
29 import org.junit.Test;
\r
31 public class EncryptionToolTest {
\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
37 private static EncryptionTool encryptionTool;
\r
40 public static void setup() {
\r
41 encryptionTool = EncryptionTool.getInstance();
\r
45 public void should_return_null_when_given_null_to_encrypt() {
\r
46 assertEquals(null, encryptionTool.encrypt(null));
\r
50 public void should_encrypt_given_string() {
\r
51 assertEquals(ENCRYPTED_TEXT, encryptionTool.encrypt(PLAIN_TEXT));
\r
55 public void should_return_null_when_given_null_to_decrypt() {
\r
56 assertEquals(null, encryptionTool.decrypt(null));
\r
60 public void should_return_same_string_when_given_unencrypted_string() {
\r
61 assertEquals(FAKE_ENCRYPTED_TEXT, encryptionTool.decrypt(FAKE_ENCRYPTED_TEXT));
\r
65 public void should_decrypt_given_string() {
\r
66 assertEquals(PLAIN_TEXT, encryptionTool.decrypt(ENCRYPTED_TEXT));
\r