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 e62c7b7ce80b21e78dbed5308d01f36f6385b235
parent 869111df03b86d8254a2708e431a7b58c5c80ff7
Author: Daniel Gultsch <daniel@gultsch.de>
Date:   Sun,  5 Jun 2016 19:29:03 +0200

fix CSI, added tests for carbons and streamhost

Diffstat:
Msrc/main/java/eu/siacs/ComplianceTester.java | 12++++++------
Asrc/main/java/eu/siacs/compliance/extensions/csi/ClientStateIndication.java | 13+++++++++++++
Asrc/main/java/eu/siacs/compliance/extensions/csi/package-info.java | 9+++++++++
Msrc/main/java/eu/siacs/compliance/suites/AbstractTestSuite.java | 13+++++++++++--
Msrc/main/java/eu/siacs/compliance/suites/EverythingTestSuite.java | 11+++++++----
Msrc/main/java/eu/siacs/compliance/suites/TestSuiteFactory.java | 15++++++++++-----
Msrc/main/java/eu/siacs/compliance/tests/CSI.java | 17+++++------------
Asrc/main/java/eu/siacs/compliance/tests/MessageCarbons.java | 29+++++++++++++++++++++++++++++
Asrc/main/java/eu/siacs/compliance/tests/Proxy65.java | 22++++++++++++++++++++++
9 files changed, 112 insertions(+), 29 deletions(-)

