refactor(bruno): migrate API tests to Bruno DSL format

- Convert all existing .bru files from JSON to Bruno DSL format
- Remove obsolete files (conflicts/api.bru, kobo/Kobo Initialization.bru)
- Update auth configuration to use 'inherit' instead of explicit bearer tokens
- Add comprehensive documentation to all test files
- Improve test scripts with proper assertions and error handling
This commit is contained in:
2026-02-08 20:49:06 -05:00
parent cb76b9ca05
commit 3117ce54ec
93 changed files with 3974 additions and 1576 deletions
+51 -9
View File
@@ -1,19 +1,61 @@
meta {
name: "Download Device Sidecar File"
name: Download Device Sidecar File
type: http
seq: 2
}
get {
url: {{base_url}}/api/devices/{{device_id}}/sidecar/download
auth: {
type: bearer
bearer: {{user_token}}
}
body: none
auth: inherit
}
assert {
response.status == 200
response.headers["Content-Type"] contains "application/json"
response.headers["Content-Disposition"] contains ".bookhoard.json"
headers {
Authorization: Bearer {{user_token}}
Content-Type: application/json
}
script:post-response {
function onResponse(res) {
if (res.getStatus() === 200) {
const headers = res.getHeaders();
const contentType = headers.get("Content-Type");
const contentDisposition = headers.get("Content-Disposition");
tests('Content-Type is JSON', contentType && contentType.includes("application/json"));
tests('Has .bookhoard.json filename', contentDisposition && contentDisposition.includes(".bookhoard.json"));
}
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## Download Device Sidecar File
Downloads the sidecar configuration file for a device in JSON format.
**Method:** GET
**Endpoint:** /api/devices/{device_id}/sidecar/download
**Authentication:** Bearer token
**Path Parameters:**
- `device_id` (string): Device UUID
**Response Headers:**
- `Content-Type`: application/json
- `Content-Disposition`: attachment; filename="device.bookhoard.json"
**Response Body:** JSON sidecar configuration file
**Status Codes:**
- 200: Success - file returned
- 401: Unauthorized
- 404: Device not found
- 500: Internal server error
}
+51 -11
View File
@@ -1,21 +1,61 @@
meta {
name: "Get Device Sidecar Config"
name: Get Device Sidecar Config
type: http
seq: 1
}
get {
url: {{base_url}}/api/devices/{{device_id}}/sidecar
auth: {
type: bearer
bearer: {{user_token}}
}
body: none
auth: inherit
}
assert {
response.status == 200
response.body.version == "1.0"
response.body.bookhoard exists()
response.body.books exists()
response.body.collections exists()
headers {
Authorization: Bearer {{user_token}}
Content-Type: application/json
}
script:post-response {
function onResponse(res) {
if (res.getStatus() === 200) {
const body = res.getBody();
tests('Version is 1.0', body.version === "1.0");
tests('Has bookhoard config', body.bookhoard !== undefined);
tests('Has books array', body.books !== undefined);
tests('Has collections array', body.collections !== undefined);
}
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## Get Device Sidecar Config
Retrieves sidecar configuration for a specific device.
**Method:** GET
**Endpoint:** /api/devices/{device_id}/sidecar
**Authentication:** Bearer token
**Path Parameters:**
- `device_id` (string): Device UUID
**Response:**
- `version` (string): Sidecar version (e.g., "1.0")
- `bookhoard` (object): Bookhoard configuration
- `books` (array): Array of book configurations
- `collections` (array): Array of collection configurations
**Status Codes:**
- 200: Success
- 401: Unauthorized
- 404: Device not found
- 500: Internal server error
}
+47 -10
View File
@@ -1,20 +1,57 @@
meta {
name: "Get System Configuration"
name: Get System Configuration
type: http
seq: 3
}
get {
url: {{base_url}}/api/system/config
auth: {
type: bearer
bearer: {{admin_token}}
}
body: none
auth: inherit
}
assert {
response.status == 200
response.body.base_url exists()
response.body.opds_base_url exists()
response.body.api_base_url exists()
headers {
Authorization: Bearer {{admin_token}}
Content-Type: application/json
}
script:post-response {
function onResponse(res) {
if (res.getStatus() === 200) {
const body = res.getBody();
tests('Has base_url', body.base_url !== undefined);
tests('Has opds_base_url', body.opds_base_url !== undefined);
tests('Has api_base_url', body.api_base_url !== undefined);
}
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## Get System Configuration
Retrieves system-wide configuration settings.
**Method:** GET
**Endpoint:** /api/system/config
**Authentication:** Bearer token (admin only)
**Response:**
- `base_url` (string): Base URL
- `opds_base_url` (string): OPDS endpoint URL
- `api_base_url` (string): API endpoint URL
- Additional configuration fields
**Status Codes:**
- 200: Success
- 401: Unauthorized
- 403: Forbidden (admin only)
- 500: Internal server error
}
+53 -9
View File
@@ -1,23 +1,67 @@
meta {
name: "Update System Configuration"
name: Update System Configuration
type: http
seq: 4
}
put {
url: {{base_url}}/api/system/config
body: json({
body: json
auth: inherit
}
headers {
Authorization: Bearer {{admin_token}}
Content-Type: application/json
}
body:json {
{
"base_url": "https://bookhoard.example.com",
"opds_base_url": "https://bookhoard.example.com/opds",
"api_base_url": "https://bookhoard.example.com/api"
})
auth: {
type: bearer
bearer: {{admin_token}}
}
}
assert {
response.status == 200
response.body.status == "success"
script:post-response {
function onResponse(res) {
if (res.getStatus() === 200) {
const body = res.getBody();
tests('Status is success', body.status === "success");
}
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## Update System Configuration
Updates system-wide configuration settings for the Bookhoard instance.
**Method:** PUT
**Endpoint:** /api/system/config
**Authentication:** Bearer token (admin only)
**Request Body:**
- `base_url` (string): Base URL for the instance
- `opds_base_url` (string): OPDS endpoint base URL
- `api_base_url` (string): API endpoint base URL
**Response:**
- `status` (string): Update status
- `config` (object): Updated configuration
**Status Codes:**
- 200: Success
- 400: Invalid configuration
- 401: Unauthorized
- 403: Forbidden (admin only)
- 500: Internal server error
}