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 0994be5e098902c10e5778bdfacb76b2586e6b74
parent 16deba576b36057560b105aea5815c2dafff8040
Author: Rishi Raj <rishiraj6686@gmail.com>
Date:   Wed, 14 Feb 2018 17:16:50 +0530

Added test for XEP-0157

Checks if atleast one abuse address is given

Diffstat:
Asrc/main/java/eu/siacs/compliance/tests/AbuseContactTest.java | 38++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+), 0 deletions(-)

diff --git a/src/main/java/eu/siacs/compliance/tests/AbuseContactTest.java b/src/main/java/eu/siacs/compliance/tests/AbuseContactTest.java @@ -0,0 +1,38 @@ +package eu.siacs.compliance.tests; + +import eu.siacs.compliance.Result; +import rocks.xmpp.addr.Jid; +import rocks.xmpp.core.XmppException; +import rocks.xmpp.core.session.XmppClient; +import rocks.xmpp.extensions.data.model.DataForm; +import rocks.xmpp.extensions.disco.ServiceDiscoveryManager; + +import java.util.List; + +public class AbuseContactTest extends AbstractTest { + public AbuseContactTest(XmppClient client) { + super(client); + } + + @Override + public Result run() { + Jid target = Jid.of(client.getConnectedResource().getDomain()); + final ServiceDiscoveryManager serviceDiscoveryManager = client.getManager(ServiceDiscoveryManager.class); + try { + List<DataForm> extensions = serviceDiscoveryManager.discoverInformation(target).getResult().getExtensions(); + for(DataForm extension: extensions) { + final DataForm.Field addr = extension.findField("abuse-addresses"); + if(addr != null && addr.getValues() != null && addr.getValues().size() > 0) { + return Result.PASSED; + } + } + return Result.FAILED; + } catch (XmppException e) { + return Result.FAILED; + } + } + @Override + public String getName() { + return "XEP-0157: Contact Addresses for XMPP Services"; + } +}