2 * ============LICENSE_START======================================================================
3 * Copyright (C) 2018-2023 Nordix Foundation. All rights reserved.
4 * Copyright (C) 2021 Nokia. All rights reserved.
5 * ===============================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7 * in compliance with the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software distributed under the License
12 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing permissions and limitations under
15 * ============LICENSE_END========================================================================
17 package org.oran.datafile.http;
19 import static org.junit.jupiter.api.Assertions.assertNotNull;
20 import static org.junit.jupiter.api.Assertions.assertThrows;
22 import org.junit.jupiter.api.Test;
23 import org.junit.jupiter.api.extension.ExtendWith;
24 import org.mockito.junit.jupiter.MockitoExtension;
25 import org.oran.datafile.exceptions.DatafileTaskException;
27 @ExtendWith(MockitoExtension.class)
28 public class HttpsClientConnectionManagerUtilTest {
30 private static final String KEY_PATH = "src/test/resources/keystore.p12";
31 private static final String KEY_PASSWORD = "src/test/resources/keystore.pass";
32 private static final String KEY_IMPROPER_PASSWORD = "src/test/resources/dfc.jks.pass";
33 private static final String TRUSTED_CA_PATH = "src/test/resources/trust.jks";
34 private static final String TRUSTED_CA_PASSWORD = "src/test/resources/trust.pass";
37 public void emptyManager_shouldThrowException() {
38 assertThrows(DatafileTaskException.class, () -> HttpsClientConnectionManagerUtil.instance());
42 public void creatingManager_successfulCase() throws Exception {
43 HttpsClientConnectionManagerUtil.setupOrUpdate(KEY_PATH, KEY_PASSWORD, TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD, //
45 assertNotNull(HttpsClientConnectionManagerUtil.instance());
49 public void creatingManager_improperSecretShouldThrowException() {
50 assertThrows(DatafileTaskException.class, () -> HttpsClientConnectionManagerUtil.setupOrUpdate(KEY_PATH, //
51 KEY_IMPROPER_PASSWORD, TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD, true));
52 assertThrows(DatafileTaskException.class, () -> HttpsClientConnectionManagerUtil.instance());