diff --git a/src/main/java/eu/siacs/ComplianceTester.java b/src/main/java/eu/siacs/ComplianceTester.java @@ -6,7 +6,6 @@ import eu.siacs.compliance.suites.TestSuiteFactory; import rocks.xmpp.addr.Jid; import rocks.xmpp.core.XmppException; import rocks.xmpp.core.sasl.AuthenticationException; -import rocks.xmpp.core.session.XmppClient; public class ComplianceTester { @@ -18,12 +17,13 @@ public class ComplianceTester { } Jid jid = Jid.of(args[0]); String password = args[1]; - XmppClient xmppClient = XmppClient.create(jid.getDomain()); - try { - xmppClient.connect(); - xmppClient.login(jid.getLocal(), password); + runTestSuite(EverythingTestSuite.class, jid, password); + } + + private static void runTestSuite(Class <? extends AbstractTestSuite> clazz, Jid jid, String password) { + try { try { - AbstractTestSuite testSuite = TestSuiteFactory.create(EverythingTestSuite.class, xmppClient); + AbstractTestSuite testSuite = TestSuiteFactory.create(clazz, jid, password); System.out.println("Use compliance suite '"+testSuite.getName()+"' to test "+jid.getDomain()+"\n"); testSuite.run(); System.out.println("\n"+testSuite.getName() + ": " + testSuite.result()); diff --git a/src/main/java/eu/siacs/compliance/extensions/csi/ClientStateIndication.java b/src/main/java/eu/siacs/compliance/extensions/csi/ClientStateIndication.java @@ -0,0 +1,13 @@ +package eu.siacs.compliance.extensions.csi; + +import rocks.xmpp.core.stream.model.StreamFeature; + +import javax.xml.bind.annotation.XmlNsForm; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchema; + +@XmlRootElement(name="csi") +public class ClientStateIndication extends StreamFeature { + + public static final String NAMESPACE = "urn:xmpp:csi:0"; +} diff --git a/src/main/java/eu/siacs/compliance/extensions/csi/package-info.java b/src/main/java/eu/siacs/compliance/extensions/csi/package-info.java @@ -0,0 +1,8 @@ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlSchema(namespace = ClientStateIndication.NAMESPACE, elementFormDefault = XmlNsForm.QUALIFIED) +package eu.siacs.compliance.extensions.csi; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlNsForm; +import javax.xml.bind.annotation.XmlSchema; +\ No newline at end of file diff --git a/src/main/java/eu/siacs/compliance/suites/AbstractTestSuite.java b/src/main/java/eu/siacs/compliance/suites/AbstractTestSuite.java @@ -3,6 +3,8 @@ package eu.siacs.compliance.suites; import eu.siacs.compliance.tests.AbstractTest; import eu.siacs.compliance.Result; import eu.siacs.compliance.tests.TestFactory; +import rocks.xmpp.addr.Jid; +import rocks.xmpp.core.XmppException; import rocks.xmpp.core.session.XmppClient; import java.util.Collections; @@ -12,17 +14,24 @@ import java.util.List; public abstract class AbstractTestSuite { private final XmppClient mXmppClient; + private final Jid mJid; + private final String mPassword; private HashMap<Class<?extends AbstractTest>,Result> mTestResults = new HashMap<>(); - public AbstractTestSuite(XmppClient client) { + public AbstractTestSuite(XmppClient client, Jid jid, String password) { mXmppClient = client; + mJid = jid; + mPassword = password; } - public void run() { + public void run() throws XmppException { + mXmppClient.connect(); + mXmppClient.login(mJid.getLocal(), mPassword); for(Class<? extends AbstractTest> test : getTests()) { run(test); } + mXmppClient.close(); int passed = Collections.frequency(mTestResults.values(),Result.PASSED); System.out.println("passed "+passed+"/"+mTestResults.size()); } diff --git a/src/main/java/eu/siacs/compliance/suites/EverythingTestSuite.java b/src/main/java/eu/siacs/compliance/suites/EverythingTestSuite.java @@ -1,6 +1,7 @@ package eu.siacs.compliance.suites; import eu.siacs.compliance.tests.*; +import rocks.xmpp.addr.Jid; import rocks.xmpp.core.session.XmppClient; import java.util.Arrays; @@ -12,8 +13,8 @@ import java.util.List; */ public class EverythingTestSuite extends AbstractTestSuite { - public EverythingTestSuite(XmppClient client) { - super(client); + public EverythingTestSuite(XmppClient client, Jid jid, String password) { + super(client, jid, password); } @Override @@ -21,14 +22,16 @@ public class EverythingTestSuite extends AbstractTestSuite { return Arrays.asList( RosterVersioning.class, StreamManagement.class, - CSI.class, + MessageCarbons.class, Blocking.class, MAM.class, Push.class, EntityCapabilities.class, MultiUserChat.class, HttpUpload.class, - PEP.class + PEP.class, + CSI.class, + Proxy65.class ); } diff --git a/src/main/java/eu/siacs/compliance/suites/TestSuiteFactory.java b/src/main/java/eu/siacs/compliance/suites/TestSuiteFactory.java @@ -1,15 +1,20 @@ package eu.siacs.compliance.suites; +import eu.siacs.compliance.extensions.csi.ClientStateIndication; +import rocks.xmpp.addr.Jid; +import rocks.xmpp.core.session.Extension; import rocks.xmpp.core.session.XmppClient; +import rocks.xmpp.core.session.XmppSessionConfiguration; public class TestSuiteFactory { - public static AbstractTestSuite create(Class <? extends AbstractTestSuite> clazz, XmppClient client) throws AbstractTestSuite.TestSuiteCreationException { - if (client == null) { - throw new AbstractTestSuite.TestSuiteCreationException(); - } + public static AbstractTestSuite create(Class <? extends AbstractTestSuite> clazz, Jid jid, String password) throws AbstractTestSuite.TestSuiteCreationException { + XmppSessionConfiguration configuration = XmppSessionConfiguration.builder() + .extensions(Extension.of(ClientStateIndication.class)) + .build(); + final XmppClient client = XmppClient.create(jid.getDomain(),configuration); try { - AbstractTestSuite testSuite = clazz.getDeclaredConstructor(XmppClient.class).newInstance(client); + AbstractTestSuite testSuite = clazz.getDeclaredConstructor(XmppClient.class, Jid.class, String.class).newInstance(client, jid, password); return testSuite; } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/eu/siacs/compliance/tests/CSI.java b/src/main/java/eu/siacs/compliance/tests/CSI.java @@ -1,28 +1,21 @@ package eu.siacs.compliance.tests; +import eu.siacs.compliance.extensions.csi.ClientStateIndication; import rocks.xmpp.core.session.XmppClient; +import rocks.xmpp.core.stream.model.StreamFeature; -import java.util.Arrays; -import java.util.List; - -public class CSI extends AbstractDiscoTest { +public class CSI extends AbstractStreamFeatureTest { public CSI(XmppClient client) { super(client); } @Override - List<String> getNamespaces() { - return Arrays.asList("urn:xmpp:carbons:2"); + Class<? extends StreamFeature> getStreamFeature() { + return ClientStateIndication.class; } @Override - boolean checkOnServer() { - return true; - } - - - @Override public String getName() { return "XEP-0352: Client State Indication"; } diff --git a/src/main/java/eu/siacs/compliance/tests/MessageCarbons.java b/src/main/java/eu/siacs/compliance/tests/MessageCarbons.java @@ -0,0 +1,29 @@ +package eu.siacs.compliance.tests; + +import rocks.xmpp.core.session.XmppClient; + +import java.util.Arrays; +import java.util.List; + +public class MessageCarbons extends AbstractDiscoTest { + + public MessageCarbons(XmppClient client) { + super(client); + } + + @Override + List<String> getNamespaces() { + return Arrays.asList("urn:xmpp:carbons:2"); + } + + @Override + boolean checkOnServer() { + return true; + } + + + @Override + public String getName() { + return "XEP-0280: Message Carbons"; + } +} diff --git a/src/main/java/eu/siacs/compliance/tests/Proxy65.java b/src/main/java/eu/siacs/compliance/tests/Proxy65.java @@ -0,0 +1,22 @@ +package eu.siacs.compliance.tests; + +import rocks.xmpp.core.session.XmppClient; +import rocks.xmpp.extensions.bytestreams.s5b.model.Socks5ByteStream; + +public class Proxy65 extends AbstractServiceTest { + + public Proxy65(XmppClient client) { + super(client); + } + + @Override + public String getNamespace() { + return Socks5ByteStream.NAMESPACE; + } + + + @Override + public String getName() { + return "XEP-0065: SOCKS5 Bytestreams (Proxy)"; + } +}