M2-T05: add SMTP test action API (POST /api/config/smtp/test)
- reuses send_smtp_test_email; tri-state result success(200)/config-error(400)/failed(502) - session + CSRF protected; never echoes SMTP secrets - SmtpTestResponse schema; regenerate openapi/ - extend tests/test_api_config.py (3 states + 401 + missing-CSRF 403)
This commit is contained in:
@@ -222,6 +222,61 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/HTTPValidationError'
|
||||
/api/config/smtp/test:
|
||||
post:
|
||||
tags:
|
||||
- api-config
|
||||
summary: Post Smtp Test
|
||||
description: 'Send a test SMTP email using the current runtime settings.
|
||||
|
||||
|
||||
Returns a structured result indicating success or the category of failure.
|
||||
|
||||
Three possible outcomes:
|
||||
|
||||
- 200 { "result": "success", "message": ... }
|
||||
|
||||
- 400 { "result": "config-error", "message": ... } (EmailConfigurationError)
|
||||
|
||||
- 502 { "result": "failed", "message": ... } (EmailDeliveryError)
|
||||
|
||||
|
||||
SMTP credentials are never echoed in the response.'
|
||||
operationId: post_smtp_test_api_config_smtp_test_post
|
||||
parameters:
|
||||
- name: X-CSRF-Token
|
||||
in: header
|
||||
required: false
|
||||
schema:
|
||||
anyOf:
|
||||
- type: string
|
||||
- type: 'null'
|
||||
title: X-Csrf-Token
|
||||
responses:
|
||||
'200':
|
||||
description: Successful Response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/SmtpTestResponse'
|
||||
'400':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/SmtpTestResponse'
|
||||
description: Bad Request
|
||||
'502':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/SmtpTestResponse'
|
||||
description: Bad Gateway
|
||||
'422':
|
||||
description: Validation Error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/HTTPValidationError'
|
||||
/api/locations:
|
||||
get:
|
||||
tags:
|
||||
@@ -1192,6 +1247,24 @@ components:
|
||||
- username
|
||||
- force_password_change
|
||||
title: SessionUser
|
||||
SmtpTestResponse:
|
||||
properties:
|
||||
result:
|
||||
type: string
|
||||
enum:
|
||||
- success
|
||||
- config-error
|
||||
- failed
|
||||
title: Result
|
||||
message:
|
||||
type: string
|
||||
title: Message
|
||||
type: object
|
||||
required:
|
||||
- result
|
||||
- message
|
||||
title: SmtpTestResponse
|
||||
description: Response from POST /api/config/smtp/test.
|
||||
StatusResponse:
|
||||
properties:
|
||||
status:
|
||||
|
||||
Reference in New Issue
Block a user