2015-05-31 23:21:46 +01:00
2015-05-31 23:17:50 +01:00
2015-05-31 23:17:50 +01:00
2015-05-11 22:39:46 +01:00
2015-05-17 19:58:31 +01:00
2015-05-31 23:17:50 +01:00
2015-05-31 23:21:46 +01:00
2015-05-27 23:14:19 +01:00
2015-05-31 23:21:46 +01:00
2015-05-31 23:17:50 +01:00
2015-05-31 23:17:50 +01:00

Stabber

Stubbed XMPP (Jabber) Server.

Overview

Stabber acts as a stubbed XMPP service for testing purposes, with an API to allow:

  • Sending of XMPP stanzas.
  • Responding to XMPP stanzas with stubbed responses.
  • Verifying that XMPP stanzas were received.

The project is work in progress with only the basics implemented, and is being developed alongside https://github.com/boothj5/profanity Currently the only API is written in C.

Installing

./bootstrap.sh
./configure
make
make install (as root)

Using in a project

Include the following header in your tests:

#include <stabber.h>

Include the following in the linker path when compiling tests:

-lstabber

API

Starting

To start Stabber on port 5230 for example:

stbbr_start(5230);

Stopping

To stop Stabber:

stbbr_stop();

Authentication

Currently only legacy authentication is supported, to set the password that stabber expects when an account connects:

stbbr_auth_passwd("mypassword");

The default if not set is "password".

Sending stanzas

To make Stabber send an XMPP stanza:

stbbr_send(
    "<iq id=\"ping1\" type=\"get\" to=\"stabber@localhost/profanity\" from=\"localhost\">"
        "<ping xmlns=\"urn:xmpp:ping\"/>"
    "</iq>"
);

Responding to stanzas

As well as being able to send an XMPP stanza at any time, you can also respond to a stanza by its id attribute:

stbbr_for("msg_21",
    "<message id=\"message17\" to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\" type=\"chat\">"
        "<body>I'm not real!</body>"
    "</message>"
);

Verify sent stanzas

To verify that you sent a particular stanza to Stabber:

stbbr_received(
    "<message id=\"msg24415\" to=\"buddy1@localhost/mobile\" type=\"chat\">"
        "<body>I know, its a test.</body>"
    "</message>"
);

The above function returns 1 if the stanza has been received, and 0 if it hasn't. The following function check that it was specifically the last stanza received:

stbbr_last_received(
    "<message id=\"msg24415\" to=\"buddy1@localhost/mobile\" type=\"chat\">"
        "<body>I know, its a test.</body>"
    "</message>"
);

Both verifications allow for wildcards (*) as attribute values, for example, if you don't know the id's that are generated by your client:

stbbr_received(
    "<message id=\"*\" to=\"buddy1@localhost/mobile\" type=\"chat\">"
        "<body>I know, its a test.</body>"
    "</message>"
);

By default the verification calls block for up to 10 seconds, the timeout in seconds can be set with:

stbbr_set_timeout(3);

A value of 0 or less is non-blocking and will return immediately.

Logs

Stabber logs to:

~/.local/share/stabber/logs/stabber.log

Example

Example tests for Profanity can be found at: https://github.com/boothj5/profanity/blob/stabber-tests/stabbertests/test_connect.c (the starting and stopping between tests is handled by the setup and teardown routines https://github.com/boothj5/profanity/blob/stabber-tests/stabbertests/stabbertestsuite.c)

Description
profanity-im/stabber fork for further development
Readme 261 KiB
Languages
C 95.5%
M4 2.3%
Makefile 1.3%
Shell 0.9%