Test suite

A test suite for testing the functionality the server is located in /test directory.

If the software has been installed as a Debian package, you can locate the files using:

dpkg -L openxcap

Configure the credentials of a test account and the xcap root in a configuration file as follows:

~/.xcapclient.ini

[Account_test]
sip_address=alice@example.com
password=1234
xcap_root = http://xcap.example.com/xcap-root

Replace the xcap_root with the same xcap_root configured in the server and make sure the hostname points to the IP address where the server listens to.

Add the same test account to the OpenSIPS subscriber table:

subscriber

Then run the test suite:

~/openxcap/test$./test.py
test_delete (test_element.ElementTest) ... ok
test_get (test_element.ElementTest) ... WARNING: test with URI in att_value is disabled
ok
test_put_error (test_element.ElementTest) ... ok
test400_1 (test_errors.ErrorsTest) ... ok
test400_2 (test_errors.ErrorsTest) ... ok
test404 (test_errors.ErrorsTest) ... ok
test405 (test_errors.ErrorsTest) ... ok
test409 (test_errors.ErrorsTest) ... ok
test_gibberish (test_errors.ErrorsTest) ... ok
test_global_auth (test_auth.AuthTest_org_openmobilealliance_pres_rules) ... ok
test_users_auth (test_auth.AuthTest_org_openmobilealliance_pres_rules) ... ok
test_global_auth (test_auth.AuthTest_pidf_manipulation) ... ok
test_users_auth (test_auth.AuthTest_pidf_manipulation) ... ok
test_global_auth (test_auth.AuthTest_pres_rules) ... ok
test_users_auth (test_auth.AuthTest_pres_rules) ... ok
test_global_auth (test_auth.AuthTest_resource_lists) ... ok
test_users_auth (test_auth.AuthTest_resource_lists) ... ok
test_global_auth (test_auth.AuthTest_rls_services) ... ok
test_users_auth (test_auth.AuthTest_rls_services) ... ok
test_global_auth (test_auth.AuthTest_test_app) ... ok
test_users_auth (test_auth.AuthTest_test_app) ... ok
test_global_auth (test_auth.AuthTest_watchers) ... ok
test_users_auth (test_auth.AuthTest_watchers) ... ok
test_global_auth (test_auth.AuthTest_xcap_caps) ... ok
test_users_auth (test_auth.AuthTest_xcap_caps) ... ok
test_conditional_PUT (test_etags2.ETagTest) ... ok
test_conditional_PUT_2 (test_etags2.ETagTest) ... ok
test_xpath10_valid (test_xpath.XPathTest) ... ok
test_xpath11_valid (test_xpath.XPathTest) ... ok
test_xpath12_valid (test_xpath.XPathTest) ... ok
test_xpath1_valid (test_xpath.XPathTest) ... ok
test_xpath2_invalid (test_xpath.XPathTest) ... ok
test_xpath3_invalid (test_xpath.XPathTest) ... ok
test_xpath4_invalid (test_xpath.XPathTest) ... ok
test_xpath5_invalid (test_xpath.XPathTest) ... ok
test_xpath6_invalid (test_xpath.XPathTest) ... ok
test_xpath7_invalid (test_xpath.XPathTest) ... ok
test_xpath8_invalid (test_xpath.XPathTest) ... ok
test_xpath9_valid (test_xpath.XPathTest) ... ok
test_pidf_manipulation (test_presrules.PresenceRulesTest) ... ok
test_operations1 (test_resourcelists.DocumentTest) ... ok
test_operations2 (test_resourcelists.DocumentTest) ... ok
test_operations3 (test_resourcelists.DocumentTest) ... ok
test_operations4 (test_resourcelists.DocumentTest) ... ok
test_ns_bindings (test_nsbindings.NSBindingsTest) ... ok
test_has_global (test_global.TestGlobal) ... ok
test_no_global (test_global.TestGlobal) ... ok
test_errors (test_fragment.FragmentTest) ... ok
test_success (test_fragment.FragmentTest) ... ok
test_operations1 (test_rlsservices.DocumentTest) ... ok
test_operations2 (test_rlsservices.DocumentTest) ... ok
test_operations3 (test_rlsservices.DocumentTest) ... ok
test_operations4 (test_rlsservices.DocumentTest) ... ok
test_pidf_manipulation (test_pidf.PIDFTest) ... ok
test_conditional_GET (test_etags.ETagTest) ... ok
test_conditional_PUT (test_etags.ETagTest) ... ok
test_conditional_PUT_2 (test_etags.ETagTest) ... ok
test_conditional_GET (test_etags.ETagTest2) ... ok
test_conditional_PUT (test_etags.ETagTest2) ... ok
test_etag_parsing (test_etags.ETagTest2) ... ok
Testing different ways of inserting an element as described in examples from Section 8.2.3 ... ok
Testing PUT requests of form '*[@att="some"]' which require looking into body of PUT ... ok
test_replacement (test_element_put.PutElementTest) ... ok
test_schema (test_xcap_caps.XCAPCaps) ... ok
test_delete (test_attribute.AttributeTest) ... ok
test_get (test_attribute.AttributeTest) ... WARNING: test with URI in att_value is disabled
ok
test_put (test_attribute.AttributeTest) ... ok
test_get (test_watchers.Test) ... ok

