Skip to content

Commit 6c7c0d5

Browse files
committed
Add scripts for testing purposes
1 parent 415dc32 commit 6c7c0d5

16 files changed

+186
-0
lines changed

devel/scripts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
headers.txt

devel/scripts/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Testing scripts
2+
3+
This directory contains some scripts that you can use to test the API. For them to work, you need to
4+
specify the URL of your Agama server (it might be running, for instance, on a virtual machine):
5+
6+
```
7+
export AGAMA_URL=https://192.168.122.10
8+
```
9+
10+
## Logging in
11+
12+
Before running any other script, you need to log into the API. You can use the `login.sh` script for
13+
that. It will generate a `headers.txt` file that contains the authentication token. By default, it
14+
uses the password `linux`, which is hardcoded into the script.
15+
16+
```
17+
$ ./login.sh
18+
Logging in https://192.168.122.10
19+
Using token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NjU2MzA2MjYsImNsaWVudF9pZCI6IjczNTJmYzFjLWVlNGItNDUzMC05NzY2LTFiMGEyODk3ZDlkZCJ9.fjkk4mab0mTEc-e3IevhKJu2pOkz6Ie0kVQD9GXZ_ZQ
20+
21+
```
22+
23+
## Setting the configuration
24+
25+
The `set-config.sh` script allows to partially update the configuration. It receives a JSON file
26+
containing the body of the PATCH request. Check `examples/*.patch.json` for some examples.
27+
28+
```
29+
$ ./set-config.sh examples/tumbleweed.patch.json
30+
```
31+
32+
You can check the user configuration using the `get-config.sh` script.
33+
34+
## Getting the status
35+
36+
There are a few scripts to retrieve different aspects of the system (status, system information,
37+
configuration, etc.). Check for `get-*.sh` scripts.
38+
39+
## Listening to events
40+
41+
You can listen to Agama events using the `monitor-*.sh` scripts:
42+
43+
- `monitor-websocat.sh`: it relies on [websocat](https://github.com/vi/websocat). Unfortunately, the
44+
program is not available in the official openSUSE repositories, so you might need to use
45+
`cargo install` (or `cargo binstall`).
46+
- `monitor-curl.sh`: it uses `curl` under the hood. The output is less convenient, but you do not
47+
need an extra tool (TODO: improve the `curl` invocation).
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"update": {
3+
"product": {
4+
"id": "SLES"
5+
},
6+
"software": {
7+
"patterns": [
8+
"gnome",
9+
"unknown"
10+
]
11+
}
12+
}
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"update": {
3+
"product": {
4+
"id": "SLES"
5+
},
6+
"software": {
7+
"patterns": [
8+
"gnome"
9+
]
10+
}
11+
}
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"update": {
3+
"product": {
4+
"id": "Slowroll"
5+
},
6+
"software": {
7+
"patterns": [
8+
"gnome",
9+
"kde"
10+
]
11+
}
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"update": {
3+
"product": {
4+
"id": "Tumbleweed"
5+
},
6+
"software": {
7+
"patterns": [
8+
"gnome",
9+
"kde"
10+
]
11+
}
12+
}
13+
}

devel/scripts/get-config.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/bash
2+
3+
# Return the users' configuration.
4+
5+
curl -k --silent -H @headers.txt -X GET $AGAMA_URL/api/v2/config | jq
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/bash
2+
3+
# Return the full (extended) configuration.
4+
5+
curl -k --silent -H @headers.txt -X GET $AGAMA_URL/api/v2/extended_config | jq

devel/scripts/get-issues.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/bash
2+
3+
# Retrieves the list of issues.
4+
5+
curl -k --silent -H @headers.txt -X GET $AGAMA_URL/api/v2/issues | jq

devel/scripts/get-status.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/bash
2+
3+
# Retrieves the installer status (stage and progress).
4+
5+
curl -k --silent -H @headers.txt -X GET $AGAMA_URL/api/v2/status | jq

0 commit comments

Comments
 (0)