@base = http://localhost:3000 @apiKey = bnt_727d2f4f72bd03ed96da5278bb971a00cb0a2454d4d70f9748b5c39f3f69d88d ############################################################################### # EDGE CASES & VALIDATION TESTS # Tests: Input validation, Error handling, Edge cases # # Test Coverage: # 1. Invalid alias format # 2. Invalid aspect ratio # 3. Missing required fields # 4. 404 for non-existent resources # 5. Regenerate generation # 6. CDN endpoints ############################################################################### ############################################################################### # TEST 1: Invalid Alias Format # Aliases must start with @ and contain only alphanumeric + hyphens ############################################################################### ### Step 1.1: Alias without @ symbol (should fail) # @name invalidNoAt POST {{base}}/api/v1/generations Content-Type: application/json X-API-Key: {{apiKey}} { "prompt": "Test invalid alias", "aspectRatio": "1:1", "alias": "no-at-symbol" } ### # Expected: 400 validation error OR 500 with alias error ### Step 1.2: Alias with spaces (should fail) # @name invalidWithSpaces POST {{base}}/api/v1/generations Content-Type: application/json X-API-Key: {{apiKey}} { "prompt": "Test invalid alias", "aspectRatio": "1:1", "alias": "@has spaces" } ### # Expected: 400 validation error ### Step 1.3: Alias with special characters (should fail) # @name invalidSpecialChars POST {{base}}/api/v1/generations Content-Type: application/json X-API-Key: {{apiKey}} { "prompt": "Test invalid alias", "aspectRatio": "1:1", "alias": "@special!chars" } ### # Expected: 400 validation error ### Step 1.4: Empty alias (should fail or be ignored) # @name invalidEmpty POST {{base}}/api/v1/generations Content-Type: application/json X-API-Key: {{apiKey}} { "prompt": "Test invalid alias", "aspectRatio": "1:1", "alias": "" } ### ############################################################################### # TEST 2: Invalid Aspect Ratio ############################################################################### ### Step 2.1: Invalid aspect ratio string # @name invalidAspectRatio POST {{base}}/api/v1/generations Content-Type: application/json X-API-Key: {{apiKey}} { "prompt": "Test invalid aspect ratio", "aspectRatio": "invalid" } ### # Expected: 400 validation error ### Step 2.2: Unsupported aspect ratio # @name unsupportedAspectRatio POST {{base}}/api/v1/generations Content-Type: application/json X-API-Key: {{apiKey}} { "prompt": "Test unsupported aspect ratio", "aspectRatio": "5:7" } ### # Expected: 400 validation error (only 1:1, 16:9, 9:16, 4:3, 3:4, 21:9 supported) ############################################################################### # TEST 3: Missing Required Fields ############################################################################### ### Step 3.1: Missing prompt # @name missingPrompt POST {{base}}/api/v1/generations Content-Type: application/json X-API-Key: {{apiKey}} { "aspectRatio": "1:1" } ### # Expected: 400 - "Prompt is required" ### Step 3.2: Empty body # @name emptyBody POST {{base}}/api/v1/generations Content-Type: application/json X-API-Key: {{apiKey}} {} ### # Expected: 400 - "Prompt is required" ############################################################################### # TEST 4: 404 for Non-Existent Resources ############################################################################### ### Step 4.1: Non-existent image # @name notFoundImage GET {{base}}/api/v1/images/00000000-0000-0000-0000-000000000000 X-API-Key: {{apiKey}} ### # Expected: 404 Not Found ### Step 4.2: Non-existent generation # @name notFoundGeneration GET {{base}}/api/v1/generations/00000000-0000-0000-0000-000000000000 X-API-Key: {{apiKey}} ### # Expected: 404 Not Found ### Step 4.3: Non-existent flow # @name notFoundFlow GET {{base}}/api/v1/flows/00000000-0000-0000-0000-000000000000 X-API-Key: {{apiKey}} ### # Expected: 404 Not Found ### Step 4.4: Non-existent alias # @name notFoundAlias GET {{base}}/api/v1/images/@non-existent-alias X-API-Key: {{apiKey}} ### # Expected: 404 - "Alias '@non-existent-alias' not found" ############################################################################### # TEST 5: Regenerate Generation ############################################################################### ### Step 5.1: Create generation for regenerate test # @name createForRegen POST {{base}}/api/v1/generations Content-Type: application/json X-API-Key: {{apiKey}} { "prompt": "Test image for regenerate", "aspectRatio": "1:1" } ### @regenSourceId = {{createForRegen.response.body.$.data.id}} ### Step 5.2: Poll until success # @name checkForRegen GET {{base}}/api/v1/generations/{{regenSourceId}} X-API-Key: {{apiKey}} ### ### Step 5.3: Regenerate # @name regenerateGen POST {{base}}/api/v1/generations/{{regenSourceId}}/regenerate Content-Type: application/json X-API-Key: {{apiKey}} {} ### # Verify: # - Returns new generation # - New generation has same prompt ### Step 5.4: Regenerate non-existent generation (should 404) # @name regenerateNotFound POST {{base}}/api/v1/generations/00000000-0000-0000-0000-000000000000/regenerate Content-Type: application/json X-API-Key: {{apiKey}} {} ### # Expected: 404 Not Found ############################################################################### # TEST 6: CDN Endpoints ############################################################################### ### Step 6.1: CDN image by path (if implemented) # @name cdnImage GET {{base}}/api/v1/cdn/default/test-project/generated/2024-01/test.jpg X-API-Key: {{apiKey}} ### # Note: Endpoint structure check only - actual paths depend on storage ### Step 6.2: Health check # @name healthCheck GET {{base}}/health ### # Expected: 200 with status info ############################################################################### # TEST 7: Authentication Errors ############################################################################### ### Step 7.1: Missing API key # @name noApiKey GET {{base}}/api/v1/generations ### # Expected: 401 Unauthorized ### Step 7.2: Invalid API key # @name invalidApiKey GET {{base}}/api/v1/generations X-API-Key: bnt_invalid_key_12345 ### # Expected: 401 Unauthorized ############################################################################### # TEST 8: Malformed Requests ############################################################################### ### Step 8.1: Invalid JSON # @name invalidJson POST {{base}}/api/v1/generations Content-Type: application/json X-API-Key: {{apiKey}} {invalid json} ### # Expected: 400 Bad Request ### Step 8.2: Wrong content type # @name wrongContentType POST {{base}}/api/v1/generations Content-Type: text/plain X-API-Key: {{apiKey}} prompt=test&aspectRatio=1:1 ### ############################################################################### # NOTES ############################################################################### # # Validation Rules: # - Prompt: required, non-empty string # - Aspect ratio: must be supported (1:1, 16:9, 9:16, 4:3, 3:4, 21:9) # - Alias: must start with @, alphanumeric + hyphens only # - UUID: must be valid UUID format # # Error Responses: # - 400: Validation error (missing/invalid fields) # - 401: Authentication error (missing/invalid API key) # - 404: Resource not found # - 429: Rate limit exceeded # - 500: Internal server error #