summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/dcaegen2/services/pmmapper/App.java9
-rw-r--r--src/main/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandler.java6
-rw-r--r--src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/MapperConfigException.java5
-rw-r--r--src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java9
-rw-r--r--src/main/java/org/onap/dcaegen2/services/pmmapper/model/PublisherConfig.java4
-rw-r--r--src/main/java/org/onap/dcaegen2/services/pmmapper/model/SubscriberConfig.java5
-rw-r--r--src/main/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactory.java35
-rw-r--r--src/main/java/org/onap/dcaegen2/services/pmmapper/utils/DmaapRequestSender.java20
-rw-r--r--src/test/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandlerTests.java20
-rw-r--r--src/test/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactoryTest.java83
-rw-r--r--src/test/resources/missing_optional_fields/null_aaf_identity.json (renamed from src/test/resources/invalid_configs/null_aaf_identity.json)2
-rw-r--r--src/test/resources/missing_optional_fields/null_aaf_password.json (renamed from src/test/resources/invalid_configs/null_aaf_password.json)2
-rw-r--r--src/test/resources/missing_optional_fields/null_client_role.json (renamed from src/test/resources/invalid_configs/null_client_role.json)2
-rw-r--r--src/test/resources/missing_optional_fields/null_dr_location.json (renamed from src/test/resources/invalid_configs/null_dr_location.json)2
-rw-r--r--src/test/resources/missing_optional_fields/null_dr_password.json (renamed from src/test/resources/invalid_configs/null_dr_password.json)2
-rw-r--r--src/test/resources/missing_optional_fields/null_dr_username.json (renamed from src/test/resources/invalid_configs/null_dr_username.json)2
-rw-r--r--src/test/resources/missing_optional_fields/null_key_store_pass_path.json (renamed from src/test/resources/invalid_configs/null_key_store_pass_path.json)2
-rw-r--r--src/test/resources/missing_optional_fields/null_key_store_path.json (renamed from src/test/resources/invalid_configs/null_key_store_path.json)2
-rw-r--r--src/test/resources/missing_optional_fields/null_location.json (renamed from src/test/resources/invalid_configs/null_location.json)2
-rw-r--r--src/test/resources/missing_optional_fields/null_trust_store_pass_path.json (renamed from src/test/resources/invalid_configs/null_trust_store_pass_path.json)2
-rw-r--r--src/test/resources/missing_optional_fields/null_trust_store_path.json (renamed from src/test/resources/invalid_configs/null_trust_store_path.json)2
21 files changed, 174 insertions, 44 deletions
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java
index 0da2b7e..0c49a96 100644
--- a/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java
+++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
- * Copyright (C) 2021-2022 Nokia.
+ * Copyright (C) 2021-2022 Nokia. All rights reserved.
* Copyright (C) 2021 Samsung Electronics.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -169,7 +169,7 @@ public class App {
this.serverResources = Arrays.asList(healthCheckHandler, deliveryHandler, dynamicConfiguration);
try {
this.applicationServer = server(this.mapperConfig, this.serverResources);
- } catch (IOException e) {
+ } catch (IOException | MapperConfigException e ) {
logger.unwrap().error("Failed to create server instance.", e);
throw new IllegalStateException("Server instantiation failed");
}
@@ -194,7 +194,10 @@ public class App {
private Undertow server(MapperConfig config, List<ServerResource> serverResources) throws IOException {
SSLContextFactory sslContextFactory = new SSLContextFactory(config);
SSLContext sslContext = sslContextFactory.createSSLContext(config);
- SSLContext.setDefault(sslContext);
+ if (sslContext != null) {
+ SSLContext.setDefault(sslContext);
+ logger.unwrap().info("SSL Context loaded");
+ }
Undertow.Builder builder = Undertow.builder();
if (config.getEnableHttp()) {
builder.addHttpListener(this.httpPort, "0.0.0.0");
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandler.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandler.java
index 6c93d2f..ff28634 100644
--- a/src/main/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandler.java
+++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandler.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Copyright (C) 2022 Nokia.
+ * Copyright (C) 2022 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -102,8 +102,8 @@ public class ConfigHandler {
.create()
.fromJson(jsonObject, MapperConfig.class);
} catch (Exception exception) {
- String exceptionMessage = "Error parsing configuration, mapper config:\n" + mapperConfig;
- logger.unwrap().error(exceptionMessage);
+ String exceptionMessage = "Error parsing configuration, mapper config: " + mapperConfig;
+ logger.unwrap().error("Error parsing configuration", exception);
throw new MapperConfigException(exceptionMessage, exception);
}
logger.unwrap().info("PM-mapper configuration processed successful");
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/MapperConfigException.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/MapperConfigException.java
index 4669871..56e2d23 100644
--- a/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/MapperConfigException.java
+++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/MapperConfigException.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2022 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,4 +24,8 @@ public class MapperConfigException extends RuntimeException {
public MapperConfigException(String message, Throwable cause) {
super(message, cause);
}
+
+ public MapperConfigException(String message) {
+ super(message);
+ }
}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java
index a71696b..18b9388 100644
--- a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java
+++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2022 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,19 +42,15 @@ public class MapperConfig implements Configurable {
@SerializedName("enable_http")
private Boolean enableHttp;
- @GSONRequired
@SerializedName("key_store_path")
private String keyStorePath;
- @GSONRequired
@SerializedName("key_store_pass_path")
private String keyStorePassPath;
- @GSONRequired
@SerializedName("trust_store_path")
private String trustStorePath;
- @GSONRequired
@SerializedName("trust_store_pass_path")
private String trustStorePassPath;
@@ -66,11 +63,9 @@ public class MapperConfig implements Configurable {
@JsonAdapter(MeasFilterConfigAdapter.class)
private MeasFilterConfig filterConfig;
- @GSONRequired
@SerializedName("aaf_identity")
private String aafUsername;
- @GSONRequired
@SerializedName("aaf_password")
private String aafPassword;
@@ -127,4 +122,4 @@ public class MapperConfig implements Configurable {
", publisherConfig=" + publisherConfig +
'}';
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/PublisherConfig.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/PublisherConfig.java
index 16ab941..4b0cdac 100644
--- a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/PublisherConfig.java
+++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/PublisherConfig.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2022 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,15 +31,12 @@ public class PublisherConfig {
@SerializedName("topic_url")
private String topicUrl;
- @GSONRequired
@SerializedName("client_role")
private String clientRole;
- @GSONRequired
@SerializedName("client_id")
private String clientId;
- @GSONRequired
@SerializedName("location")
private String clusterLocation;
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/SubscriberConfig.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/SubscriberConfig.java
index c53d36d..89cc243 100644
--- a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/SubscriberConfig.java
+++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/SubscriberConfig.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2022 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,15 +27,13 @@ import org.onap.dcaegen2.services.pmmapper.utils.GSONRequired;
@Data
public class SubscriberConfig {
- @GSONRequired
+
@SerializedName("username")
private String username;
- @GSONRequired
@SerializedName("password")
private String password;
- @GSONRequired
@SerializedName("location")
private String drLocation;
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactory.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactory.java
index e7c317d..007ba86 100644
--- a/src/main/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactory.java
+++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactory.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
* Copyright (C) 2021 Samsung Electronics.
+ * Copyright (C) 2022 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@ package org.onap.dcaegen2.services.pmmapper.ssl;
import org.onap.dcaegen2.services.pmmapper.exceptions.CreateContextException;
import org.onap.dcaegen2.services.pmmapper.exceptions.KeyManagerException;
import org.onap.dcaegen2.services.pmmapper.exceptions.LoadKeyStoreException;
+import org.onap.dcaegen2.services.pmmapper.exceptions.MapperConfigException;
import org.onap.dcaegen2.services.pmmapper.exceptions.TrustManagerException;
import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;
import org.onap.logging.ref.slf4j.ONAPLogAdapter;
@@ -48,14 +50,18 @@ import static java.nio.file.Files.readAllBytes;
public class SSLContextFactory {
private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(SSLContextFactory.class));
- private MapperConfig mapperConfig;
+ private final MapperConfig mapperConfig;
public SSLContextFactory(MapperConfig config) {
mapperConfig = config;
}
public SSLContext createSSLContext(MapperConfig mapperConfig) throws IOException {
- SSLContext sslContext = null;
+ logger.unwrap().info("Attempt to Create SSL Context");
+ if (isSslDisabled(mapperConfig)) {
+ logger.unwrap().warn("SSL is disabled. Skip creating SSL Context");
+ return null;
+ }
try {
KeyStore keyStore = loadKeyStore(mapperConfig.getKeyStorePath(), mapperConfig.getKeyStorePassPath());
@@ -64,15 +70,36 @@ public class SSLContextFactory {
KeyStore trustStore = loadKeyStore(mapperConfig.getTrustStorePath(), mapperConfig.getTrustStorePassPath());
TrustManager[] trustManagers = createTrustManager(trustStore);
- sslContext = SSLContext.getInstance("TLSv1.2");
+ SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(keyManagers, trustManagers, null);
+ return sslContext;
} catch(KeyManagementException | NoSuchAlgorithmException e) {
logger.unwrap().error("Failed to create SSL Context.", e);
throw new CreateContextException("Failed to create SSL Context", e);
}
- return sslContext;
}
+ private boolean isSslDisabled(MapperConfig mapperConfig) {
+ boolean isCertPathMissing = !areCertPathsConfigured(mapperConfig);
+ if (isCertPathMissing && !mapperConfig.getEnableHttp()) {
+ throw new MapperConfigException("Certificate paths are missing, HTTP is disabled. Not allowed configuration");
+ }
+
+ return isCertPathMissing;
+ }
+
+ private boolean areCertPathsConfigured(MapperConfig mapperConfig) {
+ return isNotBlank(mapperConfig.getKeyStorePath()) &&
+ isNotBlank(mapperConfig.getKeyStorePassPath()) &&
+ isNotBlank(mapperConfig.getTrustStorePath()) &&
+ isNotBlank(mapperConfig.getTrustStorePassPath());
+ }
+
+ private boolean isNotBlank(String str) {
+ return str != null && !str.isEmpty();
+ }
+
+
private KeyManager[] createKeyManager(KeyStore keyStore) throws NoSuchAlgorithmException, IOException {
KeyManager[] keyManager;
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/DmaapRequestSender.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/DmaapRequestSender.java
index 1a7c59e..e7898af 100644
--- a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/DmaapRequestSender.java
+++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/DmaapRequestSender.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nokia.
+ * Copyright (C) 2021-2022 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import com.google.gson.JsonParser;
import io.vavr.control.Try;
import org.onap.dcaegen2.services.sdk.model.streams.AafCredentials;
import org.onap.dcaegen2.services.sdk.model.streams.dmaap.ImmutableMessageRouterSink;
+import org.onap.dcaegen2.services.sdk.model.streams.dmaap.ImmutableMessageRouterSink.Builder;
import org.onap.dcaegen2.services.sdk.model.streams.dmaap.MessageRouterSink;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.ContentType;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory;
@@ -88,10 +89,19 @@ public class DmaapRequestSender {
}
private static MessageRouterSink sink(String topicUrl, AafCredentials credentials) {
- return ImmutableMessageRouterSink.builder()
- .aafCredentials(credentials)
- .topicUrl(topicUrl)
- .build();
+ Builder builder = ImmutableMessageRouterSink.builder();
+ if (credentialsExists(credentials)) {
+ builder.aafCredentials(credentials);
+ }
+ return builder.topicUrl(topicUrl).build();
+ }
+
+ private static boolean credentialsExists(AafCredentials credentials) {
+ return isNotBlank(credentials.username()) && isNotBlank(credentials.password());
+ }
+
+ private static boolean isNotBlank(String str) {
+ return str != null && !str.isEmpty();
}
private static RequestDiagnosticContext diagnosticContext() {
diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandlerTests.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandlerTests.java
index a1538ee..d007123 100644
--- a/src/test/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandlerTests.java
+++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandlerTests.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Copyright (C) 2022 Nokia.
+ * Copyright (C) 2022 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
*/
package org.onap.dcaegen2.services.pmmapper.config;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
@@ -62,6 +63,8 @@ class ConfigHandlerTests {
private static String validMapperConfigChanged;
private static final Path INVALID_CONFIGS_DIRECTORY = Paths.get("src/test/resources/invalid_configs/");
+ private static final Path MISSING_OPTIONAL_FIELDS_CONFIGS_DIRECTORY =
+ Paths.get("src/test/resources/missing_optional_fields/");
private static final String EXPECTED_ERROR_MESSAGE_IN_LOG = "Error parsing configuration";
private static final String EXPECTED_CHANGED_VALUE = "https://dmaap-dr-node:8443/delete_changed";
@@ -142,6 +145,17 @@ class ConfigHandlerTests {
}
@ParameterizedTest
+ @MethodSource("getConfigsWithMissingOptionalFields")
+ void should_parse_json_with_missing_optional_fields(String mapperConfig) {
+ Mono<JsonObject> just = createMonoJsonObject(mapperConfig);
+
+ when(cbsClient.get(any())).thenReturn(just);
+ ConfigHandler configHandler = new ConfigHandler(cbsClient, cbsRequest);
+
+ assertDoesNotThrow(configHandler::getInitialConfiguration);
+ }
+
+ @ParameterizedTest
@MethodSource("getInvalidConfigs")
void parse_valid_json_bad_values_mapper_config(String mapperConfig) throws Exception {
Mono<JsonObject> just = createMonoJsonObject(mapperConfig);
@@ -169,4 +183,8 @@ class ConfigHandlerTests {
private static List<String> getInvalidConfigs() throws IOException {
return FileUtils.getFilesFromDirectory(INVALID_CONFIGS_DIRECTORY);
}
+
+ private static List<String> getConfigsWithMissingOptionalFields() throws IOException {
+ return FileUtils.getFilesFromDirectory(MISSING_OPTIONAL_FIELDS_CONFIGS_DIRECTORY);
+ }
}
diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactoryTest.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactoryTest.java
index 6f5cee9..747715c 100644
--- a/src/test/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactoryTest.java
+++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactoryTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2022 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,28 +24,39 @@ package org.onap.dcaegen2.services.pmmapper.ssl;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+import java.util.ArrayList;
+import java.util.List;
+import javax.net.ssl.SSLContext;
import org.junit.Rule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.junit.rules.ExpectedException;
+
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.mockito.junit.jupiter.MockitoExtension;
+import org.onap.dcaegen2.services.pmmapper.exceptions.MapperConfigException;
import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;
-import javax.net.ssl.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
public class SSLContextFactoryTest {
+ private static final String TEST_PATH = "";
+
@Rule
public ExpectedException exception = ExpectedException.none();
@@ -52,7 +64,6 @@ public class SSLContextFactoryTest {
private static MapperConfig validConfig;
private static MapperConfig inValidConfig;
-
private static final Path validConfigPath = Paths.get("src/test/resources/valid_mapper_config.json");
private SSLContextFactory objUnderTest;
@@ -81,4 +92,68 @@ public class SSLContextFactoryTest {
assertThrows(IOException.class, () -> objUnderTest.createSSLContext(inValidConfig));
}
-} \ No newline at end of file
+
+ @Test
+ void shouldThrowExceptionWhenCertPathAreMissingButHttpIsDisabled() {
+ MapperConfig mapperConfig = mock(MapperConfig.class);
+ when(mapperConfig.getKeyStorePath()).thenReturn(TEST_PATH);
+ when(mapperConfig.getEnableHttp()).thenReturn(false);
+
+ SSLContextFactory sslContextFactory = new SSLContextFactory(mapperConfig);
+
+ assertThrows(MapperConfigException.class, () -> sslContextFactory.createSSLContext(mapperConfig));
+ }
+
+
+ @ParameterizedTest
+ @MethodSource("pathsAreNull")
+ void shouldReturnNullWhenOneCertPathIsNull(MapperConfig mapperConfig) throws IOException {
+ SSLContextFactory sslContextFactory = new SSLContextFactory(mapperConfig);
+ SSLContext sslContext = sslContextFactory.createSSLContext(mapperConfig);
+
+ assertNull(sslContext);
+ }
+
+ @ParameterizedTest
+ @MethodSource("pathsAreEmpty")
+ void shouldReturnNullWhenOneCertPathIsEmpty(MapperConfig mapperConfig) throws IOException {
+ SSLContextFactory sslContextFactory = new SSLContextFactory(mapperConfig);
+ SSLContext sslContext = sslContextFactory.createSSLContext(mapperConfig);
+
+ assertNull(sslContext);
+ }
+
+ private static List<MapperConfig> pathsAreNull() {
+ return mockMapperConfigList(null);
+ }
+
+ private static List<MapperConfig> pathsAreEmpty() {
+ return mockMapperConfigList("");
+ }
+
+ private static List<MapperConfig> mockMapperConfigList(String returnValue) {
+ List<MapperConfig> mapperConfigList = new ArrayList<>();
+
+ MapperConfig mapperConfig1 = mock(MapperConfig.class);
+ when(mapperConfig1.getKeyStorePath()).thenReturn(returnValue);
+ when(mapperConfig1.getEnableHttp()).thenReturn(true);
+ mapperConfigList.add(mapperConfig1);
+
+ MapperConfig mapperConfig2 = mock(MapperConfig.class);
+ when(mapperConfig2.getKeyStorePassPath()).thenReturn(returnValue);
+ when(mapperConfig2.getEnableHttp()).thenReturn(true);
+ mapperConfigList.add(mapperConfig2);
+
+ MapperConfig mapperConfig3 = mock(MapperConfig.class);
+ when(mapperConfig3.getTrustStorePath()).thenReturn(returnValue);
+ when(mapperConfig3.getEnableHttp()).thenReturn(true);
+ mapperConfigList.add(mapperConfig3);
+
+ MapperConfig mapperConfig4 = mock(MapperConfig.class);
+ when(mapperConfig4.getTrustStorePassPath()).thenReturn(returnValue);
+ when(mapperConfig4.getEnableHttp()).thenReturn(true);
+ mapperConfigList.add(mapperConfig4);
+
+ return mapperConfigList;
+ }
+}
diff --git a/src/test/resources/invalid_configs/null_aaf_identity.json b/src/test/resources/missing_optional_fields/null_aaf_identity.json
index f0a6940..8b2cde1 100644
--- a/src/test/resources/invalid_configs/null_aaf_identity.json
+++ b/src/test/resources/missing_optional_fields/null_aaf_identity.json
@@ -44,4 +44,4 @@
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/test/resources/invalid_configs/null_aaf_password.json b/src/test/resources/missing_optional_fields/null_aaf_password.json
index f4fdba9..77979d7 100644
--- a/src/test/resources/invalid_configs/null_aaf_password.json
+++ b/src/test/resources/missing_optional_fields/null_aaf_password.json
@@ -44,4 +44,4 @@
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/test/resources/invalid_configs/null_client_role.json b/src/test/resources/missing_optional_fields/null_client_role.json
index ae17a1d..6c2c4ef 100644
--- a/src/test/resources/invalid_configs/null_client_role.json
+++ b/src/test/resources/missing_optional_fields/null_client_role.json
@@ -44,4 +44,4 @@
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/test/resources/invalid_configs/null_dr_location.json b/src/test/resources/missing_optional_fields/null_dr_location.json
index 534ff4e..6f3f699 100644
--- a/src/test/resources/invalid_configs/null_dr_location.json
+++ b/src/test/resources/missing_optional_fields/null_dr_location.json
@@ -44,4 +44,4 @@
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/test/resources/invalid_configs/null_dr_password.json b/src/test/resources/missing_optional_fields/null_dr_password.json
index e2f0f22..e2730ea 100644
--- a/src/test/resources/invalid_configs/null_dr_password.json
+++ b/src/test/resources/missing_optional_fields/null_dr_password.json
@@ -44,4 +44,4 @@
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/test/resources/invalid_configs/null_dr_username.json b/src/test/resources/missing_optional_fields/null_dr_username.json
index 9f5b384..0a58a10 100644
--- a/src/test/resources/invalid_configs/null_dr_username.json
+++ b/src/test/resources/missing_optional_fields/null_dr_username.json
@@ -44,4 +44,4 @@
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/test/resources/invalid_configs/null_key_store_pass_path.json b/src/test/resources/missing_optional_fields/null_key_store_pass_path.json
index 94825f3..385f8f7 100644
--- a/src/test/resources/invalid_configs/null_key_store_pass_path.json
+++ b/src/test/resources/missing_optional_fields/null_key_store_pass_path.json
@@ -44,4 +44,4 @@
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/test/resources/invalid_configs/null_key_store_path.json b/src/test/resources/missing_optional_fields/null_key_store_path.json
index 945ec2a..eb2584a 100644
--- a/src/test/resources/invalid_configs/null_key_store_path.json
+++ b/src/test/resources/missing_optional_fields/null_key_store_path.json
@@ -44,4 +44,4 @@
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/test/resources/invalid_configs/null_location.json b/src/test/resources/missing_optional_fields/null_location.json
index 2f31be1..69b0a4f 100644
--- a/src/test/resources/invalid_configs/null_location.json
+++ b/src/test/resources/missing_optional_fields/null_location.json
@@ -44,4 +44,4 @@
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/test/resources/invalid_configs/null_trust_store_pass_path.json b/src/test/resources/missing_optional_fields/null_trust_store_pass_path.json
index 5ed846a..cc66354 100644
--- a/src/test/resources/invalid_configs/null_trust_store_pass_path.json
+++ b/src/test/resources/missing_optional_fields/null_trust_store_pass_path.json
@@ -44,4 +44,4 @@
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/test/resources/invalid_configs/null_trust_store_path.json b/src/test/resources/missing_optional_fields/null_trust_store_path.json
index 0c0f825..bb546cc 100644
--- a/src/test/resources/invalid_configs/null_trust_store_path.json
+++ b/src/test/resources/missing_optional_fields/null_trust_store_path.json
@@ -44,4 +44,4 @@
}
}
}
-} \ No newline at end of file
+}