« Previous -
Version 16/35
(diff) -
Next » -
Current version
Adrian Georgescu, 04/23/2010 03:43 pm
= Test suite =
A test suite for testing the functionality the server is located in /xcap/test directory. If the software has been installed as a Debian package, the test suite is found in /usr/lib/python2.5/site-packages/xcap/test
To run the test suite, configure the credentials and xcap root in a configuration file as follows:
{{{
~/.xcapclient.ini
}}}
{{{
[Account_test]
sip_address=alice@example.com
password=123
xcap_root = https://xcap.example.com/xcap-root
}}}
Add the account to OpenSIPS database:
{{{
INSERT INTO `subscriber` (username,domain,password,email_address,ha1, ha1b) VALUES ('alice','example.com','1234','alice@example.com','fd7cab2287702c763e7b318b7fb2451a','fe605f5cea371c874a6fb7239a332a3e');
}}}
Then run the test suite:
{{{
~/openxcap/xcap/test$./test.py
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_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_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
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
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_conditional_GET (test_etags.ETagTest) ... ok
test_conditional_PUT (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
test_errors (test_fragment.FragmentTest) ... ok
test_success (test_fragment.FragmentTest) ... ok
test_has_global (test_global.TestGlobal) ... ok
test_no_global (test_global.TestGlobal) ... ok
test_ns_bindings (test_nsbindings.NSBindingsTest) ... ok
test_pidf_manipulation (test_pidf.PIDFTest) ... 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_operations1 (test_rlsservices.DocumentTest) ... ok
test_operations2 (test_rlsservices.DocumentTest) ... ok
test_operations3 (test_rlsservices.DocumentTest) ... ok
test_operations4 (test_rlsservices.DocumentTest) ... ok
test_get (test_watchers.Test) ... ok
test_schema (test_xcap_caps.XCAPCaps) ... ok
----------------------------------------------------------------------
Ran 53 tests in 48.941s
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
= 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.
{{{
[Account]
sip_address=alice@example.com
password=123
xcap_root = https://xcap.example.com/xcap-root
}}}
Operating on XCAP documents (full document handling)
In the examples folder there are sample XCAP XML documents used for the examples below:
PUTTo 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"
}}}
{{{
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 http://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"]/entry1/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"]/entry1/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"]/entry1[@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.com
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:
- Manage pres-rules document: [http://sipsimpleclient.com/wiki/xcap_pres_rules xcap-pres-rules]
- Manage rls-services document: [http://sipsimpleclient.com/wiki/xcap_rls_services xcap-rls-services]
- Manage icon: [http://sipsimpleclient.com/wiki/xcap_icon xcap-icon]
- Retrieve xcap-directory document: [http://sipsimpleclient.com/wiki/xcap_directory xcap-directory]