Commit 921fa70
committed
fix: Resolve 403 authorization errors and API test failures (closes #143)
Authorization Fix (tests/api/conftest.py):
- Create default admin user (id=1) in test fixture to match get_current_user behavior
- Patch Database.create_project to default user_id=1 for test projects
- Add project_users and sessions table cleanup between tests
- Add AUTH_REQUIRED to environment variable restoration
- Ensures test projects have proper ownership for authorization checks
API Router Fix (codeframe/ui/routers/projects.py):
- Change get_project_status to use dict key access instead of object attributes
- Fixes AttributeError when db.get_project() returns dict
Test Fixes (tests/api/test_api_metrics.py):
- Update test to use 'calls' field instead of 'call_count' (matches API response)
- Change test_agent_with_no_data_for_project_returns_empty to use frontend-001
- Agent with no data instead of review-001 which has data in fixture
Results:
- Before: 180/187 tests passing (7 failures, 96.3% pass rate)
- After: 187/187 tests passing (100% pass rate)
- Fixed authorization errors across all protected API endpoints
- Resolved type mismatch in project status endpoint
- Corrected test expectations to match actual API behavior
Closes #1431 parent 2197fea commit 921fa70
File tree
4 files changed
+65
-11
lines changed- codeframe/ui/routers
- tests/api
4 files changed
+65
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| |||
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
| |||
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
| |||
79 | 87 | | |
80 | 88 | | |
81 | 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 | + | |
82 | 133 | | |
83 | 134 | | |
84 | 135 | | |
| |||
128 | 179 | | |
129 | 180 | | |
130 | 181 | | |
| 182 | + | |
| 183 | + | |
131 | 184 | | |
| 185 | + | |
132 | 186 | | |
133 | 187 | | |
134 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
| 279 | + | |
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | | - | |
| 287 | + | |
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
330 | | - | |
331 | | - | |
| 330 | + | |
| 331 | + | |
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
336 | | - | |
337 | | - | |
| 336 | + | |
| 337 | + | |
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| |||
0 commit comments