diff options
author | Brian Cully <bjc@kublai.com> | 2017-11-10 13:47:01 -0500 |
---|---|---|
committer | Brian Cully <bjc@kublai.com> | 2017-11-12 11:48:56 -0500 |
commit | 2bb7eb2dec219d05edb53002e10811fa214325b8 (patch) | |
tree | f593bef77ba64339622d720ac51901e4626848ab /t | |
parent | 3f8f46c8b10d060ec4ba7f3be91ff3cb6e903e01 (diff) | |
download | xmpt-2bb7eb2dec219d05edb53002e10811fa214325b8.tar.gz xmpt-2bb7eb2dec219d05edb53002e10811fa214325b8.zip |
Add tests.
* Add simple INSTALL document.
* Add Makefile.PL for make support.
* Moved sample files to t/fixtures.
* Add version to xmpt executable.xmpt
* Add tests for sample CLI run.
Diffstat (limited to 't')
-rw-r--r-- | t/fixtures/input | 29 | ||||
-rw-r--r-- | t/fixtures/localhost.conf | 3 | ||||
-rw-r--r-- | t/fixtures/testplan | 6 | ||||
-rw-r--r-- | t/samplerun.t | 39 |
4 files changed, 77 insertions, 0 deletions
diff --git a/t/fixtures/input b/t/fixtures/input new file mode 100644 index 0000000..2d508fe --- /dev/null +++ b/t/fixtures/input @@ -0,0 +1,29 @@ +<stream:stream xmlns:stream='http://etherx.jabber.org/streams' + version='1.0' + from='localhost' + id='somestreamid' + xmlns='jabber:client'> + <stream:features> + <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'> + <mechanism>SCRAM-SHA-1</mechanism> + <mechanism>PLAIN</mechanism> + </mechanisms> + <auth xmlns='http://jabber.org/features/iq-auth'/> + </stream:features> +<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'></success> +<stream:stream xmlns:stream='http://etherx.jabber.org/streams' + version='1.0' + from='localhost' + id='somestreamid' + xmlns='jabber:client'> + <stream:features> + <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/> + <session xmlns='urn:ietf:params:xml:ns:xmpp-session'/> + </stream:features> +<iq from='test0@localhost' to='test0@localhost/xmpt' id='bind' type='result'> + <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'> + <jid>test0@localhost/xmpt</jid> + </bind> +</iq> +<iq from='test0@localhost' to='test0@localhost/xmpt' id='session' type='result'/> +</stream:stream> diff --git a/t/fixtures/localhost.conf b/t/fixtures/localhost.conf new file mode 100644 index 0000000..bc462d7 --- /dev/null +++ b/t/fixtures/localhost.conf @@ -0,0 +1,3 @@ +# Domain and bare JID are calculated from full. +full_jid=test0@localhost/xmpt +password=test diff --git a/t/fixtures/testplan b/t/fixtures/testplan new file mode 100644 index 0000000..ba7fcaa --- /dev/null +++ b/t/fixtures/testplan @@ -0,0 +1,6 @@ +signin +auth +bind-reneg +bind +session +signout diff --git a/t/samplerun.t b/t/samplerun.t new file mode 100644 index 0000000..c3930ed --- /dev/null +++ b/t/samplerun.t @@ -0,0 +1,39 @@ +# -*- mode: perl -*- + +use Test::More tests => 3; + +use strict; +use warnings; + +my $config = 't/fixtures/localhost.conf'; +my $testplan = 't/fixtures/testplan'; +my $input = 't/fixtures/input'; + +subtest 'standard input', sub { + my $cmd = "./xmpt -c $config -p $testplan"; + my $xmptfh = new IO::File("|$cmd") or BAIL_OUT "Can't run '$cmd': $!.\n"; + my $inputfh = new IO::File($input) or + BAIL_OUT "Couldn't open $input for reading: $!.\n"; + while (<$inputfh>) { + print $xmptfh $_; + } + $inputfh->close; + $xmptfh->close; + ok($? == 0, 'Standard input redirect'); +}; + +subtest 'timeout', sub { + my $cmd = "./xmpt -t 1 -c $config -p $testplan cat 2>/dev/null"; + local $SIG{ALRM} = sub { fail("Timed out running $cmd.") }; + alarm 5; + system $cmd; + ok(($? >> 8) != 0, 'Timeout test'); +}; + +subtest 'I/O redirected to cat', sub { + my $cmd = "./xmpt -c $config -p $testplan cat $input 2>/dev/null"; + local $SIG{ALRM} = sub { fail("Timed out running $cmd.") }; + alarm 10; + ok((system($cmd) >> 8) == 0, 'I/O redirected to cat'); + alarm 0; +}; |