2 * Copyright © 2019 Bell Canada
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.cds.sdclistener;
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertFalse;
22 import org.junit.Rule;
23 import org.junit.Test;
24 import org.junit.contrib.java.lang.system.EnvironmentVariables;
25 import org.junit.runner.RunWith;
26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.boot.context.properties.EnableConfigurationProperties;
28 import org.springframework.boot.test.context.SpringBootTest;
29 import org.springframework.test.context.junit4.SpringRunner;
31 @RunWith(SpringRunner.class)
32 @EnableConfigurationProperties(SdcListenerConfiguration.class)
33 @SpringBootTest(classes = {SdcListenerConfigurationTest.class})
34 public class SdcListenerConfigurationTest {
37 public EnvironmentVariables environmentVariables = new EnvironmentVariables();
40 private SdcListenerConfiguration listenerConfiguration;
43 public void testCdsSdcListenerConfiguration() {
44 environmentVariables.set("SASL_JAAS_CONFIG",
45 "org.apache.kafka.common.security.scram.ScramLoginModule required username=admin password=admin-secret;");
46 assertEquals("localhost:8443", listenerConfiguration.getSdcAddress());
48 "org.apache.kafka.common.security.scram.ScramLoginModule required username=admin password=admin-secret;",
49 listenerConfiguration.getKafkaSaslJaasConfig());
50 assertEquals("cds", listenerConfiguration.getUser());
51 assertEquals("Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U", listenerConfiguration.getPassword());
52 assertEquals(15, listenerConfiguration.getPollingInterval());
53 assertEquals(60, listenerConfiguration.getPollingTimeout());
54 assertEquals("TOSCA_CSAR", listenerConfiguration.getRelevantArtifactTypes().stream().findFirst().get());
55 assertEquals("cds-id-local", listenerConfiguration.getConsumerGroup());
56 assertEquals("AUTO", listenerConfiguration.getEnvironmentName());
57 assertEquals("cds-id-local", listenerConfiguration.getConsumerID());
58 assertFalse(listenerConfiguration.activateServerTLSAuth());
59 assertEquals(true, listenerConfiguration.isUseHttpsWithSDC());