From 30173a74d9666faaa9ff4d1d4bc2957ab209551f Mon Sep 17 00:00:00 2001 From: Santanu Sinha Date: Wed, 6 Dec 2023 18:07:25 +0530 Subject: [PATCH] Fixed testcase for portability on linux --- ranger-discovery-bundle/pom.xml | 27 ++++++++++--------- ...rviceDiscoveryBundleLocalHostPortTest.java | 16 ++++++----- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/ranger-discovery-bundle/pom.xml b/ranger-discovery-bundle/pom.xml index 11233eb1..a0d4245d 100644 --- a/ranger-discovery-bundle/pom.xml +++ b/ranger-discovery-bundle/pom.xml @@ -12,23 +12,12 @@ ranger-discovery-bundle - 1.7.2 + 1.8.1 3.2.4 - - org.openjdk.jmh - jmh-core - 1.35 - test - - - org.openjdk.jmh - jmh-generator-annprocess - 1.35 - test - + io.dropwizard dropwizard-core @@ -77,6 +66,18 @@ ${dns.cache.manipulator.version} test + + org.openjdk.jmh + jmh-core + 1.35 + test + + + org.openjdk.jmh + jmh-generator-annprocess + 1.35 + test + \ No newline at end of file diff --git a/ranger-discovery-bundle/src/test/java/io/appform/ranger/discovery/bundle/ServiceDiscoveryBundleLocalHostPortTest.java b/ranger-discovery-bundle/src/test/java/io/appform/ranger/discovery/bundle/ServiceDiscoveryBundleLocalHostPortTest.java index d0db400a..6f008b98 100644 --- a/ranger-discovery-bundle/src/test/java/io/appform/ranger/discovery/bundle/ServiceDiscoveryBundleLocalHostPortTest.java +++ b/ranger-discovery-bundle/src/test/java/io/appform/ranger/discovery/bundle/ServiceDiscoveryBundleLocalHostPortTest.java @@ -30,10 +30,12 @@ import io.dropwizard.setup.Bootstrap; import io.dropwizard.setup.Environment; import lombok.extern.slf4j.Slf4j; +import lombok.val; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.net.InetAddress; import java.net.UnknownHostException; import java.util.UUID; @@ -138,7 +140,7 @@ void shouldThrowExceptionForInvalidZkHost() { }); assertTrue(thrown.getMessage() - .contains("Couldn't resolve host address for zkHost")); + .contains("Couldn't resolve host address for zkHost")); } @@ -168,9 +170,10 @@ void testPublishWithEmptyZkHost() throws UnknownHostException { .build(); bundle.initialize(bootstrap); - String publishedHost = ConfigurationUtils.resolveNonEmptyPublishedHost( + val publishedHost = ConfigurationUtils.resolveNonEmptyPublishedHost( serviceDiscoveryConfiguration.getPublishedHost()); - if (LOCAL_ADDRESSES.contains(publishedHost)) { + val publishedHostAddress = InetAddress.getByName(publishedHost).getHostAddress(); + if (LOCAL_ADDRESSES.contains(publishedHostAddress) || LOCAL_ADDRESSES.contains(publishedHost)) { assertLocalHostNotAllowed(); } else { assertDoesNotThrow(); @@ -202,9 +205,10 @@ void testPublishWithNullZkHost() throws UnknownHostException { .build(); bundle.initialize(bootstrap); - String publishedHost = ConfigurationUtils.resolveNonEmptyPublishedHost( + val publishedHost = ConfigurationUtils.resolveNonEmptyPublishedHost( serviceDiscoveryConfiguration.getPublishedHost()); - if (LOCAL_ADDRESSES.contains(publishedHost)) { + val publishedHostAddress = InetAddress.getByName(publishedHost).getHostAddress(); + if (LOCAL_ADDRESSES.contains(publishedHostAddress) || LOCAL_ADDRESSES.contains(publishedHost)) { assertLocalHostNotAllowed(); } else { assertDoesNotThrow(); @@ -276,7 +280,7 @@ private void assertLocalHostNotAllowed() { }); assertTrue(thrown.getMessage() - .contains("Not allowed to publish localhost address to remote zookeeper")); + .contains("Not allowed to publish localhost address to remote zookeeper")); }