----------------------------------------------------------------------
Ran 68 tests in 38.662s

OK
NOTES:
  • Running the test suite for a given user will result in the destruction of all xcap documents belonging to that user
  • Replacing 'test.py' with 'test_something.py' will run only the tests defined in test_something.py
  • Make sure you enable document validation in the server, otherwise results might be unexpected

xcapclient

A command line client is available part of python-xcaplib, which is available as a tar archive and Debian package.

The client can be used to manipulate full or partial XML documents on XCAP servers (not limited to OpenXCAP) and has a bash shell command line completion facility that makes it very easy to browse through the structure of XML documents based on XPATH.

First create xcapclient configuration file:

~/.xcapclient.ini

with your credentials and XCAP root.

# this will be the default account used by xcapclient
[Account]
sip_address=alice@example.com
password=1234
xcap_root = https://xcap.example.com/xcap-root

# this will be used when -a bob command-line switch is provided
[Account_bob]
sip_address = bob@example.com
password = 1234
xcap_root = https://xcap.example.com/xcap-root

Multiple accounts can be specified. In order to select a specific account, the '-a' switch must be used:

# use default account ('Account' section)
xcapclient --app xcap-caps GET

# use Bob's account ('Account_bob' section)
xcapclient -a bob --app xcap-caps GET

Operating on XCAP documents (full document handling)

In the examples folder there are sample XCAP XML documents used for the examples below:

PUT

To a document, for example, presence rules:

xcapclient -i pres-rules.xml put

On success, the command prints '201 Created' if a new document was created on the server or '200 OK' if an existing document was replaced. You should something like this:

url: http://xcap.example.com/xcap-root/resource-lists/users/alice@example.com/index.xml
201 Created
etag: "856bdac9012ee28e46cebb81e51ac2a0"

GET

xcapclient --app resource-lists get

or

xcapclient --app pres-rules get

or

xcapclient --app rls-services get

This will print the document you've just put, along with its tag.

or

xcapclient --app xcap-caps get

will print the capabilities of the XCAP server.

DELETE

::
xcapclient --app resource-lists delete

and:

xcapclient --app pres-rules delete

and

xcapclient --app rls-services  delete

Operating on XML elements (partial document handling)

It is possible to retrieve a single element in XCAP document, to replace it, to insert a new one or to remove one. To address an element, a node selector is required, which is an XPATH-like expression, defined in https://tools.ietf.org/html/rfc4825#section-6.3.

Let's put the document in section 1 again to server, so we can fetch some elements from it:

xcapclient --app resource-lists get '/resource-lists/list[@name="friends"]/entry[1]/display-name'

etag: "856bdac9012ee28e46cebb81e51ac2a0"
<display-name>Bill Doe</display-name>

Specifying application with --app, is no longer necessary as it may be guessed from the node selector.

To replace an element, use the node selector you would have used for retrieving the element but do PUT instead. For example if we want to fix Bill's display name:

xcapclient -i bill_display_name_fixed.xml put '/resource-lists/list[@name="friends"]/entry[1]/display-name'

To insert a new element one must construct a node selector that doesn't point to an existing element.

xcapclient -i alice.xml put '/resource-lists/list[@name="friends"]/entry[1][@uri="sip:alice@example.com"]'
201 Created
etag: "bfbd38bed7163dd19e6e110d0dfa0876"

This will shift Bill's entry to the second position.

See README of python-xcaplib package for more detailed examples on how to create/retrieve XCAP documents.

SIP SIMPLE client SDK

You can download the command Line Tools for SIP SIMPLE client SDK from http://sipsimpleclient.org

Create an account:

sip-settings -a add user@domain

Set the newly created account as default:

sip-settings -a default user@domain

Set the xcap root:

sip-settings -a set xcap.xcap_root=http://xcap.example.com/xcap-root/
sip-settings -a set xcap.enabled=True

The following Command Line Tools are available for testing XCAP: