Skip to content

Commit f23e4d8

Browse files
committed
Add additional tests
1 parent aefc460 commit f23e4d8

8 files changed

Lines changed: 261 additions & 0 deletions

File tree

test/chatservice.hurl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
GET http://localhost:9090/plugins/restapi/v1/chatservices
2+
Authorization: {{authkey}}
3+
HTTP 200
4+
[Asserts]
5+
xpath "/chatServices/chatService" count == 1
6+
xpath "string(/chatServices/chatService/serviceName)" == "conference"
7+
xpath "string(/chatServices/chatService/description)" == "Public Chatrooms"
8+
xpath "string(/chatServices/chatService/hidden)" == "false"

test/messagearchive.hurl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
GET http://localhost:9090/plugins/restapi/v1/archive/messages/unread/john@example.org
2+
Authorization: {{authkey}}
3+
HTTP 200
4+
[Asserts]
5+
xpath "string(/archive/jid)" == "john@example.org"
6+
xpath "string(/archive/count)" == "0"
7+
8+
# TODO: How to get this >0 ?

test/messagebroadcast.hurl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
POST http://localhost:9090/plugins/restapi/v1/messages/users
2+
Authorization: {{authkey}}
3+
Content-Type: application/xml
4+
```
5+
<?xml version="1.0" encoding="UTF-8"?>
6+
<message>
7+
<body>test</body>
8+
</message>
9+
```
10+
HTTP 201
11+
12+
# TODO: What could validate behaviour?

test/securitylog.hurl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
GET http://localhost:9090/plugins/restapi/v1/logs/security
2+
Authorization: {{authkey}}
3+
HTTP 200
4+
[Asserts]
5+
xpath "/logs/log" count >= 1 # Minimum of 'plugin loaded'?
6+
xpath "/logs/log/details" exists
7+
xpath "/logs/log/logId" exists
8+
xpath "/logs/log/node" exists
9+
xpath "/logs/log/summary" exists
10+
xpath "/logs/log/timestamp" exists
11+
xpath "/logs/log/username" exists

test/sessions.hurl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
GET http://localhost:9090/plugins/restapi/v1/sessions
2+
Authorization: {{authkey}}
3+
HTTP 200
4+
[Asserts]
5+
xpath "/sessions" exists
6+
7+
GET http://localhost:9090/plugins/restapi/v1/sessions/john
8+
Authorization: {{authkey}}
9+
HTTP 200
10+
[Asserts]
11+
xpath "/sessions" exists
12+
13+
# TODO: This documents behaviour, but is it correct??
14+
GET http://localhost:9090/plugins/restapi/v1/sessions/nonexistent
15+
Authorization: {{authkey}}
16+
HTTP 200
17+
[Asserts]
18+
xpath "/sessions" exists
19+
20+
# TODO: create a session (somehow), then read its props, then kick it with DELETE

test/statistics.hurl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
GET http://localhost:9090/plugins/restapi/v1/system/statistics/sessions
2+
Authorization: {{authkey}}
3+
HTTP 200
4+
[Asserts]
5+
xpath "/sessions/clusterSessions" exists
6+
xpath "/sessions/localSessions" exists

test/system.hurl

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
GET http://localhost:9090/plugins/restapi/v1/system/liveness
2+
Authorization: {{authkey}}
3+
HTTP 200
4+
5+
GET http://localhost:9090/plugins/restapi/v1/system/liveness/deadlock
6+
Authorization: {{authkey}}
7+
HTTP 200
8+
9+
GET http://localhost:9090/plugins/restapi/v1/system/liveness/properties
10+
Authorization: {{authkey}}
11+
HTTP 200
12+
13+
GET http://localhost:9090/plugins/restapi/v1/system/readiness
14+
Authorization: {{authkey}}
15+
HTTP 200
16+
17+
GET http://localhost:9090/plugins/restapi/v1/system/readiness/cluster
18+
Authorization: {{authkey}}
19+
HTTP 200
20+
21+
GET http://localhost:9090/plugins/restapi/v1/system/readiness/connections
22+
Authorization: {{authkey}}
23+
HTTP 200
24+
25+
GET http://localhost:9090/plugins/restapi/v1/system/readiness/plugins
26+
Authorization: {{authkey}}
27+
HTTP 200
28+
29+
GET http://localhost:9090/plugins/restapi/v1/system/readiness/server
30+
Authorization: {{authkey}}
31+
HTTP 200
32+
33+
GET http://localhost:9090/plugins/restapi/v1/system/properties
34+
Authorization: {{authkey}}
35+
HTTP 200
36+
[Asserts]
37+
xpath "/properties/property" count > 150
38+
# TODO test that property with attribute key=admin.authorizedJIDs exists
39+
# TODO test that property with attribute key=plugin.restapi.enabled has value=true
40+
41+
POST http://localhost:9090/plugins/restapi/v1/system/properties
42+
Authorization: {{authkey}}
43+
Content-Type: application/xml
44+
```
45+
<?xml version="1.0" encoding="UTF-8"?>
46+
<property key="test.key" value="test-value" />
47+
```
48+
HTTP 201
49+
50+
GET http://localhost:9090/plugins/restapi/v1/system/properties/test.key
51+
Authorization: {{authkey}}
52+
HTTP 200
53+
[Asserts]
54+
xpath "/property" count == 1
55+
# TODO test that property with attribute key=test.key has value=test-value
56+
57+
PUT http://localhost:9090/plugins/restapi/v1/system/properties/test.key
58+
Authorization: {{authkey}}
59+
Content-Type: application/xml
60+
```
61+
<?xml version="1.0" encoding="UTF-8"?>
62+
<property key="test.key" value="new-value" />
63+
```
64+
HTTP 200
65+
66+
PUT http://localhost:9090/plugins/restapi/v1/system/properties/wrong.key
67+
Authorization: {{authkey}}
68+
Content-Type: application/xml
69+
```
70+
<?xml version="1.0" encoding="UTF-8"?>
71+
<property key="wrong.key" value="new-value" />
72+
```
73+
HTTP 404
74+
75+
PUT http://localhost:9090/plugins/restapi/v1/system/properties/test.key
76+
Authorization: {{authkey}}
77+
Content-Type: application/xml
78+
```
79+
<?xml version="1.0" encoding="UTF-8"?>
80+
<property key="wrong.key" value="new-value" />
81+
```
82+
HTTP 400
83+
84+
DELETE http://localhost:9090/plugins/restapi/v1/system/properties/test.key
85+
Authorization: {{authkey}}
86+
HTTP 200

