Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hurl tests with CI #202

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
48 changes: 48 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,51 @@ jobs:
secrets:
IGNITE_REALTIME_MAVEN_USERNAME: ${{ secrets.IGNITE_REALTIME_MAVEN_USERNAME }}
IGNITE_REALTIME_MAVEN_PASSWORD: ${{ secrets.IGNITE_REALTIME_MAVEN_PASSWORD }}
test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout tests
uses: actions/checkout@v4
with:
sparse-checkout: |
test

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

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

- name: Run Openfire
uses: igniterealtime/[email protected]
with:
version: 4.9.0
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@v4
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@v4
if: always() # always run even if the previous step fails
with:
report_paths: 'test-results.xml'
suite_regex: '*'
include_passed: true
detailed_summary: true
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>[email protected]</email>
<password>admin</password>
</admin>
<users>
<user1>
<username>john</username>
<password>secret</password>
<name>John Doe</name>
<email>[email protected]</email>
<roster>
<item1>
<jid>[email protected]</jid>
<nickname>Jane</nickname>
</item1>
</roster>
</user1>
<user2>
<username>jane</username>
<password>secret</password>
<name>Jane Doe</name>
<email>[email protected]</email>
<roster>
<item1>
<jid>[email protected]</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/[email protected]
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "string(/archive/jid)" == "[email protected]"
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
86 changes: 86 additions & 0 deletions test/system.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
GET http://localhost:9090/plugins/restapi/v1/system/liveness
Authorization: {{authkey}}
HTTP 200

GET http://localhost:9090/plugins/restapi/v1/system/liveness/deadlock
Authorization: {{authkey}}
HTTP 200

GET http://localhost:9090/plugins/restapi/v1/system/liveness/properties
Authorization: {{authkey}}
HTTP 200

GET http://localhost:9090/plugins/restapi/v1/system/readiness
Authorization: {{authkey}}
HTTP 200

GET http://localhost:9090/plugins/restapi/v1/system/readiness/cluster
Authorization: {{authkey}}
HTTP 200

GET http://localhost:9090/plugins/restapi/v1/system/readiness/connections
Authorization: {{authkey}}
HTTP 200

GET http://localhost:9090/plugins/restapi/v1/system/readiness/plugins
Authorization: {{authkey}}
HTTP 200

GET http://localhost:9090/plugins/restapi/v1/system/readiness/server
Authorization: {{authkey}}
HTTP 200

GET http://localhost:9090/plugins/restapi/v1/system/properties
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/properties/property" count > 150
# TODO test that property with attribute key=admin.authorizedJIDs exists
# TODO test that property with attribute key=plugin.restapi.enabled has value=true

POST http://localhost:9090/plugins/restapi/v1/system/properties
Authorization: {{authkey}}
Content-Type: application/xml
```
<?xml version="1.0" encoding="UTF-8"?>
<property key="test.key" value="test-value" />
```
HTTP 201

GET http://localhost:9090/plugins/restapi/v1/system/properties/test.key
Authorization: {{authkey}}
HTTP 200
[Asserts]
xpath "/property" count == 1
# TODO test that property with attribute key=test.key has value=test-value

PUT http://localhost:9090/plugins/restapi/v1/system/properties/test.key
Authorization: {{authkey}}
Content-Type: application/xml
```
<?xml version="1.0" encoding="UTF-8"?>
<property key="test.key" value="new-value" />
```
HTTP 200

PUT http://localhost:9090/plugins/restapi/v1/system/properties/wrong.key
Authorization: {{authkey}}
Content-Type: application/xml
```
<?xml version="1.0" encoding="UTF-8"?>
<property key="wrong.key" value="new-value" />
```
HTTP 404

PUT http://localhost:9090/plugins/restapi/v1/system/properties/test.key
Authorization: {{authkey}}
Content-Type: application/xml
```
<?xml version="1.0" encoding="UTF-8"?>
<property key="wrong.key" value="new-value" />
```
HTTP 400

DELETE http://localhost:9090/plugins/restapi/v1/system/properties/test.key
Authorization: {{authkey}}
HTTP 200
2 changes: 2 additions & 0 deletions test/test.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
host=http://localhost:9090
authkey=potato
Loading
Loading