mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 21:42:07 +01:00
[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`).
This commit is contained in:
parent
5cbcd67645
commit
7c77cfbc20
2 changed files with 18 additions and 0 deletions
|
@ -72,6 +72,8 @@ public final class Configuration {
|
||||||
|
|
||||||
public final DomainBareJid service;
|
public final DomainBareJid service;
|
||||||
|
|
||||||
|
public final String host;
|
||||||
|
|
||||||
public final String serviceTlsPin;
|
public final String serviceTlsPin;
|
||||||
|
|
||||||
public final SslContextFactory sslContextFactory;
|
public final SslContextFactory sslContextFactory;
|
||||||
|
@ -138,6 +140,7 @@ public final class Configuration {
|
||||||
private Configuration(Configuration.Builder builder) throws KeyManagementException, NoSuchAlgorithmException {
|
private Configuration(Configuration.Builder builder) throws KeyManagementException, NoSuchAlgorithmException {
|
||||||
service = Objects.requireNonNull(builder.service,
|
service = Objects.requireNonNull(builder.service,
|
||||||
"'service' must be set. Either via 'properties' files or via system property 'sinttest.service'.");
|
"'service' must be set. Either via 'properties' files or via system property 'sinttest.service'.");
|
||||||
|
host = builder.host;
|
||||||
serviceTlsPin = builder.serviceTlsPin;
|
serviceTlsPin = builder.serviceTlsPin;
|
||||||
if (serviceTlsPin != null) {
|
if (serviceTlsPin != null) {
|
||||||
SSLContext sslContext = Java7Pinning.forPin(serviceTlsPin);
|
SSLContext sslContext = Java7Pinning.forPin(serviceTlsPin);
|
||||||
|
@ -197,6 +200,9 @@ public final class Configuration {
|
||||||
}
|
}
|
||||||
b.setSecurityMode(securityMode);
|
b.setSecurityMode(securityMode);
|
||||||
b.setXmppDomain(service);
|
b.setXmppDomain(service);
|
||||||
|
if (host != null) {
|
||||||
|
b.setHost(host);
|
||||||
|
}
|
||||||
|
|
||||||
if (debuggerFactory != null) {
|
if (debuggerFactory != null) {
|
||||||
b.setDebuggerFactory(debuggerFactory);
|
b.setDebuggerFactory(debuggerFactory);
|
||||||
|
@ -222,6 +228,8 @@ public final class Configuration {
|
||||||
|
|
||||||
private DomainBareJid service;
|
private DomainBareJid service;
|
||||||
|
|
||||||
|
private String host;
|
||||||
|
|
||||||
private String serviceTlsPin;
|
private String serviceTlsPin;
|
||||||
|
|
||||||
private SecurityMode securityMode;
|
private SecurityMode securityMode;
|
||||||
|
@ -287,6 +295,11 @@ public final class Configuration {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Builder setHost(String host) {
|
||||||
|
this.host = host;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder addEnabledTest(Class<? extends AbstractSmackIntTest> enabledTest) {
|
public Builder addEnabledTest(Class<? extends AbstractSmackIntTest> enabledTest) {
|
||||||
if (enabledTests == null) {
|
if (enabledTests == null) {
|
||||||
enabledTests = new HashSet<>();
|
enabledTests = new HashSet<>();
|
||||||
|
@ -521,6 +534,7 @@ public final class Configuration {
|
||||||
|
|
||||||
Builder builder = builder();
|
Builder builder = builder();
|
||||||
builder.setService(properties.getProperty("service"));
|
builder.setService(properties.getProperty("service"));
|
||||||
|
builder.setHost(properties.getProperty("host"));
|
||||||
builder.setServiceTlsPin(properties.getProperty("serviceTlsPin"));
|
builder.setServiceTlsPin(properties.getProperty("serviceTlsPin"));
|
||||||
builder.setSecurityMode(properties.getProperty("securityMode"));
|
builder.setSecurityMode(properties.getProperty("securityMode"));
|
||||||
builder.setReplyTimeout(properties.getProperty("replyTimeout", "47000"));
|
builder.setReplyTimeout(properties.getProperty("replyTimeout", "47000"));
|
||||||
|
|
|
@ -80,6 +80,10 @@
|
||||||
* <td>XMPP service to run the tests on</td>
|
* <td>XMPP service to run the tests on</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
|
* <td>host</td>
|
||||||
|
* <td>IP address or DNS name of the XMPP service to run the tests on</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
* <td>serviceTlsPin</td>
|
* <td>serviceTlsPin</td>
|
||||||
* <td>TLS Pin (used by <a href="https://github.com/Flowdalic/java-pinning">java-pinning</a>)</td>
|
* <td>TLS Pin (used by <a href="https://github.com/Flowdalic/java-pinning">java-pinning</a>)</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
|
Loading…
Reference in a new issue