xmpp-compliance-tester

XMPP Compliance Tester, forked from github.com/iNPUTmice/ComplianceTester
git clone https://git.in0rdr.ch/xmpp-compliance-tester.git
Log | Files | Refs | Pull requests |Archive | README | LICENSE

commit ef30ec8e55603a8bc5d008845278bb9e520405c6
parent 039770326cf30fc0dfe604f51dc9c9820c98b22b
Author: Daniel Gultsch <daniel@gultsch.de>
Date:   Mon, 23 Jan 2017 00:38:41 +0100

add test for XEP-0368

Diffstat:
Mpom.xml | 5+++++
Msrc/main/java/eu/siacs/compliance/suites/Conversations.java | 7++++---
Asrc/main/java/eu/siacs/compliance/tests/XmppOverTls.java | 46++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml @@ -22,6 +22,11 @@ <artifactId>xmpp-extensions-client</artifactId> <version>0.7.0</version> </dependency> + <dependency> + <groupId>de.measite.minidns</groupId> + <artifactId>minidns-hla</artifactId> + <version>0.2.0</version> + </dependency> </dependencies> <build> diff --git a/src/main/java/eu/siacs/compliance/suites/Conversations.java b/src/main/java/eu/siacs/compliance/suites/Conversations.java @@ -16,12 +16,13 @@ public class Conversations extends AdvancedServerIM { @Override List<Class<? extends AbstractTest>> getTests() { - return Stream.concat(super.getTests().stream(), Arrays.asList( + return Stream.concat(super.getTests().stream(), Stream.of( CSI.class, HttpUpload.class, Proxy65.class, - Push.class - ).stream()).collect(Collectors.toList()); + Push.class, + XmppOverTls.class + )).collect(Collectors.toList()); } @Override diff --git a/src/main/java/eu/siacs/compliance/tests/XmppOverTls.java b/src/main/java/eu/siacs/compliance/tests/XmppOverTls.java @@ -0,0 +1,46 @@ +package eu.siacs.compliance.tests; + +import de.measite.minidns.hla.ResolverApi; +import de.measite.minidns.hla.ResolverResult; +import de.measite.minidns.record.SRV; +import eu.siacs.compliance.Result; +import rocks.xmpp.core.session.XmppClient; + +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; +import java.io.IOException; + +public class XmppOverTls extends AbstractTest { + + public XmppOverTls(XmppClient client) { + super(client); + } + + @Override + public Result run() { + String domain = client.getDomain().getDomain(); + try { + final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); + ResolverResult<SRV> results = ResolverApi.INSTANCE.resolve("_xmpps-client._tcp." + domain, SRV.class); + for(SRV record : results.getAnswers()) { + try { + SSLSocket socket = (SSLSocket) sslSocketFactory.createSocket(record.name.toString(),record.port); + socket.setSoTimeout(1000); + socket.startHandshake(); + socket.close(); + return Result.PASSED; + } catch (IOException e) { + //ignored + } + } + } catch (Exception e) { + return Result.FAILED; + } + return Result.FAILED; + } + + @Override + public String getName() { + return "XEP-0368: SRV records for XMPP over TLS"; + } +}