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:
+54
-13
@@ -1,5 +1,5 @@
|
||||
meta {
|
||||
name: "WebSocket - Connect and Receive Updates"
|
||||
name: WebSocket - Connect and Receive Updates
|
||||
type: websocket
|
||||
seq: 1
|
||||
}
|
||||
@@ -9,22 +9,63 @@ vars {
|
||||
}
|
||||
|
||||
websocket {
|
||||
url: "{{ baseUrl }}/ws/sync?token={{ token }}"
|
||||
url: {{baseUrl}}/ws/sync?token={{token}}
|
||||
body: {
|
||||
type: "ping",
|
||||
timestamp: "2026-01-30T20:00:00Z"
|
||||
}
|
||||
auth: {
|
||||
type: bearer
|
||||
token: "{{ token }}"
|
||||
}
|
||||
headers: {
|
||||
Authorization: "Bearer {{ token }}"
|
||||
}
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status == 101
|
||||
res.headers.contains("Connection", "upgrade")
|
||||
res.headers.contains("Upgrade", "websocket")
|
||||
headers {
|
||||
Authorization: Bearer {{token}}
|
||||
}
|
||||
|
||||
script:post-response {
|
||||
function onResponse(res) {
|
||||
tests('Status is 101 (Switching Protocols)', res.getStatus() === 101);
|
||||
const headers = res.getHeaders();
|
||||
const connection = headers.get("Connection");
|
||||
const upgrade = headers.get("Upgrade");
|
||||
tests('Connection header has upgrade', connection && connection.toLowerCase().includes("upgrade"));
|
||||
tests('Upgrade header is websocket', upgrade && upgrade.toLowerCase().includes("websocket"));
|
||||
}
|
||||
onResponse(res);
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## WebSocket - Connect and Receive Updates
|
||||
|
||||
Establishes a WebSocket connection for real-time sync updates.
|
||||
|
||||
**Type:** WebSocket
|
||||
|
||||
**Endpoint:** /ws/sync?token={token}
|
||||
|
||||
**Authentication:** Bearer token (via query parameter)
|
||||
|
||||
**Query Parameters:**
|
||||
- `token` (string): JWT access token
|
||||
|
||||
**Request Body:**
|
||||
- `type` (string): Message type (ping, subscribe, unsubscribe)
|
||||
- `timestamp` (string): ISO 8601 timestamp
|
||||
|
||||
**Expected Response:**
|
||||
- Status: 101 Switching Protocols
|
||||
- Headers:
|
||||
- `Connection`: upgrade
|
||||
- `Upgrade`: websocket
|
||||
|
||||
**Status Codes:**
|
||||
- 101: Switching Protocols - WebSocket established
|
||||
- 401: Unauthorized
|
||||
- 500: Internal server error
|
||||
|
||||
**Note:** WebSocket connection allows real-time push notifications for sync updates, progress changes, and device activity.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user