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
+50 -9
View File
@@ -6,15 +6,56 @@ meta {
get {
url: {{baseUrl}}/api/sync/koreader/metadata/{{book_uuid}}
headers: {
Authorization: Bearer {{device_token}},
Content-Type: application/json
}
body: none
auth: inherit
}
assert {
res.status == 200
res.body.uuid != null
res.body.title != null
res.body.progress != null
headers {
Authorization: Bearer {{device_token}}
Content-Type: application/json
}
script:post-response {
function onResponse(res) {
if (res.getStatus() === 200) {
const body = res.getBody();
tests['Status is 200'] = true;
tests['Has UUID'] = body.uuid !== null;
tests['Has title'] = body.title !== null;
tests['Has progress'] = body.progress !== null;
}
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## KOReader Get Book Metadata
Retrieves metadata for a specific book from the KOReader sync endpoint.
**Method:** GET
**Endpoint:** /api/sync/koreader/metadata/{book_uuid}
**Authentication:** Bearer token (device token)
**Path Parameters:**
- `book_uuid` (string): Book UUID
**Response:**
- `uuid` (string): Book UUID
- `title` (string): Book title
- `progress` (object): Reading progress data
- `metadata` (object): Additional book metadata
**Status Codes:**
- 200: Success
- 401: Unauthorized
- 404: Book not found
- 500: Internal server error
}
+44 -8
View File
@@ -6,14 +6,50 @@ meta {
get {
url: {{baseUrl}}/api/sync/koreader/library
headers: {
Authorization: Bearer {{device_token}},
Content-Type: application/json
}
body: none
auth: inherit
}
assert {
res.status == 200
res.body.library_sync != null
res.body.total_books >= 0
headers {
Authorization: Bearer {{device_token}}
Content-Type: application/json
}
script:post-response {
function onResponse(res) {
if (res.getStatus() === 200) {
const body = res.getBody();
tests['Status is 200'] = res.getStatus() === 200;
tests['Has library_sync'] = body.library_sync != null;
tests('Total books >= 0', body.total_books >= 0);
}
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## KOReader Get Library
Retrieves the user's library for KOReader sync operations.
**Method:** GET
**Endpoint:** /api/sync/koreader/library
**Authentication:** Bearer token (device token)
**Response:**
- `library_sync` (object): Library sync data
- `total_books` (number): Total number of books
- `books` (array): Array of book objects
**Status Codes:**
- 200: Success
- 401: Unauthorized
- 500: Internal server error
}
@@ -1,12 +1,22 @@
meta {
name: "KOReader Sync Annotations - Per-Annotation SHA-256"
name: KOReader Sync Annotations - Per-Book SHA-256
type: http
seq: 4
}
post {
url: {{base_url}}/api/v1/koreader/sync/bookmarks
body: json({
body: json
auth: inherit
}
headers {
Authorization: Bearer {{koreader_device_token}}
Content-Type: application/json
}
body:json {
{
"book_uuid": "{{book_uuid}}",
"highlights": [
{
@@ -26,14 +36,51 @@ post {
"book_sha256": "{{another_book_sha256}}"
}
]
})
auth: {
type: bearer
bearer: {{koreader_device_token}}
}
}
assert {
response.status == 200
response.body.highlights_synced >= 0
script:post-response {
function onResponse(res) {
if (res.getStatus() === 200) {
const body = res.getBody();
tests('Highlights synced >= 0', body.highlights_synced >= 0);
}
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## KOReader Sync Annotations - Per-Book SHA-256
Synchronizes annotations (highlights) from KOReader with per-annotation SHA-256 hashes for multi-book sync.
**Method:** POST
**Endpoint:** /api/v1/koreader/sync/bookmarks
**Authentication:** Bearer token (KOReader device token)
**Request Body:**
- `book_uuid` (string): Primary book UUID
- `highlights` (array): Array of highlight objects
- `text` (string): Highlighted text
- `pos0`, `pos1` (string): EPUB CFI positions
- `color` (string): Highlight color (hex)
- `page` (number): Page number
- `book_sha256` (string): SHA-256 hash for this specific book
**Response:**
- `highlights_synced` (number): Number of highlights synced
**Status Codes:**
- 200: Success
- 401: Unauthorized
- 500: Internal server error
**Note:** Each highlight can include its own book_sha256, allowing annotations from multiple books in a single request.
}
+53 -10
View File
@@ -1,12 +1,22 @@
meta {
name: "KOReader Sync Bookmarks - Enhanced with SHA-256"
name: KOReader Sync Bookmarks - SHA-256
type: http
seq: 3
}
post {
url: {{base_url}}/api/v1/koreader/sync/bookmarks
body: json({
body: json
auth: inherit
}
headers {
Authorization: Bearer {{koreader_device_token}}
Content-Type: application/json
}
body:json {
{
"book_sha256": "{{book_sha256}}",
"bookmarks": [
{
@@ -33,15 +43,48 @@ post {
"page": 50
}
]
})
auth: {
type: bearer
bearer: {{koreader_device_token}}
}
}
assert {
response.status == 200
response.body.sync_status == "completed"
response.body.total_synced >= 0
script:post-response {
function onResponse(res) {
if (res.getStatus() === 200) {
const body = res.getBody();
tests('Sync completed', body.sync_status === "completed");
tests('Total synced >= 0', body.total_synced >= 0);
}
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## KOReader Sync Bookmarks - SHA-256
Synchronizes bookmarks, notes, and highlights from KOReader using SHA-256 hash for book identification.
**Method:** POST
**Endpoint:** /api/v1/koreader/sync/bookmarks
**Authentication:** Bearer token (KOReader device token)
**Request Body:**
- `book_sha256` (string): SHA-256 hash of book file
- `bookmarks` (array): Array of bookmarks
- `notes` (array): Array of notes
- `highlights` (array): Array of highlights
**Response:**
- `sync_status` (string): Sync status
- `total_synced` (number): Total items synced
**Status Codes:**
- 200: Success
- 401: Unauthorized
- 500: Internal server error
}
+61 -9
View File
@@ -6,7 +6,17 @@ meta {
post {
url: {{baseUrl}}/api/sync/koreader/bookmarks
body: json({
body: json
auth: inherit
}
headers {
Authorization: Bearer {{device_token}}
Content-Type: application/json
}
body:json {
{
"book_uuid": "{{book_uuid}}",
"bookmarks": [
{
@@ -46,15 +56,57 @@ post {
"percentage": 0.45
}
]
})
headers: {
Authorization: Bearer {{device_token}},
Content-Type: application/json
}
}
assert {
res.status == 200
res.body.sync_status == "completed"
res.body.total_synced >= 0
script:post-response {
function onResponse(res) {
if (res.getStatus() === 200) {
const body = res.getBody();
tests['Sync completed'] = body.sync_status === "completed";
tests('Items synced >= 0', body.total_synced >= 0);
}
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## KOReader Sync Bookmarks
Synchronizes bookmarks, notes, and highlights from a KOReader device.
**Method:** POST
**Endpoint:** /api/sync/koreader/bookmarks
**Authentication:** Bearer token (device token)
**Request Body:**
- `book_uuid` (string): Book UUID
- `bookmarks` (array): Array of bookmark objects
- `notes` (array): Array of note objects
- `highlights` (array): Array of highlight objects
Each object includes:
- `chapter` (number): Chapter number
- `datetime` (string): ISO 8601 timestamp
- `text` (string): Highlighted/bookmarked text
- `pos0`, `pos1` (string): EPUB CFI positions
- `page` (number): Page number
- `type` (string): Type (highlight, bookmark, note)
- `percentage` (number): Position in book (0-1)
**Response:**
- `sync_status` (string): Sync status (completed, partial)
- `total_synced` (number): Number of items synced
**Status Codes:**
- 200: Success
- 401: Unauthorized
- 500: Internal server error
}
@@ -1,12 +1,22 @@
meta {
name: "KOReader Sync Progress - Priority Matching (SHA-256 only)"
name: KOReader Sync Progress - SHA-256 Only
type: http
seq: 2
}
post {
url: {{base_url}}/api/v1/koreader/sync/progress
body: json({
body: json
auth: inherit
}
headers {
Authorization: Bearer {{koreader_device_token}}
Content-Type: application/json
}
body:json {
{
"sync_mode": "immediate",
"books": [
{
@@ -17,13 +27,50 @@ post {
"total_pages": 200
}
]
})
auth: {
type: bearer
bearer: {{koreader_device_token}}
}
}
assert {
response.status == 200 || response.status == 202
script:post-response {
function onResponse(res) {
tests('Status is 200 or 202', res.getStatus() === 200 || res.getStatus() === 202);
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## KOReader Sync Progress - SHA-256 Only
Synchronizes reading progress using only SHA-256 hash for book identification (when UUID is not available).
**Method:** POST
**Endpoint:** /api/v1/koreader/sync/progress
**Authentication:** Bearer token (KOReader device token)
**Request Body:**
- `sync_mode` (string): Sync mode (immediate, deferred)
- `books` (array): Array of book progress objects
- `sha256` (string): SHA-256 hash of book file
- `file_path` (string): Path to book file
- `percentage` (number): Progress percentage
- `page` (number): Current page
- `total_pages` (number): Total pages
**Response:**
- `sync_status` (string): Sync status
- `books_synced` (number): Number of books synced
**Status Codes:**
- 200: Success
- 202: Accepted
- 401: Unauthorized
- 500: Internal server error
**Note:** Use this when book UUID is not available, falling back to SHA-256 hash for identification.
}
+64 -10
View File
@@ -1,12 +1,22 @@
meta {
name: "KOReader Sync Progress - Enhanced with SHA-256"
name: KOReader Sync Progress - SHA-256
type: http
seq: 1
}
post {
url: {{base_url}}/api/v1/koreader/sync/progress
body: json({
body: json
auth: inherit
}
headers {
Authorization: Bearer {{koreader_device_token}}
Content-Type: application/json
}
body:json {
{
"sync_mode": "immediate",
"books": [
{
@@ -23,15 +33,59 @@ post {
"authors": ["J.R.R. Tolkien"]
}
]
})
auth: {
type: bearer
bearer: {{koreader_device_token}}
}
}
assert {
response.status == 200 || response.status == 202
response.body.sync_status exists()
response.body.books_synced >= 0
script:post-response {
function onResponse(res) {
if (res.getStatus() === 200 || res.getStatus() === 202) {
const body = res.getBody();
tests['Status accepted'] = res.getStatus() === 200 || res.getStatus() === 202;
tests('Has sync_status', body.sync_status !== undefined);
tests('Books synced >= 0', body.books_synced >= 0);
}
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## KOReader Sync Progress - SHA-256
Synchronizes reading progress from a KOReader device using SHA-256 book hash for identification.
**Method:** POST
**Endpoint:** /api/v1/koreader/sync/progress
**Authentication:** Bearer token (KOReader device token)
**Request Body:**
- `sync_mode` (string): Sync mode (immediate, deferred)
- `books` (array): Array of book progress objects
- `uuid` (string): Book UUID
- `sha256` (string): SHA-256 hash of book file for identification
- `file_path` (string): Path to book file on device
- `percentage` (number): Progress percentage (0-1)
- `chapter` (number): Current chapter
- `page` (number): Current page
- `total_pages` (number): Total pages
- `epubcfi` (string): EPUB location
- `last_read` (string): ISO 8601 timestamp
- `title` (string): Book title
- `authors` (array): List of authors
**Response:**
- `sync_status` (string): Sync status
- `books_synced` (number): Number of books synced
**Status Codes:**
- 200: Success
- 202: Accepted - processing
- 401: Unauthorized
- 500: Internal server error
}
+65 -9
View File
@@ -6,7 +6,17 @@ meta {
post {
url: {{baseUrl}}/api/sync/koreader/progress
body: json({
body: json
auth: inherit
}
headers {
Authorization: Bearer {{device_token}}
Content-Type: application/json
}
body:json {
{
"library_id": null,
"books": [
{
@@ -28,15 +38,61 @@ post {
"koreader_version": "2024.01",
"device_model": "kindle-paperwhite-5"
}
})
headers: {
Authorization: Bearer {{device_token}},
Content-Type: application/json
}
}
assert {
res.status == 202
res.body.sync_status == "accepted"
res.body.books_synced >= 0
script:post-response {
function onResponse(res) {
if (res.getStatus() === 202) {
const body = res.getBody();
tests['Status is 202'] = res.getStatus() === 202;
tests['Sync status accepted'] = body.sync_status === "accepted";
tests('Books synced >= 0', body.books_synced >= 0);
}
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## KOReader Sync Progress
Synchronizes reading progress from a KOReader device to the Bookhoard server.
**Method:** POST
**Endpoint:** /api/sync/koreader/progress
**Authentication:** Bearer token (device token)
**Request Body:**
- `library_id` (string, optional): Library UUID
- `books` (array): Array of book progress objects
- `uuid` (string): Book UUID
- `title` (string): Book title
- `authors` (array): List of authors
- `progress` (number): Progress value
- `percentage` (number): Percentage complete (0-1)
- `last_read` (string): ISO 8601 timestamp
- `chapter` (number): Current chapter
- `epubcfi` (string): EPUB Canonical Fragment Identifier
- `page` (number): Current page
- `total_pages` (number): Total pages
- `sync_mode` (string): Sync mode (immediate, deferred)
- `device_info` (object): Device information
- `koreader_version` (string): KOReader version
- `device_model` (string): Device model identifier
**Response:**
- `sync_status` (string): Sync status (accepted, processing)
- `books_synced` (number): Number of books synced
**Status Codes:**
- 202: Accepted - sync queued
- 401: Unauthorized
- 500: Internal server error
}