-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathtest.http
More file actions
251 lines (204 loc) · 8.26 KB
/
Copy pathtest.http
File metadata and controls
251 lines (204 loc) · 8.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
###############################################
# Go SNMP OLT ZTE C320/C300 — live API test collection
# Works with VS Code "REST Client" and JetBrains HTTP Client.
# OpenAPI: api/openapi.yaml
#
# Response contract (v3.x):
# success: {"code":200,"status":"success","data":...,"meta":{...}}
# error : {"code":400,"status":"...","error_code":"...","data":...,"request_id":"..."}
#
# Defaults match the multi-OLT + per-tenant dev setup used in testing:
# OLTS : id "1" = C320 (boards 1,2, user_id 1); id "2" = C300 (slot 3, user_id 2)
# DEFAULT_OLT : 1 (also answers the bare /api/v1/board/... paths)
# API_USERS : keyA -> user 1, keyB -> user 2, admintoken -> admin (sees all)
# Override the variables below for your own instance.
###############################################
@host = http://localhost:8081
@olt1 = 1
@olt2 = 2
@keyA = keyA
@keyB = keyB
@admin = admintoken
# Single-key / legacy deployments (OLTS + API_USERS unset): set this instead.
@API_KEY = admintoken
###############################################
# Health, Readiness, Version, Metrics (no auth, never rate limited)
###############################################
### Liveness probe (legacy alias) -> 200
GET {{host}}/health
Accept: application/json
### Liveness probe (k8s style) -> 200
GET {{host}}/healthz
Accept: application/json
### Readiness probe -> 200 {"status":"ready","dependencies":{"redis":{...},"snmp_1":{...},"snmp_2":{...}}}
# In multi-OLT mode each OLT has its own probe keyed snmp_<id>. Secondary OLTs
# are non-critical: one unreachable -> degraded report but still 200.
GET {{host}}/readyz
Accept: application/json
### Build metadata (version, commit, build_time, uptime) -> 200
GET {{host}}/version
Accept: application/json
### Prometheus metrics -> 200
GET {{host}}/metrics
Accept: text/plain
### Root endpoint -> 200
GET {{host}}/
Accept: application/json
###############################################
# Authentication (per-tenant API_USERS)
# 401 envelope: {"code":401,"status":"Unauthorized","error_code":"UNAUTHORIZED","data":"...","request_id":"..."}
###############################################
### No API key -> 401
GET {{host}}/api/v1/olt/{{olt1}}/board/1/pon/1/
Accept: application/json
### Invalid API key -> 401
GET {{host}}/api/v1/olt/{{olt1}}/board/1/pon/1/
Accept: application/json
X-API-Key: not-a-real-key
###############################################
# Tenant isolation (the core of per-user access control)
# Cross-tenant requests return 404 (NOT 403) to prevent enumeration.
###############################################
### user1 -> own OLT (C320) -> 200
GET {{host}}/api/v1/olt/{{olt1}}/board/1/pon/1/
Accept: application/json
X-API-Key: {{keyA}}
### user1 -> other tenant's OLT (C300) -> 404
GET {{host}}/api/v1/olt/{{olt2}}/board/3/pon/1/
Accept: application/json
X-API-Key: {{keyA}}
### user2 -> own OLT (C300) -> 200
GET {{host}}/api/v1/olt/{{olt2}}/board/3/pon/1/
Accept: application/json
X-API-Key: {{keyB}}
### user2 -> other tenant's OLT (C320) -> 404
GET {{host}}/api/v1/olt/{{olt1}}/board/1/pon/1/
Accept: application/json
X-API-Key: {{keyB}}
### admin -> C320 -> 200
GET {{host}}/api/v1/olt/{{olt1}}/board/1/pon/1/
Accept: application/json
X-API-Key: {{admin}}
### admin -> C300 -> 200
GET {{host}}/api/v1/olt/{{olt2}}/board/3/pon/1/
Accept: application/json
X-API-Key: {{admin}}
###############################################
# Bare /board paths -> DEFAULT_OLT (olt 1 / C320), scoped to its owner
###############################################
### user1 owns the default OLT -> 200
GET {{host}}/api/v1/board/1/pon/1/
Accept: application/json
X-API-Key: {{keyA}}
### user2 does NOT own the default OLT -> 404
GET {{host}}/api/v1/board/1/pon/1/
Accept: application/json
X-API-Key: {{keyB}}
###############################################
# ONU read endpoints (multi-OLT path, full surface)
###############################################
### List all ONUs on a board/PON -> 200
GET {{host}}/api/v1/olt/{{olt1}}/board/1/pon/1/
Accept: application/json
X-API-Key: {{admin}}
### Specific ONU detail -> 200 (404 if onu_id absent)
GET {{host}}/api/v1/olt/{{olt1}}/board/1/pon/1/onu/1
Accept: application/json
X-API-Key: {{admin}}
### Empty / available ONU IDs -> 200
GET {{host}}/api/v1/olt/{{olt1}}/board/1/pon/1/onu_id/empty
Accept: application/json
X-API-Key: {{admin}}
### ONU IDs with serial numbers -> 200
GET {{host}}/api/v1/olt/{{olt1}}/board/1/pon/1/onu_id_sn
Accept: application/json
X-API-Key: {{admin}}
### Paginated ONU list -> 200
GET {{host}}/api/v1/olt/{{olt1}}/paginate/board/1/pon/1?page=1&limit=10
Accept: application/json
X-API-Key: {{admin}}
### C300 (olt 2) list via admin -> 200
GET {{host}}/api/v1/olt/{{olt2}}/board/3/pon/1/
Accept: application/json
X-API-Key: {{admin}}
###############################################
# Write / cache endpoints (emit an audit log entry)
###############################################
### Force refresh empty ONU ID cache (POST) -> 200
POST {{host}}/api/v1/olt/{{olt1}}/board/1/pon/1/onu_id/update
Accept: application/json
X-API-Key: {{admin}}
### Clear cache for a board/PON (DELETE) -> 200
DELETE {{host}}/api/v1/olt/{{olt1}}/board/1/pon/1/cache/clear
Accept: application/json
X-API-Key: {{admin}}
###############################################
# Validation & error contract
###############################################
### Unknown OLT id -> 404
GET {{host}}/api/v1/olt/does-not-exist/board/1/pon/1/
Accept: application/json
X-API-Key: {{admin}}
### board_id out of range -> 400 VALIDATION_ERROR
GET {{host}}/api/v1/olt/{{olt1}}/board/99/pon/1/
Accept: application/json
X-API-Key: {{admin}}
### pon_id out of range for the card -> 400 VALIDATION_ERROR
GET {{host}}/api/v1/olt/{{olt1}}/board/1/pon/99/
Accept: application/json
X-API-Key: {{admin}}
### Slot not present on this OLT (C320 has no slot 3) -> 400
GET {{host}}/api/v1/olt/{{olt1}}/board/3/pon/1/
Accept: application/json
X-API-Key: {{admin}}
### Request ID echo: response echoes X-Request-ID (header + error body request_id)
GET {{host}}/api/v1/olt/{{olt1}}/board/99/pon/1/
Accept: application/json
X-API-Key: {{admin}}
X-Request-ID: my-custom-trace-id-123
###############################################
# Single-OLT / legacy mode (OLTS + API_USERS unset; single API_KEY)
# Uses the bare /api/v1/board/... paths with {{API_KEY}}.
###############################################
### Legacy: list ONUs -> 200
GET {{host}}/api/v1/board/1/pon/8
Accept: application/json
X-API-Key: {{API_KEY}}
### Legacy: paginate -> 200 (pagination lives under /paginate/, not query params on the list path)
GET {{host}}/api/v1/paginate/board/1/pon/8?page=2&limit=5
Accept: application/json
X-API-Key: {{API_KEY}}
###############################################
# Uplink / card auto-detect (ENTITY-MIB + IF-MIB; detection-only, no writes)
###############################################
### Default OLT uplink topology -> 200 {cards[], ports[]}
GET {{host}}/api/v1/uplinks
Accept: application/json
X-API-Key: {{API_KEY}}
### Per-OLT uplink topology -> 200
GET {{host}}/api/v1/olt/{{olt1}}/uplinks
Accept: application/json
X-API-Key: {{admin}}
###############################################
# Forced-fresh serial-list read (?nocache=true bypasses + refreshes the
# serial-list Redis cache — used by write-olt-zte pre-write checks)
###############################################
### Cached serial list (default) -> 200
GET {{host}}/api/v1/olt/{{olt1}}/board/1/pon/1/onu_id_sn
Accept: application/json
X-API-Key: {{admin}}
### Forced-fresh serial list -> 200 (live SNMP read, cache repopulated)
GET {{host}}/api/v1/olt/{{olt1}}/board/1/pon/1/onu_id_sn?nocache=true
Accept: application/json
X-API-Key: {{admin}}
###############################################
# Notes
# - Response headers on every request: X-Request-ID, X-API-Version, X-App-Version, X-Build-Commit
# - Health/readiness/metrics are unauthenticated AND exempt from the rate limiter
# (so k8s probes and Prometheus scrapes are never 429'd under API load).
# - API rate limit: 100 req/s, burst 200 (global; infra endpoints exempt).
# - board_id = physical GPON slot (C320: 1-2; C300: e.g. 3,5). pon_id validated
# per card (GTGO=8, GTGH=16). Valid slots/pons differ per OLT.
# - Per-tenant: each OLT carries a user_id; a caller sees only its own OLTs
# (cross-tenant -> 404). role "admin" sees all. Unowned (user_id 0) = admin-only.
###############################################