test/users.hurl

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
GET http://localhost:9090/plugins/restapi/v1/users
2+
Authorization: {{authkey}}
3+
HTTP 200
4+
[Asserts]
5+
xpath "/users/user" count == 3
6+
xpath "/users/user[username='admin']" exists
7+
xpath "/users/user[username='jane']" exists
8+
xpath "/users/user[username='john']" exists
9+
xpath "/users/user[name='John Doe']" exists
10+
xpath "/users/user[email='john.doe@example.com']" exists
11+
12+
GET http://localhost:9090/plugins/restapi/v1/users?search=john
13+
Authorization: {{authkey}}
14+
HTTP 200
15+
[Asserts]
16+
xpath "/users/user" count == 1
17+
xpath "/users/user[username='john']" exists
18+
xpath "/users/user[name='John Doe']" exists
19+
xpath "/users/user[email='john.doe@example.com']" exists
20+
21+
# TODO: Add a user with a property to the demoboot
22+
# How to launch with custom demoboot.xml locally?
23+
#GET http://localhost:9090/plugins/restapi/v1/users?propertyKey=tea&propertyValue=earlgreyhot
24+
#Authorization: {{authkey}}
25+
#HTTP 200
26+
#[Asserts]
27+
#xpath "/users/user" count == 1
28+
29+
POST http://localhost:9090/plugins/restapi/v1/users
30+
Authorization: {{authkey}}
31+
Content-Type: application/xml
32+
```
33+
<?xml version="1.0" encoding="UTF-8"?>
34+
<user>
35+
<username>jeanluc</username>
36+
<name>Jean-Luc</name>
37+
<email>jlp@example.com</email>
38+
<password>makeitso</password>
39+
<properties>
40+
<property key="tea" value="earlgreyhot" />
41+
</properties>
42+
</user>
43+
```
44+
HTTP 201
45+
46+
GET http://localhost:9090/plugins/restapi/v1/users?propertyKey=tea&propertyValue=earlgreyhot
47+
Authorization: {{authkey}}
48+
HTTP 200
49+
[Asserts]
50+
xpath "/users/user" count == 1
51+
xpath "string(/users/user/username)" == "jeanluc"
52+
xpath "/users/user[name='Jean-Luc']" exists
53+
xpath "/users/user[email='jlp@example.com']" exists
54+
# TODO xpath for attributes
55+
xpath "/users/user/properties/property" exists
56+
57+
PUT http://localhost:9090/plugins/restapi/v1/users/jeanluc
58+
Authorization: {{authkey}}
59+
Content-Type: application/xml
60+
```
61+
<?xml version="1.0" encoding="UTF-8"?>
62+
<user>
63+
<username>jeanluc</username>
64+
<name>Jean-Luc</name>
65+
<email>jeanluc@example.com</email>
66+
<properties>
67+
<property key="tea" value="earlgreyhot" />
68+
</properties>
69+
</user>
70+
```
71+
HTTP 200
72+
73+
74+
GET http://localhost:9090/plugins/restapi/v1/users/jeanluc
75+
Authorization: {{authkey}}
76+
HTTP 200
77+
[Asserts]
78+
xpath "/user" count == 1
79+
xpath "string(/user/username)" == "jeanluc"
80+
xpath "/user[name='Jean-Luc']" exists
81+
xpath "/user[email='jlp@example.com']" not exists
82+
xpath "/user[email='jeanluc@example.com']" exists
83+
84+
DELETE http://localhost:9090/plugins/restapi/v1/users/jeanluc
85+
Authorization: {{authkey}}
86+
HTTP 200
87+
88+
GET http://localhost:9090/plugins/restapi/v1/users/jeanluc
89+
Authorization: {{authkey}}
90+
HTTP 404
91+
[Asserts]
92+
xpath "string(/error/exception)" == "UserNotFoundException"
93+
xpath "string(/error/message)" == "Could not get user"
94+
xpath "string(/error/resource)" == "jeanluc"
95+
96+
GET http://localhost:9090/plugins/restapi/v1/users/john/roster
97+
Authorization: {{authkey}}
98+
HTTP 200
99+
[Asserts]
100+
xpath "/roster/rosterItem" count == 1
101+
xpath "string(/roster/rosterItem/jid)" == "jane@example.org"
102+
xpath "string(/roster/rosterItem/nickname)" == "Jane"
103+
xpath "string(/roster/rosterItem/subscriptionType)" == "3"
104+
xpath "/roster/rosterItem/groups" exists
105+
106+
# TODO: Roster add/edit/delete
107+
108+
# TODO: Group membership
109+
110+
# TODO: User lockouts

0 commit comments

Comments
 (0)