Backend: - service_auto module complet: router, service, schemas, 5 teste suites (22/22 passed) - 5 endpoints: GET /ping, /firme, /tip-deviz, /masini, POST /comenzi - SP_CREEAZA_COMANDA_PROTOTIP creat în MARIUSM_AUTO (VALID, 5.9ms) - oracle_pool.py: session_callback backward-compat patch - ROA_WEB user: grants SP-only confirmate (H3), mariusm_test pool switchat - pyproject.toml: integration pytest marker înregistrat Frontend: - ComandaNoua.vue: date reale din Oracle (firme/tip-deviz/masini), nu hardcodate - src/modules/service-auto/services/api.js: axios service cu Bearer token - src/router/index.js: rută /service-auto/comanda-noua Docs: - decision-log.md: verdict MERGE, toate 6 ipoteze CONFIRMED - learnings.md: 7 patterns reutilizabile - grants-audit.md: arhitectura multi-tenant + proxy auth analysis + V_NOM_FIRME loop - template-modul-oracle.md: rețetă completă pentru module Oracle noi - TODO-phase2.md: 7 items concrete Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
68 lines
1.7 KiB
Markdown
68 lines
1.7 KiB
Markdown
# Săpt 6 — Checkpoint: GET /api/service-auto/ping
|
|
|
|
## Endpoint
|
|
|
|
`GET /api/service-auto/ping` — Health check Oracle connectivity pentru serverul `mariusm_test`.
|
|
|
|
**Implementat în**: `backend/modules/service_auto/routers/comanda.py`
|
|
|
|
## Comportament
|
|
|
|
1. Verifică autentificare JWT (`get_current_user` dependency)
|
|
2. Deschide conexiune din `oracle_pool` pentru server-ul `mariusm_test`
|
|
3. Execută `SELECT 1 FROM DUAL`
|
|
4. Returnează rezultatul cu latența măsurată
|
|
|
|
## Răspuns așteptat (200 OK)
|
|
|
|
```json
|
|
{
|
|
"result": 1,
|
|
"server": "mariusm_test",
|
|
"latency_ms": 12.34
|
|
}
|
|
```
|
|
|
|
## Eroare Oracle (503 Service Unavailable)
|
|
|
|
```json
|
|
{
|
|
"detail": "Oracle error: ORA-12541: TNS:no listener"
|
|
}
|
|
```
|
|
|
|
## Comandă curl pentru testare
|
|
|
|
```bash
|
|
# 1. Obține token JWT (înlocuiește credențialele)
|
|
TOKEN=$(curl -s -X POST http://localhost:8000/api/auth/login \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"username":"MARIUS M","password":"123","company_id":1}' \
|
|
| python3 -c "import sys,json; print(json.load(sys.stdin)['access_token'])")
|
|
|
|
# 2. Ping Oracle
|
|
curl -s -X GET http://localhost:8000/api/service-auto/ping \
|
|
-H "Authorization: Bearer $TOKEN" | python3 -m json.tool
|
|
```
|
|
|
|
### Răspuns așteptat (server TEST):
|
|
|
|
```json
|
|
{
|
|
"result": 1,
|
|
"server": "mariusm_test",
|
|
"latency_ms": 8.45
|
|
}
|
|
```
|
|
|
|
## Routing path
|
|
|
|
`main.py` → `create_service_auto_router()` → `comanda_router` inclus cu prefix `/api/service-auto`
|
|
→ `GET /ping` devine `GET /api/service-auto/ping`
|
|
|
|
## Note implementare
|
|
|
|
- `time.perf_counter()` pentru latență (monotonic, rezoluție înaltă)
|
|
- `oracledb.DatabaseError` prins explicit → HTTP 503
|
|
- `_: CurrentUser` — user din JWT nu e necesar în body, dar dependency enforces auth
|