Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,53 @@ jobs:
secrets:
IGNITE_REALTIME_MAVEN_USERNAME: ${{ secrets.IGNITE_REALTIME_MAVEN_USERNAME }}
IGNITE_REALTIME_MAVEN_PASSWORD: ${{ secrets.IGNITE_REALTIME_MAVEN_PASSWORD }}
hurl-e2e-test:
name: Hurl E2E Tests
runs-on: ubuntu-latest
needs: build
permissions:
checks: write
steps:
- name: Checkout tests
uses: actions/checkout@v5
with:
sparse-checkout: |
test

- name: Download the built plugin
uses: actions/download-artifact@v6
with:
name: restAPI
path: .

- name: Rename plugin
run: |
mv restAPI-openfire-plugin-assembly.jar restAPI.jar

- name: Run Openfire
uses: igniterealtime/launch-openfire-action@main # Should this be tied to the Openfire version?
with:
version: 5.0.2
config: ./test/demoboot-with-additions.xml
plugin: ./restAPI.jar

- uses: gacts/install-hurl@v1

- name: Test the plugin
run: |
hurl --test --report-junit test-results.xml --variables-file test/test.env --jobs 1 test/*.hurl

- name: Expose Openfire logs
uses: actions/upload-artifact@v5
if: always() # always run even if the previous step fails
with:
name: Openfire server logs
path: openfire/logs/*

- name: Publish Test Report
uses: mikepenz/action-junit-report@v6
if: always() # always run even if the previous step fails
with:
report_paths: 'test-results.xml'
include_passed: true
detailed_summary: true
1 change: 1 addition & 0 deletions changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ <h1>
<p><b>1.12.1</b> (to be determined)</p>
<ul>
<li>[<a href="https://github.com/igniterealtime/openfire-restAPI-plugin/issues/213">#213</a>] - Improve setting a subject in a chat room</li>
<li>[<a href="https://github.com/igniterealtime/openfire-restAPI-plugin/issues/217">#217</a>] - Add Hurl e2e tests, and CI to run them</li>
</ul>

<p><b>1.12.0</b> July 4, 2025</p>
Expand Down
11 changes: 11 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Tests

The tests contained in this folder are written in Hurl (see [docs](https://hurl.dev/docs/manual.html)).

Install Hurl with instructions as per the documentation.

Configure the Rest API:

* Enable it
* Set auth for shared key, and set the value in test.env
* Set `adminConsole.access.allow-wildcards-in-excludes` to true
14 changes: 14 additions & 0 deletions test/chatrooms.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
GET http://localhost:9090/plugins/restapi/v1/chatrooms
Authorization: {{authkey}}
HTTP 200

GET http://localhost:9090/plugins/restapi/v1/sessions
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/sessions[not(child::node())]" count == 1 # sessions at the root, with no child nodes


GET http://localhost:9090/plugins/restapi/v1/system/readiness/server
Authorization: {{authkey}}
HTTP 200
8 changes: 8 additions & 0 deletions test/chatservice.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
GET http://localhost:9090/plugins/restapi/v1/chatservices
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/chatServices/chatService" count == 1
xpath "string(/chatServices/chatService/serviceName)" == "conference"
xpath "string(/chatServices/chatService/description)" == "Public Chatrooms"
xpath "string(/chatServices/chatService/hidden)" == "false"
11 changes: 11 additions & 0 deletions test/clustering.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
GET {{host}}/plugins/restapi/v1/clustering/status
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "string(/clustering/status)" == "Disabled"

GET {{host}}/plugins/restapi/v1/clustering/nodes
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/clusterNodes[not(child::node())]" exists
64 changes: 64 additions & 0 deletions test/demoboot-with-additions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<jive>
<plugin>
<restapi>
<enabled>true</enabled>
<httpAuth>secret</httpAuth>
<secret>potato</secret>
</restapi>
</plugin>
<adminConsole>
<access>
<allow-wildcards-in-excludes>true</allow-wildcards-in-excludes>
</access>
<port>9090</port>
<securePort>9091</securePort>
</adminConsole>
<connectionProvider>
<className>org.jivesoftware.database.EmbeddedConnectionProvider</className>
</connectionProvider>
<autosetup>
<run>true</run>
<locale>en</locale>
<xmpp>
<auth>
<anonymous>true</anonymous>
</auth>
<domain>example.org</domain>
<fqdn>example.org</fqdn>
</xmpp>
<database>
<mode>embedded</mode>
</database>
<admin>
<email>admin@example.com</email>
<password>admin</password>
</admin>
<users>
<user1>
<username>john</username>
<password>secret</password>
<name>John Doe</name>
<email>john.doe@example.com</email>
<roster>
<item1>
<jid>jane@example.org</jid>
<nickname>Jane</nickname>
</item1>
</roster>
</user1>
<user2>
<username>jane</username>
<password>secret</password>
<name>Jane Doe</name>
<email>jane.doe@example.com</email>
<roster>
<item1>
<jid>john@example.org</jid>
<nickname>John</nickname>
</item1>
</roster>
</user2>
</users>
</autosetup>
</jive>
69 changes: 69 additions & 0 deletions test/groups.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

GET http://localhost:9090/plugins/restapi/v1/groups
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/groups[not(child::node())]" exists # groups at the root, with no child nodes

POST http://localhost:9090/plugins/restapi/v1/groups
Authorization: {{authkey}}
Content-Type: application/xml
```
<?xml version="1.0" encoding="UTF-8"?>
<group>
<name>group1</name>
<description>test-group</description>
<shared>false</shared>
<admins>
<admin>jane</admin>
</admins>
<members>
<member>john</member>
</members>
</group>
```
HTTP 201

GET http://localhost:9090/plugins/restapi/v1/groups # check if the group was created
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/groups/group[name='group1']" exists

GET http://localhost:9090/plugins/restapi/v1/groups/group1
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/group[name='group1']" exists
xpath "string(/group/description)" == "test-group"

PUT http://localhost:9090/plugins/restapi/v1/groups/group1
Authorization: {{authkey}}
Content-Type: application/xml
```
<?xml version="1.0" encoding="UTF-8"?>
<group>
<name>group1</name>
<description>test-group-updated</description>
<shared>false</shared>
<admins>
<admin>jane</admin>
</admins>
<members>
<member>john</member>
</members>
</group>
```
HTTP 200

GET http://localhost:9090/plugins/restapi/v1/groups/group1
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/group[name='group1']" exists
xpath "string(/group/description)" == "test-group-updated"

DELETE http://localhost:9090/plugins/restapi/v1/groups/group1
Authorization: {{authkey}}
HTTP 200

8 changes: 8 additions & 0 deletions test/messagearchive.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
GET http://localhost:9090/plugins/restapi/v1/archive/messages/unread/john@example.org
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "string(/archive/jid)" == "john@example.org"
xpath "string(/archive/count)" == "0"

# TODO: How to get this >0 ?
12 changes: 12 additions & 0 deletions test/messagebroadcast.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
POST http://localhost:9090/plugins/restapi/v1/messages/users
Authorization: {{authkey}}
Content-Type: application/xml
```
<?xml version="1.0" encoding="UTF-8"?>
<message>
<body>test</body>
</message>
```
HTTP 201

# TODO: What could validate behaviour?
11 changes: 11 additions & 0 deletions test/securitylog.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
GET http://localhost:9090/plugins/restapi/v1/logs/security
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/logs/log" count == 0 # TODO: How to make this have 1+ events
#xpath "/logs/log/details" exists
#xpath "/logs/log/logId" exists
#xpath "/logs/log/node" exists
#xpath "/logs/log/summary" exists
#xpath "/logs/log/timestamp" exists
#xpath "/logs/log/username" exists
20 changes: 20 additions & 0 deletions test/sessions.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
GET http://localhost:9090/plugins/restapi/v1/sessions
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/sessions" exists

GET http://localhost:9090/plugins/restapi/v1/sessions/john
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/sessions" exists

# TODO: This documents behaviour, but is it correct??
GET http://localhost:9090/plugins/restapi/v1/sessions/nonexistent
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/sessions" exists

# TODO: create a session (somehow), then read its props, then kick it with DELETE
6 changes: 6 additions & 0 deletions test/statistics.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
GET http://localhost:9090/plugins/restapi/v1/system/statistics/sessions
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/sessions/clusterSessions" exists
xpath "/sessions/localSessions" exists
Loading
Loading