Files
bookhoard/bruno/saved-filters/Delete Saved Filter.yml
T
john-okeefe 2022595fd4 test(api): add Bruno API collection for saved filters
Add comprehensive Bruno OpenCollection YAML files for testing
the saved filters API with 9 request files and scenarios.

Main CRUD Requests (4 files):
1. List Saved Filters.yml
   - GET /api/saved-filters?resource_type=media-items
   - Documents resource_type parameter requirement
   - Example responses with JSONB filters

2. Create Saved Filter.yml
   - POST /api/saved-filters
   - Complete request body documentation
   - All filter field examples (genre, author, sort, year, etc.)
   - Validation rules (max 100 chars, uniqueness)

3. Update Saved Filter.yml
   - PUT /api/saved-filters/{filter_id}
   - Immutability notes (resource_type can't change)
   - Duplicate name validation
   - Updated timestamp behavior

4. Delete Saved Filter.yml
   - DELETE /api/saved-filters/{filter_id}
   - 204 No Content response
   - Security considerations

Scenario Test Files (5 files):

1. Duplicate Name Validation.yml
   - Tests 409 Conflict on duplicate names
   - Per-user + per-resource-type uniqueness
   - Example bash test script

2. User Isolation - Cross-User Access.yml
   - Tests users can't access each other's filters
   - Security: 404 instead of 403 (prevents enumeration)
   - Complete multi-user test scenario
   - Database-level isolation documentation

3. Multiple Resource Types.yml
   - Tests generic design with different resource types
   - Same name allowed for different types (media-items, collections, devices)
   - Examples for each resource type
   - Extensibility benefits explained

4. Complete CRUD Workflow.yml
   - End-to-end lifecycle test (6.5K file)
   - Shell script with all steps: Create → Read → Update → Delete → Verify
   - Success criteria checklist
   - Copy-paste ready test script

5. Filter Validation - Edge Cases.yml
   - 12 different validation test cases
   - Empty names, missing fields, invalid UUIDs
   - Unicode support (emoji, CJK characters)
   - Malformed JSON handling
   - Special characters and XSS attempts

Documentation Features:
- {{base_url}} variable substitution
- auth: inherit for authentication
- Comprehensive docs: sections with examples
- Shell commands ready to copy-paste
- Expected status codes and responses
- Error handling examples
- Security best practices

Total: 9 YAML files covering all CRUD operations and edge cases

Usage:
- Import into Bruno/Postman for API testing
- Use for manual testing during development
- Reference for API contract validation
- Example curl commands for documentation

Part of: Saved Filters Implementation (Phase 5: Testing & Documentation)
Related: #saved-filters-feature
2026-03-21 00:16:29 -04:00

96 lines
2.3 KiB
YAML

info:
name: Delete Saved Filter
type: http
seq: 4
http:
method: DELETE
url: '{{base_url}}/api/saved-filters/{{filter_id}}'
auth: inherit
docs: |-
## Delete Saved Filter
Permanently deletes a saved filter.
**Method:** DELETE
**Endpoint:** /api/saved-filters/{filter_id}
**Authentication:** Required (Bearer token)
**Path Parameters:**
- `filter_id` (string, required): UUID of the filter to delete
- Must be a valid UUID
- Must belong to the authenticated user
**Response:**
- 204 No Content (success)
- Empty response body
**Status Codes:**
- 204: No Content - Filter deleted successfully
- 400: Bad Request - Invalid filter ID format
- 401: Unauthorized - Invalid or missing authentication token
- 404: Not Found - Filter doesn't exist or doesn't belong to user
- 500: Internal Server Error - Database error
**Example Usage:**
```bash
curl -X DELETE \
-H "Authorization: Bearer YOUR_TOKEN" \
"{{base_url}}/api/saved-filters/{{filter_id}}"
```
**Important Notes:**
- You can only delete filters that belong to you
- Deletion is permanent - cannot be undone
- Returns 204 No Content on success (no response body)
- If filter doesn't exist or belongs to another user, returns 404
**Error Response Examples:**
Invalid filter ID:
```json
{
"error": "invalid filter ID"
}
```
Filter not found:
```json
{
"error": "failed to delete filter"
}
```
**Testing Deletion:**
```bash
# First, create a filter
CREATE_RESPONSE=$(curl -s -X POST \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "To Be Deleted",
"resource_type": "media-items",
"filters": {}
}' \
"{{base_url}}/api/saved-filters")
# Extract the ID
FILTER_ID=$(echo $CREATE_RESPONSE | jq -r '.id')
# Delete the filter
curl -X DELETE \
-H "Authorization: Bearer YOUR_TOKEN" \
"{{base_url}}/api/saved-filters/$FILTER_ID"
# Verify it's gone
curl -H "Authorization: Bearer YOUR_TOKEN" \
"{{base_url}}/api/saved-filters?resource_type=media-items"
```
**Cascade Effects:**
- No cascade effects - saved filters are standalone records
- User deletion automatically cascades to delete their filters
- No foreign key dependencies on other tables