Skip to content

Commit f53bd90

Browse files
authored
Hurl tests with CI (#202)
* Hurl tests with CI * Switch to new launch-openfire action * Remove unnecessary wait * Split tests into separate files * Add additional tests * Expose test results * Fix broken test in CI * Bump action versions * Bump Openfire version in tests * Add changelog entry * More descriptive CI step * Switch launch-openfire-action to using main * Fix test reporter config
1 parent 6b7de5c commit f53bd90

16 files changed

Lines changed: 483 additions & 0 deletions

.github/workflows/build.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,53 @@ jobs:
88
secrets:
99
IGNITE_REALTIME_MAVEN_USERNAME: ${{ secrets.IGNITE_REALTIME_MAVEN_USERNAME }}
1010
IGNITE_REALTIME_MAVEN_PASSWORD: ${{ secrets.IGNITE_REALTIME_MAVEN_PASSWORD }}
11+
hurl-e2e-test:
12+
name: Hurl E2E Tests
13+
runs-on: ubuntu-latest
14+
needs: build
15+
permissions:
16+
checks: write
17+
steps:
18+
- name: Checkout tests
19+
uses: actions/checkout@v5
20+
with:
21+
sparse-checkout: |
22+
test
23+
24+
- name: Download the built plugin
25+
uses: actions/download-artifact@v6
26+
with:
27+
name: restAPI
28+
path: .
29+
30+
- name: Rename plugin
31+
run: |
32+
mv restAPI-openfire-plugin-assembly.jar restAPI.jar
33+
34+
- name: Run Openfire
35+
uses: igniterealtime/launch-openfire-action@main # Should this be tied to the Openfire version?
36+
with:
37+
version: 5.0.2
38+
config: ./test/demoboot-with-additions.xml
39+
plugin: ./restAPI.jar
40+
41+
- uses: gacts/install-hurl@v1
42+
43+
- name: Test the plugin
44+
run: |
45+
hurl --test --report-junit test-results.xml --variables-file test/test.env --jobs 1 test/*.hurl
46+
47+
- name: Expose Openfire logs
48+
uses: actions/upload-artifact@v5
49+
if: always() # always run even if the previous step fails
50+
with:
51+
name: Openfire server logs
52+
path: openfire/logs/*
53+
54+
- name: Publish Test Report
55+
uses: mikepenz/action-junit-report@v6
56+
if: always() # always run even if the previous step fails
57+
with:
58+
report_paths: 'test-results.xml'
59+
include_passed: true
60+
detailed_summary: true

changelog.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ <h1>
4747
<p><b>1.12.1</b> (to be determined)</p>
4848
<ul>
4949
<li>[<a href="https://github.com/igniterealtime/openfire-restAPI-plugin/issues/213">#213</a>] - Improve setting a subject in a chat room</li>
50+
<li>[<a href="https://github.com/igniterealtime/openfire-restAPI-plugin/issues/217">#217</a>] - Add Hurl e2e tests, and CI to run them</li>
5051
</ul>
5152

5253
<p><b>1.12.0</b> July 4, 2025</p>

test/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Tests
2+
3+
The tests contained in this folder are written in Hurl (see [docs](https://hurl.dev/docs/manual.html)).
4+
5+
Install Hurl with instructions as per the documentation.
6+
7+
Configure the Rest API:
8+
9+
* Enable it
10+
* Set auth for shared key, and set the value in test.env
11+
* Set `adminConsole.access.allow-wildcards-in-excludes` to true

test/chatrooms.hurl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
GET http://localhost:9090/plugins/restapi/v1/chatrooms
2+
Authorization: {{authkey}}
3+
HTTP 200
4+
5+
GET http://localhost:9090/plugins/restapi/v1/sessions
6+
Authorization: {{authkey}}
7+
HTTP 200
8+
[Asserts]
9+
xpath "/sessions[not(child::node())]" count == 1 # sessions at the root, with no child nodes
10+
11+
12+
GET http://localhost:9090/plugins/restapi/v1/system/readiness/server
13+
Authorization: {{authkey}}
14+
HTTP 200

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/clustering.hurl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
GET {{host}}/plugins/restapi/v1/clustering/status
2+
Authorization: {{authkey}}
3+
HTTP 200
4+
[Asserts]
5+
xpath "string(/clustering/status)" == "Disabled"
6+
7+
GET {{host}}/plugins/restapi/v1/clustering/nodes
8+
Authorization: {{authkey}}
9+
HTTP 200
10+
[Asserts]
11+
xpath "/clusterNodes[not(child::node())]" exists

test/demoboot-with-additions.xml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jive>
3+
<plugin>
4+
<restapi>
5+
<enabled>true</enabled>
6+
<httpAuth>secret</httpAuth>
7+
<secret>potato</secret>
8+
</restapi>
9+
</plugin>
10+
<adminConsole>
11+
<access>
12+
<allow-wildcards-in-excludes>true</allow-wildcards-in-excludes>
13+
</access>
14+
<port>9090</port>
15+
<securePort>9091</securePort>
16+
</adminConsole>
17+
<connectionProvider>
18+
<className>org.jivesoftware.database.EmbeddedConnectionProvider</className>
19+
</connectionProvider>
20+
<autosetup>
21+
<run>true</run>
22+
<locale>en</locale>
23+
<xmpp>
24+
<auth>
25+
<anonymous>true</anonymous>
26+
</auth>
27+
<domain>example.org</domain>
28+
<fqdn>example.org</fqdn>
29+
</xmpp>
30+
<database>
31+
<mode>embedded</mode>
32+
</database>
33+
<admin>
34+
<email>admin@example.com</email>
35+
<password>admin</password>
36+
</admin>
37+
<users>
38+
<user1>
39+
<username>john</username>
40+
<password>secret</password>
41+
<name>John Doe</name>
42+
<email>john.doe@example.com</email>
43+
<roster>
44+
<item1>
45+
<jid>jane@example.org</jid>
46+
<nickname>Jane</nickname>
47+
</item1>
48+
</roster>
49+
</user1>
50+
<user2>
51+
<username>jane</username>
52+
<password>secret</password>
53+
<name>Jane Doe</name>
54+
<email>jane.doe@example.com</email>
55+
<roster>
56+
<item1>
57+
<jid>john@example.org</jid>
58+
<nickname>John</nickname>
59+
</item1>
60+
</roster>
61+
</user2>
62+
</users>
63+
</autosetup>
64+
</jive>

test/groups.hurl

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
GET http://localhost:9090/plugins/restapi/v1/groups
3+
Authorization: {{authkey}}
4+
HTTP 200
5+
[Asserts]
6+
xpath "/groups[not(child::node())]" exists # groups at the root, with no child nodes
7+
8+
POST http://localhost:9090/plugins/restapi/v1/groups
9+
Authorization: {{authkey}}
10+
Content-Type: application/xml
11+
```
12+
<?xml version="1.0" encoding="UTF-8"?>
13+
<group>
14+
<name>group1</name>
15+
<description>test-group</description>
16+
<shared>false</shared>
17+
<admins>
18+
<admin>jane</admin>
19+
</admins>
20+
<members>
21+
<member>john</member>
22+
</members>
23+
</group>
24+
```
25+
HTTP 201
26+
27+
GET http://localhost:9090/plugins/restapi/v1/groups # check if the group was created
28+
Authorization: {{authkey}}
29+
HTTP 200
30+
[Asserts]
31+
xpath "/groups/group[name='group1']" exists
32+
33+
GET http://localhost:9090/plugins/restapi/v1/groups/group1
34+
Authorization: {{authkey}}
35+
HTTP 200
36+
[Asserts]
37+
xpath "/group[name='group1']" exists
38+
xpath "string(/group/description)" == "test-group"
39+
40+
PUT http://localhost:9090/plugins/restapi/v1/groups/group1
41+
Authorization: {{authkey}}
42+
Content-Type: application/xml
43+
```
44+
<?xml version="1.0" encoding="UTF-8"?>
45+
<group>
46+
<name>group1</name>
47+
<description>test-group-updated</description>
48+
<shared>false</shared>
49+
<admins>
50+
<admin>jane</admin>
51+
</admins>
52+
<members>
53+
<member>john</member>
54+
</members>
55+
</group>
56+
```
57+
HTTP 200
58+
59+
GET http://localhost:9090/plugins/restapi/v1/groups/group1
60+
Authorization: {{authkey}}
61+
HTTP 200
62+
[Asserts]
63+
xpath "/group[name='group1']" exists
64+
xpath "string(/group/description)" == "test-group-updated"
65+
66+
DELETE http://localhost:9090/plugins/restapi/v1/groups/group1
67+
Authorization: {{authkey}}
68+
HTTP 200
69+

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?

0 commit comments

Comments
 (0)