diff options
Diffstat (limited to 'datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java')
-rw-r--r-- | datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java index 839a9a18..3c940297 100644 --- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java +++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START====================================================================== - * Copyright (C) 2018, 2020-2021 NOKIA Intellectual Property, 2018-2019 Nordix Foundation. - * All rights reserved. + * Copyright (C) 2018, 2020-2022 Nokia. All rights reserved. + * Copyright (C) 2018-2019 Nordix Foundation. 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. You may obtain a copy of the License at @@ -91,6 +91,7 @@ class AppConfigTest { .trustedCa("/src/test/resources/cert.jks") // .trustedCaPasswordPath("/src/test/resources/cert.jks.pass") // .httpsHostnameVerify(true) + .enableCertAuth(true) .build(); private AppConfig appConfigUnderTest; @@ -129,6 +130,19 @@ class AppConfigTest { } @Test + void shouldInitializeApplicationWithoutCertificates() throws IOException { + // When + doReturn(getCorrectConfigWithoutTLS()).when(appConfigUnderTest).createInputStream(any()); + appConfigUnderTest.initialize(); + + // Then + verify(appConfigUnderTest, times(1)).loadConfigurationFromFile(); + + CertificateConfig certificateConfig = appConfigUnderTest.getCertificateConfiguration(); + assertThat(certificateConfig).isNotNull(); + } + + @Test void whenTheConfigurationFits_twoProducers() throws IOException, DatafileTaskException { // When doReturn(getCorrectJsonTwoProducers()).when(appConfigUnderTest).createInputStream(any()); @@ -293,6 +307,12 @@ class AppConfigTest { return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8))); } + private static InputStream getCorrectConfigWithoutTLS() throws IOException { + URL url = CloudConfigParser.class.getClassLoader().getResource("datafile_test_config_no_tls.json"); + String string = Resources.toString(url, Charsets.UTF_8); + return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8))); + } + private static InputStream getCorrectJsonTwoProducers() throws IOException { URL url = CloudConfigParser.class.getClassLoader().getResource("datafile_endpoints_test_2producers.json"); String string = Resources.toString(url, Charsets.UTF_8); |