refactor(bruno): reorganize file structure from bruno-yaml to flat bruno directory

- Move all files from bruno-yaml/* to bruno/*
- Maintains existing directory structure within categories
- Updates bruno/user/auth files with OAuth2 refresh token flow
- Updates bruno/user/profile files for user profile management
- Adds bruno/dashboard/ directory with dashboard API tests
- Preserves all existing test scenarios and OpenCollection YAML format
- No functional changes - file reorganization only
This commit is contained in:
2026-02-17 20:22:21 -05:00
parent 96730d9475
commit f859b2714d
221 changed files with 0 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
info:
name: Delete Account
type: http
seq: 4
http:
method: DELETE
url: '{{base_url}}/api/auth/account'
auth: inherit
body:
type: none
docs: |-
## Delete Account
Permanently deletes user account and all associated data.
**Method:** DELETE
**Endpoint:** /api/auth/account
**Authentication:** Required
**Usage:**
- **Self-deletion**: DELETE /api/auth/account (no parameters)
- **Admin deletion**: DELETE /api/auth/account?user_id={uuid
+45
View File
@@ -0,0 +1,45 @@
info:
name: List Users
type: http
seq: 5
http:
method: GET
url: '{{base_url}}/api/auth/users'
auth: inherit
body:
type: none
docs: |-
## List Users
Retrieves a list of all users with complete user information.
**Method:** GET
**Endpoint:** /api/auth/users
**Authentication:** Required (Admin only)
**Response:** Array of user objects with complete information:
- `id` (string): User ID (UUID)
- `email` (string): Email address
- `username` (string): Username
- `first_name` (string): First name (empty if not set)
- `last_name` (string): Last name (empty if not set)
- `role` (string): User role ("user" or "admin")
- `theme` (string): Theme preference (empty if default)
- `max_devices` (integer): Maximum number of devices allowed
- `device_count` (integer): Current number of registered devices
- `created_at` (string): Creation timestamp (ISO 8601)
- `updated_at` (string): Last update timestamp (ISO 8601)
**Status Codes:**
- 200: Success
- 401: Unauthorized
- 403: Forbidden (admin access required)
**Features:**
- Admin-only endpoint with complete user information
- Returns first_name, last_name, role, theme fields
- Includes device limits and current device count
- Useful for user management interfaces
+58
View File
@@ -0,0 +1,58 @@
info:
name: Register Admin User
type: http
seq: 4
http:
method: POST
url: '{{base_url}}/api/auth/register'
auth: inherit
body:
type: json
jsonBody: "{\n \"email\": \"maxdevices@example.com\",\n \"username\": \"\
maxdevicesuser\",\n \"password\": \"Test@Pass123!\",\n \"first_name\"\
: \"Test\",\n \"last_name\": \"User\",\n \"role\": \"admin\""
docs: |-
## Register Admin User
Creates a new admin user account with role-based restrictions.
**Method:** POST
**Endpoint:** /api/auth/register
**Request Body:**
- `email` (string): Email address
- `username` (string): Username
- `password` (string): Password
- `first_name` (string, optional): First name
- `last_name` (string, optional): Last name
- `role` (string): Must be "admin"
**Response:**
- `token` (string): JWT token with admin role
- `user` (object): User details
- `id` (string): User ID
- `email` (string): Email
- `username` (string): Username
- `theme` (string): User theme preference
- `first_name` (string, optional): First name
- `last_name` (string, optional): Last name
- `role` (string): User role ("admin")
**Status Codes:**
- 201: Created
- 400: Invalid input data
- 403: Forbidden - admin creation restrictions apply
- 409: User exists
**Role Restrictions:**
- **First User**: Anyone can create first admin (auto-assigned)
- **Existing Admins Present**: Only authenticated admins can create new admin accounts
- **Unauthenticated Users**: Cannot create admin accounts if any admin exists
- **Security**: Requires admin authentication for subsequent admin creation
**Usage Notes:**
- Use this request only when specifically creating admin accounts
- For regular user creation, use "Register User" request
- Admin token will have elevated privileges for administrative operations
@@ -0,0 +1,27 @@
info:
name: Update User Max Devices
type: http
seq: 6
http:
method: PUT
url: '{{base_url}}/api/auth/users/{{user_id}}/max-devices'
auth: inherit
docs: |-
## Update User Max Devices (Admin)
Updates the maximum number of devices a user can register.
**Method:** PUT
**Endpoint:** /api/auth/users/:id/max-devices
**Authentication:** Required (Admin only)
**URL Parameters:**
- `id` (string): User ID (UUID)
**Request Body:**
```json
{
"max_devices": 10
@@ -0,0 +1,19 @@
info:
name: Delete User Account (Admin)
type: http
seq: 6
http:
method: DELETE
url: '{{base_url}}/api/auth/account?user_id={{user_id}}'
auth: inherit
body:
type: none
docs: |-
## Delete User Account (Admin)
Allows administrators to delete any user account by specifying user_id parameter.
**Method:** DELETE
**Endpoint:** /api/auth/account?user_id={user_id
@@ -0,0 +1,16 @@
info:
name: Update User Max Devices - Exceeds Maximum
type: http
seq: 3
http:
method: PUT
url: '{{base_url}}/api/auth/users/{{user_id}}/max-devices'
auth: inherit
docs: |-
## Update User Max Devices - Invalid (Exceeds Maximum)
Attempts to set max_devices to 101 (above maximum of 100).
**Expected:** 400 Bad Request
**Response:** `{"error": "validation error"
@@ -0,0 +1,16 @@
info:
name: Update User Max Devices - Invalid Max Devices
type: http
seq: 2
http:
method: PUT
url: '{{base_url}}/api/auth/users/{{user_id}}/max-devices'
auth: inherit
docs: |-
## Update User Max Devices - Invalid (Zero)
Attempts to set max_devices to 0 (below minimum).
**Expected:** 400 Bad Request
**Response:** `{"error": "validation error"
@@ -0,0 +1,16 @@
info:
name: Update User Max Devices - Missing ID
type: http
seq: 4
http:
method: PUT
url: '{{base_url}}/api/auth/users//max-devices'
auth: inherit
docs: |-
## Update User Max Devices - Missing User ID
Attempts to update max devices without providing user ID.
**Expected:** 400 Bad Request
**Response:** `{"error": "user id required"
@@ -0,0 +1,16 @@
info:
name: Update User Max Devices - Success
type: http
seq: 1
http:
method: PUT
url: '{{base_url}}/api/auth/users/{{user_id}}/max-devices'
auth: inherit
docs: |-
## Update User Max Devices - Success Case
Successfully updates a user's max devices limit to 5.
**Expected:** 200 OK
**Response:** `{"message": "max devices updated"
+77
View File
@@ -0,0 +1,77 @@
info:
name: Login User
type: http
seq: 1
http:
method: POST
url: "{{base_url}}/api/auth/login"
body:
type: json
data: |-
{
"login": "testuser@example.com",
"password": "Test@Pass123!"
}
runtime:
scripts:
- type: after-response
code: |-
function onResponse(res) {
try {
const responseBody = res.getBody();
const token = responseBody.access_token;
const refreshToken = responseBody.refresh_token;
if (token) {
bru.setEnvVar("token", token, { persist: true });
console.log("Access token saved:", token);
}
if (refreshToken) {
bru.setEnvVar("refresh_token", refreshToken, { persist: true });
console.log("Refresh token saved:", refreshToken);
}
if (!token && !refreshToken) {
console.log("No tokens found in response.");
}
} catch (error) {
console.error("Error in post-response script:", error.message);
}
}
onResponse(res);
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
docs: |-
## Login User
Authenticates a user with email/username and password.
**Method:** POST
**Endpoint:** /api/auth/login
**Request Body:**
- `login` (string): Email or username
- `password` (string): Password
**Response:**
- `token` (string): JWT token
- `user` (object): User details
- `id` (string): User ID
- `email` (string): Email
- `username` (string): Username
- `theme` (string): User theme preference
- `first_name` (string): First name
- `last_name` (string): Last name
**Status Codes:**
- 200: Success
- 401: Invalid credentials
+40
View File
@@ -0,0 +1,40 @@
info:
name: Logout User
type: http
seq: 1
http:
method: POST
url: '{{base_url}}/api/auth/logout'
auth: inherit
body:
type: json
jsonBody: "{\n \"refresh_token\": \"{{refresh_token"
headers:
- key: Content-Type
value: application/json
docs: |-
## Logout User
Logs out the user by revoking their refresh token. If no refresh token is provided, the request succeeds but no token is revoked.
**Method:** POST
**Endpoint:** /api/auth/logout
**Authentication:** Bearer token (optional)
**Request Body:**
- `refresh_token` (string, optional): Refresh token to revoke
**Response:**
- `message` (string): Success message
**Status Codes:**
- 200: Success - user logged out (token revoked if provided)
- 401: Unauthorized
**Example Response:**
```json
{
"message": "logged out successfully"
+44
View File
@@ -0,0 +1,44 @@
info:
name: Refresh Access Token
type: http
seq: 1
http:
method: POST
url: '{{base_url}}/api/auth/refresh'
auth: inherit
body:
type: json
jsonBody: "{\n \"refresh_token\": \"{{refresh_token"
headers:
- key: Content-Type
value: application/json
docs: |-
## Refresh Access Token
Refreshes an access token using a valid refresh token. Returns a new access token with 1-hour expiration.
**Method:** POST
**Endpoint:** /api/auth/refresh
**Authentication:** Not required (refresh token is in request body)
**Request Body:**
- `refresh_token` (string): Valid refresh token UUID
**Response:**
- `access_token` (string): New JWT access token (1 hour expiration)
- `token_type` (string): Token type (usually "Bearer")
- `expires_in` (number): Token lifetime in seconds (3600)
**Status Codes:**
- 200: Success - new access token generated
- 401: Unauthorized - invalid or expired refresh token
**Example Response (Success):**
```json
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600
+57
View File
@@ -0,0 +1,57 @@
info:
name: Register User
type: http
seq: 2
http:
method: POST
url: '{{base_url}}/api/auth/register'
auth: inherit
body:
type: json
jsonBody: "{\n \"email\": \"testuser@example.com\",\n \"username\": \"testuser\"\
,\n \"password\": \"Test@Pass123!\",\n \"first_name\": \"Test\",\n \
\ \"last_name\": \"User\""
docs: |-
## Register User
Creates a new user account with role-based restrictions.
**Method:** POST
**Endpoint:** /api/auth/register
**Request Body:**
- `email` (string): Email address
- `username` (string): Username
- `password` (string): Password
- `first_name` (string, optional): First name
- `last_name` (string, optional): Last name
- `role` (string): User role ("user" or "admin")
**Response:**
- `token` (string): JWT token
- `user` (object): User details
- `id` (string): User ID
- `email` (string): Email
- `username` (string): Username
- `theme` (string): User theme preference
- `first_name` (string, optional): First name
- `last_name` (string, optional): Last name
- `role` (string): User role ("user" or "admin")
**Status Codes:**
- 201: Created
- 400: Invalid input data
- 403: Forbidden - role-based restrictions apply
- 409: User exists
**Role Restrictions:**
- **First User**: Automatically gets admin role regardless of request
- **Existing Admins Present**: Only authenticated admins can create new admin accounts
- **No Admins Yet**: Anyone can create first admin (auto-assigned)
- **Regular User Creation**: Anyone can create regular user accounts
- **Unauthenticated Users**: Can only create first admin, not subsequent admins
**Examples:**
- First admin creation: `{"email": "admin@example.com", "username": "admin", "password": "password123", "role": "admin"
+33
View File
@@ -0,0 +1,33 @@
info:
name: Get Profile
type: http
seq: 1
http:
method: GET
url: '{{base_url}}/api/auth/profile'
auth: inherit
body:
type: none
docs: |-
## Get User Profile
Retrieves the authenticated user's profile.
**Method:** GET
**Endpoint:** /api/auth/profile
**Authentication:** Required
**Response:**
- `id` (string): User ID
- `email` (string): Email
- `username` (string): Username
- `theme` (string): User theme preference
- `first_name` (string, optional): First name
- `last_name` (string, optional): Last name
**Status Codes:**
- 200: Success
- 401: Unauthorized
+33
View File
@@ -0,0 +1,33 @@
info:
name: Update Email
type: http
seq: 2
http:
method: PUT
url: '{{base_url}}/api/auth/email'
auth: inherit
body:
type: json
docs: |-
## Update Email
Updates the authenticated user's email address.
**Method:** PUT
**Endpoint:** /api/auth/email
**Authentication:** Required
**Request Body:**
- `email` (string, required): New email address (must be valid email format)
**Response:**
- `message` (string): Success message
**Status Codes:**
- 200: Success
- 400: Invalid email format
- 401: Unauthorized
- 409: Email already taken
+37
View File
@@ -0,0 +1,37 @@
info:
name: Update Password
type: http
seq: 3
http:
method: PUT
url: '{{base_url}}/api/auth/password'
auth: inherit
body:
type: json
jsonBody: "{\n \"current_password\": \"password123\",\n \"new_password\"\
: \"newpassword123\",\n \"confirm_password\": \"newpassword123\""
docs: |-
## Update Password
Updates the authenticated user's password.
**Method:** PUT
**Endpoint:** /api/auth/password
**Authentication:** Required
**Request Body:**
- `current_password` (string, required): Current password for verification
- `new_password` (string, required): New password (minimum 6 characters)
- `confirm_password` (string, required): Confirmation of new password
**Response:**
- `message` (string): Success message
**Status Codes:**
- 200: Success
- 400: Password validation failed
- 401: Current password incorrect
- 401: Unauthorized
+34
View File
@@ -0,0 +1,34 @@
info:
name: Update Profile
type: http
seq: 4
http:
method: PUT
url: '{{base_url}}/api/auth/profile'
auth: inherit
body:
type: json
jsonBody: "{\n \"first_name\": \"Updated\",\n \"last_name\": \"Name\""
docs: |-
## Update User Profile
Updates the authenticated user's profile information.
**Method:** PUT
**Endpoint:** /api/auth/profile
**Authentication:** Required (Bearer token)
**Request Body:**
- `first_name` (string, optional): First name
- `last_name` (string, optional): Last name
**Response:**
- `message` (string): Success message
**Status Codes:**
- 200: Success
- 400: Invalid request
- 401: Unauthorized
+33
View File
@@ -0,0 +1,33 @@
info:
name: Update Theme
type: http
seq: 4
http:
method: PUT
url: '{{base_url}}/api/auth/theme'
auth: inherit
body:
type: json
jsonBody: "{\n \"theme\": \"dracula\""
docs: |-
## Update User Theme
Updates the authenticated user's theme preference.
**Method:** PUT
**Endpoint:** /api/auth/theme
**Authentication:** Required (Bearer token)
**Request Body:**
- `theme` (string): Theme name (tokyo-night, dracula, nord, solarized-dark, monokai, one-dark-pro, material-dark, catppuccin-mocha, catppuccin-macchiato, catppuccin-frappe, catppuccin-latte)
**Response:**
- `message` (string): Success message
**Status Codes:**
- 200: Success
- 400: Invalid theme
- 401: Unauthorized
+33
View File
@@ -0,0 +1,33 @@
info:
name: Update Username
type: http
seq: 1
http:
method: PUT
url: '{{base_url}}/api/auth/username'
auth: inherit
body:
type: json
docs: |-
## Update Username
Updates the authenticated user's username.
**Method:** PUT
**Endpoint:** /api/auth/username
**Authentication:** Required
**Request Body:**
- `username` (string, required): New username (3-50 characters)
**Response:**
- `message` (string): Success message
**Status Codes:**
- 200: Success
- 400: Invalid username
- 401: Unauthorized
- 409: Username already taken