86b12ae8f6b61c276e6b4adfa82d257c74b81058
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (c) 2019 Samsung. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.so.apihandler.common;
21
22 import org.junit.Assert;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.mockito.Mockito;
27 import org.mockito.junit.MockitoJUnitRunner;
28
29 @RunWith(MockitoJUnitRunner.class)
30 public class RequestClientTest {
31
32     private static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f";
33
34     private RequestClient requestClient;
35
36     @Before
37     public void init() {
38         requestClient = Mockito.mock(RequestClient.class, Mockito.CALLS_REAL_METHODS);
39     }
40
41     @Test
42     public void getEncryptedPropValueWithSuccess() {
43
44         String encryptedValue = requestClient.getEncryptedPropValue(
45                 "E8E19DD16CC90D2E458E8FF9A884CC0452F8F3EB8E321F96038DE38D5C1B0B02DFAE00B88E2CF6E2A4101AB2C011FC161212EE",
46                 "defaultValue", ENCRYPTION_KEY);
47
48         Assert.assertEquals("apihBpmn:camunda-R1512!", encryptedValue);
49     }
50
51     @Test
52     public void getDefaultEncryptedPropValue() {
53
54         String encryptedValue =
55                 requestClient.getEncryptedPropValue("012345678901234567890123456789", "defaultValue", ENCRYPTION_KEY);
56
57         Assert.assertEquals("defaultValue", encryptedValue);
58     }
59
60 }