From 7c77cfbc205fe3b1f895c0626314ba37808e8438 Mon Sep 17 00:00:00 2001 From: Guus der Kinderen Date: Fri, 7 Jun 2024 15:45:23 +0200 Subject: [PATCH] [sinttest] Add new config option: 'host' An optional configuration option for the Smack Integration Test framework has been added that allows one to bypass DNS when resolving a host for the XMPP domain that is the subject of the test. The `host` option can be used with IP addresses (eg: `-Dsinttest.host=127.0.0.1`) and DNS names (eg: `-Dsinttest.host=example.org`). --- .../smack/inttest/Configuration.java | 14 ++++++++++++++ .../igniterealtime/smack/inttest/package-info.java | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/Configuration.java b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/Configuration.java index 48a587cc5..0616da38a 100644 --- a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/Configuration.java +++ b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/Configuration.java @@ -72,6 +72,8 @@ public final class Configuration { public final DomainBareJid service; + public final String host; + public final String serviceTlsPin; public final SslContextFactory sslContextFactory; @@ -138,6 +140,7 @@ public final class Configuration { private Configuration(Configuration.Builder builder) throws KeyManagementException, NoSuchAlgorithmException { service = Objects.requireNonNull(builder.service, "'service' must be set. Either via 'properties' files or via system property 'sinttest.service'."); + host = builder.host; serviceTlsPin = builder.serviceTlsPin; if (serviceTlsPin != null) { SSLContext sslContext = Java7Pinning.forPin(serviceTlsPin); @@ -197,6 +200,9 @@ public final class Configuration { } b.setSecurityMode(securityMode); b.setXmppDomain(service); + if (host != null) { + b.setHost(host); + } if (debuggerFactory != null) { b.setDebuggerFactory(debuggerFactory); @@ -222,6 +228,8 @@ public final class Configuration { private DomainBareJid service; + private String host; + private String serviceTlsPin; private SecurityMode securityMode; @@ -287,6 +295,11 @@ public final class Configuration { return this; } + private Builder setHost(String host) { + this.host = host; + return this; + } + public Builder addEnabledTest(Class enabledTest) { if (enabledTests == null) { enabledTests = new HashSet<>(); @@ -521,6 +534,7 @@ public final class Configuration { Builder builder = builder(); builder.setService(properties.getProperty("service")); + builder.setHost(properties.getProperty("host")); builder.setServiceTlsPin(properties.getProperty("serviceTlsPin")); builder.setSecurityMode(properties.getProperty("securityMode")); builder.setReplyTimeout(properties.getProperty("replyTimeout", "47000")); diff --git a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/package-info.java b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/package-info.java index c72d0afc2..22ad207f5 100644 --- a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/package-info.java +++ b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/package-info.java @@ -80,6 +80,10 @@ * XMPP service to run the tests on * * + * host + * IP address or DNS name of the XMPP service to run the tests on + * + * * serviceTlsPin * TLS Pin (used by java-pinning) *