Skip to content

Commit 3c71440

Browse files
committed
phase 5 fixes
1 parent ae4d42f commit 3c71440

12 files changed

Lines changed: 4254 additions & 13 deletions

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
4141
- name: Run Go tests
4242
env:
43-
TEST_DB_DSN: postgres://testuser:testpassword@localhost:5432/controlplane_test?sslmode=disable
43+
TEST_DATABASE_URL: postgres://testuser:testpassword@localhost:5432/controlplane_test?sslmode=disable
4444
run: go test -v -count=1 ./...
4545

4646
- name: Build application

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ This is not a blog, not a todo app, and not a public wiki. It is an operational
8282

8383
## Current Status
8484

85-
> **Phase 5 — Production Hardening** (in progress)
85+
> **Phase 5 — Production Hardening** (Complete)
8686
87-
Phase 5 test files are complete. CI pipeline is implemented and currently being refined.
87+
Phase 5 test files, integration tests, rate limiting, and CI pipelines are now complete. The backend is fully hardened for production use.
8888

8989
| Phase | Description | Status |
9090
|-------|-------------|--------|
@@ -93,7 +93,7 @@ Phase 5 test files are complete. CI pipeline is implemented and currently being
9393
| Phase 2 | Forms, validation, sessions, auth, context | ✅ Complete |
9494
| Phase 3 | Notebooks, revisions, tags, search, DB-backed pages | ✅ Complete |
9595
| Phase 4 | Approvals, audit, moderation, governance | ✅ Complete |
96-
| Phase 5 | Tests, CI, production hardening | 🔧 In Progress |
96+
| Phase 5 | Tests, CI, production hardening | ✅ Complete |
9797

9898
---
9999

@@ -568,8 +568,8 @@ gantt
568568
Approvals, audit, moderation :done, p4, after p3, 21d
569569
570570
section Phase 5
571-
Tests & CI :active, p5, after p4, 14d
572-
Production hardening : p5b, after p5, 14d
571+
Tests & CI :done, p5, after p4, 14d
572+
Production hardening :done, p5b, after p5, 14d
573573
```
574574

575575
### Phase 0 — Foundation ✅
@@ -612,7 +612,7 @@ gantt
612612
- Moderation flags table
613613
- Admin audit page
614614

615-
### Phase 5 — Production Hardening 🔧
615+
### Phase 5 — Production Hardening
616616

617617
- [x] Test infrastructure: `fakeStore`, `newTestApplication`, `serveWithSession`
618618
- [x] Context helper tests
@@ -622,10 +622,10 @@ gantt
622622
- [x] Notebook handler tests (create, view, validation)
623623
- [x] Approval handler tests (approve/reject transactions)
624624
- [x] GitHub Actions CI pipeline
625-
- [ ] CI pipeline refinement and edge cases
626-
- [ ] Structured error handling improvements
627-
- [ ] Request logging and observability
628-
- [ ] Graceful shutdown
625+
- [x] CI pipeline refinement and edge cases
626+
- [x] Structured error handling improvements
627+
- [x] Request logging and observability
628+
- [x] Graceful shutdown
629629

630630
---
631631

cmd/web/csrf_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package web
22

33
import (
4+
"html"
45
"html/template"
56
"io"
67
"net/http"
@@ -104,6 +105,7 @@ func TestCSRFAcceptsPostWithValidToken(t *testing.T) {
104105

105106
token := strings.TrimPrefix(body, "<form>")
106107
token = strings.TrimSuffix(token, "</form>")
108+
token = html.UnescapeString(token)
107109

108110
if token == "" {
109111
t.Fatal("CSRF token was empty from GET /login")

cmd/web/main.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,17 @@ func main() {
7171
log.Fatalf("CSRF_SECRET must be at least 32 bytes; got %d", len(csrfSecret))
7272
}
7373

74+
stateStr := os.Getenv("ENV")
75+
if stateStr == "" {
76+
stateStr = string(Development)
77+
}
78+
state := State(stateStr)
79+
7480
cfg := Config{
7581
Port: 6767,
7682
Database: os.Getenv("DATABASE_URL"),
77-
State: Development,
78-
SecureCookies: false,
83+
State: state,
84+
SecureCookies: state == Production,
7985
CSRFSecret: []byte(csrfSecret),
8086
}
8187

0 commit comments

Comments
 (0)