refactor: standardize Bruno API requests with bruToJsonV2 format
- Convert all JSON tests to JavaScript functions for bruToJsonV2 compatibility
- Update authentication to use 'inherit' instead of manual headers
- Fix hardcoded URLs to use {{base_url}} variables
- Standardize variable syntax from {{ _.var }} to {{var}}
- Add comprehensive API documentation to all requests
- Update environment variables with missing required fields
- Apply consistent structure: meta, http method, headers, tests, vars, settings, docs
- Enhanced validation with proper error handling and field checks
This commit is contained in:
@@ -1,21 +1,57 @@
|
||||
meta {
|
||||
name: Get Admin Library Page
|
||||
type: http,
|
||||
name: Get Admin Library
|
||||
type: http
|
||||
seq: 5
|
||||
}
|
||||
|
||||
get {
|
||||
url: "/admin/library"
|
||||
headers: {
|
||||
Authorization: "Bearer {{ _.token }}"
|
||||
}
|
||||
url: {{base_url}}/admin/library
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
tests: {
|
||||
test_admin_library_page_success: {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "text/html; charset=UTF-8"
|
||||
script:post-response {
|
||||
function onResponse(res) {
|
||||
if (res.getStatus() !== 200) {
|
||||
bru.testFailed("Expected status 200, got " + res.getStatus());
|
||||
return;
|
||||
}
|
||||
|
||||
const contentType = res.getHeader("content-type");
|
||||
if (!contentType || !contentType.includes("text/html")) {
|
||||
bru.testFailed("Expected content-type to contain text/html, got " + contentType);
|
||||
return;
|
||||
}
|
||||
|
||||
bru.testPassed("Admin library page returned successfully");
|
||||
}
|
||||
}
|
||||
onResponse(res);
|
||||
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Get Admin Library Page
|
||||
|
||||
Retrieves the admin library page for administrative access.
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /admin/library
|
||||
|
||||
**Headers:**
|
||||
- `Authorization` (string): Bearer token
|
||||
|
||||
**Response:**
|
||||
- HTML content for the admin library page
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden
|
||||
|
||||
}
|
||||
|
||||
@@ -7,5 +7,40 @@ meta {
|
||||
get {
|
||||
url: {{base_url}}/admin/profile
|
||||
body: none
|
||||
auth: bearer
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Get Admin Profile
|
||||
|
||||
Retrieves the admin profile information for administrative access.
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /admin/profile
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Response:**
|
||||
- JSON object containing admin profile details
|
||||
- `id` (string): Admin user ID
|
||||
- `email` (string): Admin email
|
||||
- `username` (string): Admin username
|
||||
- `theme` (string): Theme preference
|
||||
- `first_name` (string): First name
|
||||
- `last_name` (string): Last name
|
||||
- `is_admin` (boolean): Admin status
|
||||
- `created_at` (string): Account creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (non-admin users)
|
||||
- 404: Profile not found
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user