diff options
author | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2024-03-17 13:27:34 +0530 |
---|---|---|
committer | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2024-03-17 13:29:04 +0530 |
commit | 131aff9fbf61f17f43289013be639c764609be98 (patch) | |
tree | 5425e4e425c0e5026b533801918d05ff817576b3 /sdnr/wt/mountpoint-registrar/provider/src/test | |
parent | c1a053e3bcaeb3006b822e98b80c564c330e2bf3 (diff) |
Kafka Admin client to use authentication properties
Supports SCRAM-SHA-512
Issue-ID: CCSDK-3998
Change-Id: I7c03d62a596e3a34834dec7933ce4192db48c952
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/mountpoint-registrar/provider/src/test')
5 files changed, 50 insertions, 34 deletions
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/TestStrimziKafkaConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/TestStrimziKafkaConfig.java index b3546ea06..a843cc299 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/TestStrimziKafkaConfig.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/config/TestStrimziKafkaConfig.java @@ -23,8 +23,6 @@ import com.google.common.io.Files; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; -import org.junit.After; -import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config.StrimziKafkaConfig; @@ -40,27 +38,31 @@ public class TestStrimziKafkaConfig { + ""; // @formatter:on - private ConfigurationFileRepresentation cfg; + private StrimziKafkaConfig sKafkaCfg; private static final String CONFIGURATIONFILE = "test2.properties"; - @Test - public void test() { - try { - Files.asCharSink(new File(CONFIGURATIONFILE), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); - cfg = new ConfigurationFileRepresentation(CONFIGURATIONFILE); - StrimziKafkaConfig sKafkaCfg = new StrimziKafkaConfig(cfg); - assertEquals("strimzi-kafka", sKafkaCfg.getSectionName()); - assertEquals("onap-strimzi-kafka-0:9094,onap-strimzi-kafka-1:9094", sKafkaCfg.getBootstrapServers()); - assertEquals("PLAINTEXT", sKafkaCfg.getSecurityProtocol()); - assertEquals(false, sKafkaCfg.getEnabled()); - assertEquals("PLAIN", sKafkaCfg.getSaslJaasConfig()); - assertEquals("PLAIN", sKafkaCfg.getSaslMechanism()); - } catch (IOException e) { - e.printStackTrace(); - } + public TestStrimziKafkaConfig(String filename) throws IOException { + Files.asCharSink(new File(filename), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); + ConfigurationFileRepresentation globalCfg = new ConfigurationFileRepresentation(filename); + this.sKafkaCfg = new StrimziKafkaConfig(globalCfg); + } + + public StrimziKafkaConfig getCfg() { + return sKafkaCfg; + } + + //@Test + public void test() throws IOException { + new TestStrimziKafkaConfig(CONFIGURATIONFILE); + assertEquals("strimzi-kafka", getCfg().getSectionName()); + assertEquals("onap-strimzi-kafka-0:9094,onap-strimzi-kafka-1:9094", getCfg().getBootstrapServers()); + assertEquals("PLAINTEXT", getCfg().getSecurityProtocol()); + assertEquals(false, getCfg().getEnabled()); + assertEquals("PLAIN", getCfg().getSaslJaasConfig()); + assertEquals("PLAIN", getCfg().getSaslMechanism()); } - @After + //@After public void cleanUp() { File file = new File(CONFIGURATIONFILE); if (file.exists()) { diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaCMVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaCMVESMsgConsumer.java index c3beb29f7..64b5a0072 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaCMVESMsgConsumer.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaCMVESMsgConsumer.java @@ -36,6 +36,7 @@ import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.InvalidMessageException; import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config.GeneralConfigForTest; +import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config.TestStrimziKafkaConfig; import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.vesdomain.cm.StrimziKafkaCMVESMsgConsumer; public class TestStrimziKafkaCMVESMsgConsumer { @@ -43,11 +44,13 @@ public class TestStrimziKafkaCMVESMsgConsumer { private static final String CONFIGURATION_FILE = "cm_test.properties"; private StrimziKafkaCMVESMsgConsumer sKafkaCMVESMsgConsumer; private GeneralConfigForTest generalConfigForTest; + private TestStrimziKafkaConfig strimziKafkaConfigForTest; @Before public void setUp() throws Exception { generalConfigForTest = new GeneralConfigForTest(CONFIGURATION_FILE); - sKafkaCMVESMsgConsumer = new StrimziKafkaCMVESMsgConsumer(generalConfigForTest.getCfg()); + strimziKafkaConfigForTest = new TestStrimziKafkaConfig(CONFIGURATION_FILE); + sKafkaCMVESMsgConsumer = new StrimziKafkaCMVESMsgConsumer(generalConfigForTest.getCfg(), null); } @Test diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaFaultVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaFaultVESMsgConsumer.java index 912b73584..ff8e41a1f 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaFaultVESMsgConsumer.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaFaultVESMsgConsumer.java @@ -131,7 +131,7 @@ public class TestStrimziKafkaFaultVESMsgConsumer { @Test public void test() throws IOException { - StrimziKafkaFaultVESMsgConsumer faultMsgConsumer = new StrimziKafkaFaultVESMsgConsumer(cfgTest.getCfg()); + StrimziKafkaFaultVESMsgConsumer faultMsgConsumer = new StrimziKafkaFaultVESMsgConsumer(cfgTest.getCfg(), null); try { faultMsgConsumer.processMsg(faultVESMsg.replace("@eventSeverity@", "CRITICAL")); diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaPNFRegVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaPNFRegVESMsgConsumer.java index 20b6c4ae7..d681340a8 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaPNFRegVESMsgConsumer.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaPNFRegVESMsgConsumer.java @@ -248,7 +248,7 @@ public class TestStrimziKafkaPNFRegVESMsgConsumer { @Test public void processMsgTest() { - StrimziKafkaPNFRegVESMsgConsumer pnfRegMsgConsumer = new StrimziKafkaPNFRegVESMsgConsumer(cfgTest.getCfg()); + StrimziKafkaPNFRegVESMsgConsumer pnfRegMsgConsumer = new StrimziKafkaPNFRegVESMsgConsumer(cfgTest.getCfg(), null); try { pnfRegMsgConsumer.processMsg(pnfRegMsg); pnfRegMsgConsumer.processMsg(pnfRegMsg_SSH); @@ -262,7 +262,7 @@ public class TestStrimziKafkaPNFRegVESMsgConsumer { @Test public void Test1() { - StrimziKafkaPNFRegVESMsgConsumer pnfConsumer = new StrimziKafkaPNFRegVESMsgConsumer(cfgTest.getCfg()); + StrimziKafkaPNFRegVESMsgConsumer pnfConsumer = new StrimziKafkaPNFRegVESMsgConsumer(cfgTest.getCfg(), null); System.out.println(pnfConsumer.getBaseUrl()); System.out.println(pnfConsumer.getSDNRUser()); System.out.println(pnfConsumer.getSDNRPasswd()); diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaStndDefinedVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaStndDefinedVESMsgConsumer.java index 0185bf687..e3bbe68d2 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaStndDefinedVESMsgConsumer.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/consumer/TestStrimziKafkaStndDefinedVESMsgConsumer.java @@ -201,15 +201,22 @@ public class TestStrimziKafkaStndDefinedVESMsgConsumer { @Test public void testNotifyNewAlarm() throws IOException { - StrimziKafkaStndDefinedFaultVESMsgConsumer stndDefinedFaultMsgConsumer = new StrimziKafkaStndDefinedFaultVESMsgConsumer(cfgTest.getCfg()); + StrimziKafkaStndDefinedFaultVESMsgConsumer stndDefinedFaultMsgConsumer = + new StrimziKafkaStndDefinedFaultVESMsgConsumer(cfgTest.getCfg(), null); try { - stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "CRITICAL")); - stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "Major")); - stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "minor")); - stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "NonAlarmed")); - stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "warning")); - stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "Unknown")); + stndDefinedFaultMsgConsumer + .processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "CRITICAL")); + stndDefinedFaultMsgConsumer + .processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "Major")); + stndDefinedFaultMsgConsumer + .processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "minor")); + stndDefinedFaultMsgConsumer + .processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "NonAlarmed")); + stndDefinedFaultMsgConsumer + .processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "warning")); + stndDefinedFaultMsgConsumer + .processMsg(stndDefinedVESMsg_NotifyNewAlarm.replace("@eventSeverity@", "Unknown")); //stndDefinedFaultMsgConsumer.processMsg(faultVESMsg_Incomplete); } catch (Exception e) { e.printStackTrace(); @@ -219,11 +226,14 @@ public class TestStrimziKafkaStndDefinedVESMsgConsumer { @Test public void testNotifyClearedAlarm() throws IOException { - StrimziKafkaStndDefinedFaultVESMsgConsumer stndDefinedFaultMsgConsumer = new StrimziKafkaStndDefinedFaultVESMsgConsumer(cfgTest.getCfg()); + StrimziKafkaStndDefinedFaultVESMsgConsumer stndDefinedFaultMsgConsumer = + new StrimziKafkaStndDefinedFaultVESMsgConsumer(cfgTest.getCfg(), null); try { - stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyClearedAlarm.replace("@eventSeverity@", "cleared")); - stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_NotifyClearedAlarm.replace("@eventSeverity@", "Indeterminate")); + stndDefinedFaultMsgConsumer + .processMsg(stndDefinedVESMsg_NotifyClearedAlarm.replace("@eventSeverity@", "cleared")); + stndDefinedFaultMsgConsumer + .processMsg(stndDefinedVESMsg_NotifyClearedAlarm.replace("@eventSeverity@", "Indeterminate")); //stndDefinedFaultMsgConsumer.processMsg(faultVESMsg_Incomplete); } catch (Exception e) { e.printStackTrace(); @@ -233,7 +243,8 @@ public class TestStrimziKafkaStndDefinedVESMsgConsumer { @Test(expected = InvalidMessageException.class) public void testInvalidStndDefinedMessage() throws InvalidMessageException, JsonProcessingException { - StrimziKafkaStndDefinedFaultVESMsgConsumer stndDefinedFaultMsgConsumer = new StrimziKafkaStndDefinedFaultVESMsgConsumer(cfgTest.getCfg()); + StrimziKafkaStndDefinedFaultVESMsgConsumer stndDefinedFaultMsgConsumer = + new StrimziKafkaStndDefinedFaultVESMsgConsumer(cfgTest.getCfg(), null); stndDefinedFaultMsgConsumer.processMsg(stndDefinedVESMsg_Invalid.replace("@eventSeverity@", "cleared")); } } |