Testing

Version 34 (Adrian Georgescu, 06/09/2011 10:00 am)

1 1 Redmine Admin
2 34 Adrian Georgescu
h1. Testing
3 1 Redmine Admin
4 1 Redmine Admin
5 34 Adrian Georgescu
6 34 Adrian Georgescu
7 34 Adrian Georgescu
8 34 Adrian Georgescu
h2. Test Suite
9 34 Adrian Georgescu
10 34 Adrian Georgescu
11 1 Redmine Admin
A test suite for testing the functionality the server is located in /test directory. 
12 1 Redmine Admin
13 26 Adrian Georgescu
If the software has been installed as a Debian package, you can locate the files using:
14 26 Adrian Georgescu
15 34 Adrian Georgescu
<pre>
16 1 Redmine Admin
dpkg -L openxcap
17 34 Adrian Georgescu
</pre>
18 26 Adrian Georgescu
19 26 Adrian Georgescu
Configure the credentials of a test account and the xcap root in a configuration file as follows:
20 1 Redmine Admin
21 34 Adrian Georgescu
<pre>
22 1 Redmine Admin
~/.xcapclient.ini
23 34 Adrian Georgescu
</pre>
24 27 Adrian Georgescu
25 34 Adrian Georgescu
<pre>
26 1 Redmine Admin
[Account_test]
27 1 Redmine Admin
sip_address=alice@example.com
28 18 Adrian Georgescu
password=1234
29 19 Adrian Georgescu
xcap_root = http://xcap.example.com/xcap-root
30 34 Adrian Georgescu
</pre>
31 16 Adrian Georgescu
32 16 Adrian Georgescu
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.
33 28 Adrian Georgescu
34 21 Adrian Georgescu
Add the same test account to the OpenSIPS subscriber table:
35 28 Adrian Georgescu
36 34 Adrian Georgescu
@subscriber@
37 16 Adrian Georgescu
38 1 Redmine Admin
Then run the test suite:
39 1 Redmine Admin
40 34 Adrian Georgescu
<pre>
41 33 Adrian Georgescu
~/openxcap/test$./test.py 
42 32 Redmine Admin
test_delete (test_element.ElementTest) ... ok
43 32 Redmine Admin
test_get (test_element.ElementTest) ... WARNING: test with URI in att_value is disabled
44 1 Redmine Admin
ok
45 32 Redmine Admin
test_put_error (test_element.ElementTest) ... ok
46 32 Redmine Admin
test400_1 (test_errors.ErrorsTest) ... ok
47 32 Redmine Admin
test400_2 (test_errors.ErrorsTest) ... ok
48 32 Redmine Admin
test404 (test_errors.ErrorsTest) ... ok
49 32 Redmine Admin
test405 (test_errors.ErrorsTest) ... ok
50 32 Redmine Admin
test409 (test_errors.ErrorsTest) ... ok
51 32 Redmine Admin
test_gibberish (test_errors.ErrorsTest) ... ok
52 1 Redmine Admin
test_global_auth (test_auth.AuthTest_org_openmobilealliance_pres_rules) ... ok
53 1 Redmine Admin
test_users_auth (test_auth.AuthTest_org_openmobilealliance_pres_rules) ... ok
54 1 Redmine Admin
test_global_auth (test_auth.AuthTest_pidf_manipulation) ... ok
55 1 Redmine Admin
test_users_auth (test_auth.AuthTest_pidf_manipulation) ... ok
56 1 Redmine Admin
test_global_auth (test_auth.AuthTest_pres_rules) ... ok
57 1 Redmine Admin
test_users_auth (test_auth.AuthTest_pres_rules) ... ok
58 1 Redmine Admin
test_global_auth (test_auth.AuthTest_resource_lists) ... ok
59 10 Adrian Georgescu
test_users_auth (test_auth.AuthTest_resource_lists) ... ok
60 1 Redmine Admin
test_global_auth (test_auth.AuthTest_rls_services) ... ok
61 1 Redmine Admin
test_users_auth (test_auth.AuthTest_rls_services) ... ok
62 1 Redmine Admin
test_global_auth (test_auth.AuthTest_test_app) ... ok
63 1 Redmine Admin
test_users_auth (test_auth.AuthTest_test_app) ... ok
64 1 Redmine Admin
test_global_auth (test_auth.AuthTest_watchers) ... ok
65 10 Adrian Georgescu
test_users_auth (test_auth.AuthTest_watchers) ... ok
66 1 Redmine Admin
test_global_auth (test_auth.AuthTest_xcap_caps) ... ok
67 1 Redmine Admin
test_users_auth (test_auth.AuthTest_xcap_caps) ... ok
68 32 Redmine Admin
test_conditional_PUT (test_etags2.ETagTest) ... ok
69 32 Redmine Admin
test_conditional_PUT_2 (test_etags2.ETagTest) ... ok
70 32 Redmine Admin
test_xpath10_valid (test_xpath.XPathTest) ... ok
71 32 Redmine Admin
test_xpath11_valid (test_xpath.XPathTest) ... ok
72 32 Redmine Admin
test_xpath12_valid (test_xpath.XPathTest) ... ok
73 32 Redmine Admin
test_xpath1_valid (test_xpath.XPathTest) ... ok
74 32 Redmine Admin
test_xpath2_invalid (test_xpath.XPathTest) ... ok
75 32 Redmine Admin
test_xpath3_invalid (test_xpath.XPathTest) ... ok
76 32 Redmine Admin
test_xpath4_invalid (test_xpath.XPathTest) ... ok
77 32 Redmine Admin
test_xpath5_invalid (test_xpath.XPathTest) ... ok
78 32 Redmine Admin
test_xpath6_invalid (test_xpath.XPathTest) ... ok
79 32 Redmine Admin
test_xpath7_invalid (test_xpath.XPathTest) ... ok
80 32 Redmine Admin
test_xpath8_invalid (test_xpath.XPathTest) ... ok
81 32 Redmine Admin
test_xpath9_valid (test_xpath.XPathTest) ... ok
82 1 Redmine Admin
test_pidf_manipulation (test_presrules.PresenceRulesTest) ... ok
83 1 Redmine Admin
test_operations1 (test_resourcelists.DocumentTest) ... ok
84 1 Redmine Admin
test_operations2 (test_resourcelists.DocumentTest) ... ok
85 1 Redmine Admin
test_operations3 (test_resourcelists.DocumentTest) ... ok
86 1 Redmine Admin
test_operations4 (test_resourcelists.DocumentTest) ... ok
87 32 Redmine Admin
test_ns_bindings (test_nsbindings.NSBindingsTest) ... ok
88 32 Redmine Admin
test_has_global (test_global.TestGlobal) ... ok
89 32 Redmine Admin
test_no_global (test_global.TestGlobal) ... ok
90 32 Redmine Admin
test_errors (test_fragment.FragmentTest) ... ok
91 32 Redmine Admin
test_success (test_fragment.FragmentTest) ... ok
92 1 Redmine Admin
test_operations1 (test_rlsservices.DocumentTest) ... ok
93 10 Adrian Georgescu
test_operations2 (test_rlsservices.DocumentTest) ... ok
94 1 Redmine Admin
test_operations3 (test_rlsservices.DocumentTest) ... ok
95 1 Redmine Admin
test_operations4 (test_rlsservices.DocumentTest) ... ok
96 32 Redmine Admin
test_pidf_manipulation (test_pidf.PIDFTest) ... ok
97 32 Redmine Admin
test_conditional_GET (test_etags.ETagTest) ... ok
98 32 Redmine Admin
test_conditional_PUT (test_etags.ETagTest) ... ok
99 32 Redmine Admin
test_conditional_PUT_2 (test_etags.ETagTest) ... ok
100 32 Redmine Admin
test_conditional_GET (test_etags.ETagTest2) ... ok
101 32 Redmine Admin
test_conditional_PUT (test_etags.ETagTest2) ... ok
102 32 Redmine Admin
test_etag_parsing (test_etags.ETagTest2) ... ok
103 1 Redmine Admin
Testing different ways of inserting an element as described in examples from Section 8.2.3 ... ok
104 1 Redmine Admin
Testing PUT requests of form '*[@att="some"]' which require looking into body of PUT ... ok
105 1 Redmine Admin
test_replacement (test_element_put.PutElementTest) ... ok
106 1 Redmine Admin
test_schema (test_xcap_caps.XCAPCaps) ... ok
107 1 Redmine Admin
test_delete (test_attribute.AttributeTest) ... ok
108 1 Redmine Admin
test_get (test_attribute.AttributeTest) ... WARNING: test with URI in att_value is disabled
109 1 Redmine Admin
ok
110 10 Adrian Georgescu
test_put (test_attribute.AttributeTest) ... ok
111 32 Redmine Admin
test_get (test_watchers.Test) ... ok
112 32 Redmine Admin
113 32 Redmine Admin
----------------------------------------------------------------------
114 32 Redmine Admin
Ran 68 tests in 38.662s
115 1 Redmine Admin
116 32 Redmine Admin
OK
117 34 Adrian Georgescu
</pre>
118 1 Redmine Admin
119 1 Redmine Admin
120 34 Adrian Georgescu
h3. Notes
121 1 Redmine Admin
122 1 Redmine Admin
123 34 Adrian Georgescu
* Running the test suite for a given user will result in the destruction of all xcap documents belonging to that user
124 34 Adrian Georgescu
* Replacing 'test.py' with 'test_something.py' will run only the tests defined in test_something.py
125 34 Adrian Georgescu
* Make sure you enable document validation in the server, otherwise results might be unexpected
126 34 Adrian Georgescu
127 34 Adrian Georgescu
128 34 Adrian Georgescu
h2. xcapclient
129 34 Adrian Georgescu
130 34 Adrian Georgescu
131 14 Adrian Georgescu
A command line client is available part of python-xcaplib, which is available as a tar archive and Debian package.
132 14 Adrian Georgescu
133 1 Redmine Admin
The client can be used to manipulate full or partial XML
134 1 Redmine Admin
documents on XCAP servers (not limited to OpenXCAP) and has a bash shell
135 1 Redmine Admin
command line completion facility that makes it very easy to browse through
136 1 Redmine Admin
the structure of XML documents based on XPATH.
137 1 Redmine Admin
138 11 Adrian Georgescu
First create xcapclient configuration file:
139 11 Adrian Georgescu
140 34 Adrian Georgescu
<pre>
141 1 Redmine Admin
~/.xcapclient.ini
142 34 Adrian Georgescu
</pre>
143 11 Adrian Georgescu
144 11 Adrian Georgescu
with your credentials and XCAP root.
145 11 Adrian Georgescu
146 34 Adrian Georgescu
<pre>
147 1 Redmine Admin
# this will be the default account used by xcapclient
148 1 Redmine Admin
[Account]
149 1 Redmine Admin
sip_address=alice@example.com
150 11 Adrian Georgescu
password=1234
151 1 Redmine Admin
xcap_root = https://xcap.example.com/xcap-root
152 1 Redmine Admin
153 30 Redmine Admin
# this will be used when -a bob command-line switch is provided
154 30 Redmine Admin
[Account_bob]
155 1 Redmine Admin
sip_address = bob@example.com
156 30 Redmine Admin
password = 1234
157 30 Redmine Admin
xcap_root = https://xcap.example.com/xcap-root
158 34 Adrian Georgescu
</pre>
159 1 Redmine Admin
160 1 Redmine Admin
Multiple accounts can be specified. In order to select a specific account, the '-a' switch must be used:
161 1 Redmine Admin
162 34 Adrian Georgescu
<pre>
163 1 Redmine Admin
# use default account ('Account' section)
164 30 Redmine Admin
xcapclient --app xcap-caps GET
165 30 Redmine Admin
166 1 Redmine Admin
# use Bob's account ('Account_bob' section)
167 1 Redmine Admin
xcapclient -a bob --app xcap-caps GET
168 34 Adrian Georgescu
</pre>
169 11 Adrian Georgescu
170 1 Redmine Admin
Operating on XCAP documents (full document handling)
171 1 Redmine Admin
172 2 Redmine Admin
In the examples folder there are sample XCAP XML documents used for the examples below:
173 3 Redmine Admin
174 20 Adrian Georgescu
175 34 Adrian Georgescu
h3. PUT
176 34 Adrian Georgescu
177 34 Adrian Georgescu
178 2 Redmine Admin
To a document, for example, presence rules:
179 2 Redmine Admin
180 34 Adrian Georgescu
<pre>
181 1 Redmine Admin
xcapclient -i pres-rules.xml put
182 34 Adrian Georgescu
</pre>
183 1 Redmine Admin
184 1 Redmine Admin
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:
185 2 Redmine Admin
186 34 Adrian Georgescu
<pre>
187 1 Redmine Admin
url: http://xcap.example.com/xcap-root/resource-lists/users/alice@example.com/index.xml
188 1 Redmine Admin
201 Created
189 2 Redmine Admin
etag: "856bdac9012ee28e46cebb81e51ac2a0"
190 34 Adrian Georgescu
</pre>
191 1 Redmine Admin
192 1 Redmine Admin
193 34 Adrian Georgescu
h3. GET
194 34 Adrian Georgescu
195 34 Adrian Georgescu
196 34 Adrian Georgescu
<pre>
197 2 Redmine Admin
xcapclient --app resource-lists get
198 34 Adrian Georgescu
</pre>
199 1 Redmine Admin
200 1 Redmine Admin
or
201 1 Redmine Admin
202 34 Adrian Georgescu
<pre>
203 1 Redmine Admin
xcapclient --app pres-rules get
204 34 Adrian Georgescu
</pre>
205 2 Redmine Admin
206 2 Redmine Admin
or
207 2 Redmine Admin
208 34 Adrian Georgescu
<pre>
209 1 Redmine Admin
xcapclient --app rls-services get
210 34 Adrian Georgescu
</pre>
211 2 Redmine Admin
212 1 Redmine Admin
This will print the document you've just put, along with its tag.
213 1 Redmine Admin
214 1 Redmine Admin
or
215 2 Redmine Admin
216 34 Adrian Georgescu
<pre>
217 1 Redmine Admin
xcapclient --app xcap-caps get
218 34 Adrian Georgescu
</pre>
219 2 Redmine Admin
220 2 Redmine Admin
will print the capabilities of the XCAP server.
221 2 Redmine Admin
222 1 Redmine Admin
223 34 Adrian Georgescu
h3. DELETE
224 34 Adrian Georgescu
225 34 Adrian Georgescu
226 34 Adrian Georgescu
<pre>
227 2 Redmine Admin
xcapclient --app resource-lists delete
228 34 Adrian Georgescu
</pre>
229 1 Redmine Admin
230 2 Redmine Admin
and
231 2 Redmine Admin
232 34 Adrian Georgescu
<pre>
233 1 Redmine Admin
xcapclient --app pres-rules delete
234 34 Adrian Georgescu
</pre>
235 2 Redmine Admin
236 1 Redmine Admin
and
237 2 Redmine Admin
238 34 Adrian Georgescu
<pre>
239 1 Redmine Admin
xcapclient --app rls-services  delete
240 34 Adrian Georgescu
</pre>
241 1 Redmine Admin
242 2 Redmine Admin
Operating on XML elements (partial document handling)
243 2 Redmine Admin
244 2 Redmine Admin
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.
245 2 Redmine Admin
246 2 Redmine Admin
Let's put the document in section 1 again to server, so we can fetch some elements from it.
247 2 Redmine Admin
248 34 Adrian Georgescu
<pre>
249 2 Redmine Admin
xcapclient --app resource-lists get '/resource-lists/list[@name="friends"]/entry[1]/display-name'
250 34 Adrian Georgescu
</pre>
251 2 Redmine Admin
252 34 Adrian Georgescu
<pre>
253 2 Redmine Admin
etag: "856bdac9012ee28e46cebb81e51ac2a0"
254 2 Redmine Admin
<display-name>Bill Doe</display-name>
255 34 Adrian Georgescu
</pre>
256 2 Redmine Admin
257 2 Redmine Admin
Specifying application with --app, is no longer necessary as it may be guessed from the node selector.
258 2 Redmine Admin
259 2 Redmine Admin
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:
260 29 Adrian Georgescu
261 34 Adrian Georgescu
<pre>
262 2 Redmine Admin
xcapclient -i bill_display_name_fixed.xml put '/resource-lists/list[@name="friends"]/entry[1]/display-name'
263 34 Adrian Georgescu
</pre>
264 2 Redmine Admin
265 2 Redmine Admin
To insert a new element one must construct a node selector that doesn't point to an existing element.
266 2 Redmine Admin
267 34 Adrian Georgescu
<pre>
268 2 Redmine Admin
xcapclient -i alice.xml put '/resource-lists/list[@name="friends"]/entry[1][@uri="sip:alice@example.com"]'
269 34 Adrian Georgescu
</pre>
270 2 Redmine Admin
271 34 Adrian Georgescu
<pre>
272 2 Redmine Admin
201 Created
273 2 Redmine Admin
etag: "bfbd38bed7163dd19e6e110d0dfa0876"
274 34 Adrian Georgescu
</pre>
275 2 Redmine Admin
276 2 Redmine Admin
This will shift Bill's entry to the second position.
277 2 Redmine Admin
278 1 Redmine Admin
See README of python-xcaplib package for more detailed examples on how to create/retrieve XCAP documents.
279 4 Redmine Admin
280 1 Redmine Admin
281 34 Adrian Georgescu
h2. SIP SIMPLE client SDK
282 34 Adrian Georgescu
283 34 Adrian Georgescu
284 8 Adrian Georgescu
You can download the command Line Tools for SIP SIMPLE client SDK from http://SipSimpleClient.com
285 8 Adrian Georgescu
286 8 Adrian Georgescu
Create an account:
287 8 Adrian Georgescu
288 34 Adrian Georgescu
<pre>
289 8 Adrian Georgescu
sip-settings -a add user@domain
290 34 Adrian Georgescu
</pre>
291 8 Adrian Georgescu
292 8 Adrian Georgescu
Set the newly created account as default:
293 8 Adrian Georgescu
294 34 Adrian Georgescu
<pre>
295 8 Adrian Georgescu
sip-settings -a default user@domain
296 34 Adrian Georgescu
</pre>
297 8 Adrian Georgescu
298 8 Adrian Georgescu
Set the xcap root:
299 8 Adrian Georgescu
300 34 Adrian Georgescu
<pre>
301 8 Adrian Georgescu
sip-settings -a set xcap.xcap_root=http://xcap.example.com/xcap-root/
302 8 Adrian Georgescu
sip-settings -a set xcap.enabled=True
303 34 Adrian Georgescu
</pre>
304 7 Adrian Georgescu
305 7 Adrian Georgescu
The following Command Line Tools are available for testing XCAP:
306 7 Adrian Georgescu
307 34 Adrian Georgescu
* Manage pres-rules document: "xcap-pres-rules":http://sipsimpleclient.com/wiki/xcap_pres_rules
308 34 Adrian Georgescu
* Manage rls-services document: "xcap-rls-services":http://sipsimpleclient.com/wiki/xcap_rls_services
309 34 Adrian Georgescu
* Manage icon: "xcap-icon":http://sipsimpleclient.com/wiki/xcap_icon
310 34 Adrian Georgescu
* Retrieve xcap-directory document: "xcap-directory":http://sipsimpleclient.com/wiki/xcap_directory