Skip to content

Commit 8900d82

Browse files
committed
Hurl tests with CI
1 parent ae85c60 commit 8900d82

5 files changed

Lines changed: 251 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,76 @@ jobs:
88
secrets:
99
IGNITE_REALTIME_MAVEN_USERNAME: ${{ secrets.IGNITE_REALTIME_MAVEN_USERNAME }}
1010
IGNITE_REALTIME_MAVEN_PASSWORD: ${{ secrets.IGNITE_REALTIME_MAVEN_PASSWORD }}
11+
test:
12+
runs-on: ubuntu-latest
13+
needs: build
14+
steps:
15+
- name: Checkout tests
16+
uses: actions/checkout@v4
17+
with:
18+
sparse-checkout: |
19+
test
20+
21+
- name: Checkout Openfire actions e.g. 'startCIServer'
22+
uses: actions/checkout@v4
23+
with:
24+
repository: igniterealtime/Openfire
25+
path: openfire-ci
26+
sparse-checkout: |
27+
.github
28+
29+
- name: Download a recent Openfire daily build.
30+
run: |
31+
# This tries to find the most recent daily build, going back 30 days if none are available.
32+
#Note that the cache above will cause whatever build that's download to be considered 'todays' build.
33+
for i in $(seq 0 30); do
34+
STAMP=`date --date="$i day ago" +%F`;
35+
echo "Attempting to download Openfire build for $STAMP"
36+
curl --fail -L "https://download.igniterealtime.org/openfire/dailybuilds/openfire_$STAMP.tar.gz" -o openfire.tar.gz && break
37+
done
38+
39+
- name: Extract Openfire
40+
run: |
41+
tar -xzf openfire.tar.gz
42+
43+
- name: Set up yq
44+
uses: frenck/action-setup-yq@v1
45+
46+
- name: Copy in the extended demoboot config
47+
run: |
48+
rm openfire/conf/openfire.xml
49+
cp ./test/demoboot-with-additions.xml openfire/conf/openfire-demoboot.xml
50+
51+
- name: Start CI server from distribution
52+
id: startCIServer
53+
uses: ./openfire-ci/.github/actions/startserver-action
54+
with:
55+
distBaseDir: './openfire'
56+
domain: 'example.org'
57+
ip: '127.0.0.1'
58+
59+
- name: Download the built artifacts
60+
uses: actions/download-artifact@v4
61+
with:
62+
name: restAPI
63+
path: .
64+
65+
- name: Install plugin
66+
run: |
67+
cp restAPI-openfire-plugin-assembly.jar openfire/plugins/restAPI.jar
68+
69+
- uses: gacts/install-hurl@v1
70+
71+
- name: Test the plugin
72+
run: |
73+
# Wait for the server to start
74+
sleep 30
75+
# Test the plugin
76+
hurl --test test/restAPI.hurl
77+
78+
- name: Expose Openfire logs
79+
uses: actions/upload-artifact@v4
80+
if: always() # always run even if the previous step fails
81+
with:
82+
name: Openfire server logs
83+
path: openfire/logs/*

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

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
### CLUSTERING ###
2+
3+
GET {{host}}/plugins/restapi/v1/clustering/status
4+
Authorization: {{authkey}}
5+
HTTP 200
6+
[Asserts]
7+
xpath "string(/clustering/status)" == "Disabled"
8+
9+
GET {{host}}/plugins/restapi/v1/clustering/nodes
10+
Authorization: {{authkey}}
11+
HTTP 200
12+
[Asserts]
13+
xpath "/clusterNodes[not(child::node())]" exists
14+
15+
16+
### USER GROUPS ###
17+
18+
GET http://localhost:9090/plugins/restapi/v1/groups
19+
Authorization: {{authkey}}
20+
HTTP 200
21+
[Asserts]
22+
xpath "/groups[not(child::node())]" exists # groups at the root, with no child nodes
23+
24+
POST http://localhost:9090/plugins/restapi/v1/groups
25+
Authorization: {{authkey}}
26+
Content-Type: application/xml
27+
```
28+
<?xml version="1.0" encoding="UTF-8"?>
29+
<group>
30+
<name>group1</name>
31+
<description>test-group</description>
32+
<shared>false</shared>
33+
<admins>
34+
<admin>jane</admin>
35+
</admins>
36+
<members>
37+
<member>john</member>
38+
</members>
39+
</group>
40+
```
41+
HTTP 201
42+
43+
GET http://localhost:9090/plugins/restapi/v1/groups # check if the group was created
44+
Authorization: {{authkey}}
45+
HTTP 200
46+
[Asserts]
47+
xpath "/groups/group[name='group1']" exists
48+
49+
GET http://localhost:9090/plugins/restapi/v1/groups/group1
50+
Authorization: {{authkey}}
51+
HTTP 200
52+
[Asserts]
53+
xpath "/group[name='group1']" exists
54+
xpath "string(/group/description)" == "test-group"
55+
56+
PUT http://localhost:9090/plugins/restapi/v1/groups/group1
57+
Authorization: {{authkey}}
58+
Content-Type: application/xml
59+
```
60+
<?xml version="1.0" encoding="UTF-8"?>
61+
<group>
62+
<name>group1</name>
63+
<description>test-group-updated</description>
64+
<shared>false</shared>
65+
<admins>
66+
<admin>jane</admin>
67+
</admins>
68+
<members>
69+
<member>john</member>
70+
</members>
71+
</group>
72+
```
73+
HTTP 200
74+
75+
GET http://localhost:9090/plugins/restapi/v1/groups/group1
76+
Authorization: {{authkey}}
77+
HTTP 200
78+
[Asserts]
79+
xpath "/group[name='group1']" exists
80+
xpath "string(/group/description)" == "test-group-updated"
81+
82+
DELETE http://localhost:9090/plugins/restapi/v1/groups/group1
83+
Authorization: {{authkey}}
84+
HTTP 200
85+
86+
87+
### CHAT ROOMS ###
88+
GET http://localhost:9090/plugins/restapi/v1/chatrooms
89+
Authorization: {{authkey}}
90+
HTTP 200
91+
92+
GET http://localhost:9090/plugins/restapi/v1/sessions
93+
Authorization: {{authkey}}
94+
HTTP 200
95+
[Asserts]
96+
xpath "/sessions[not(child::node())]" count == 1 # sessions at the root, with no child nodes
97+
98+
99+
GET http://localhost:9090/plugins/restapi/v1/system/readiness/server
100+
Authorization: {{authkey}}
101+
HTTP 200

test/test.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
host=http://localhost:9090
2+
authkey=potato

0 commit comments

Comments
 (0)