Commit 4fa3862
committed
refactor: restructure packages, fix bugs, and improve test coverage
Reorganize internal packages into domain/sync layers, fix multiple
correctness bugs, harden the integration test infrastructure, and
add comprehensive unit tests across all major packages.
Architecture:
- Extract shared App factory into internal/app/factory.go, removing
duplicated newApp() from all four cmd/ entry points
- Move domain types/interfaces/errors into internal/domain/
- Move sync logic into internal/sync/ with full unit tests
- Add context.Context to OktaClient interface, remove stored-context
anti-pattern
- Add compile-time interface assertions for GitHubClient and OktaClient
- Remove unused GitHubClientFactory and cross-installation code path
Bug fixes:
- Fix mapErrorResponse: errors.HasType() never matched errors.Mark()
markers; switch to errors.Is() so domain errors return correct HTTP
status codes (401/400/503/502) instead of always 500
- Fix GetOrCreateTeam: non-404 errors (403, 500) were misclassified as
ErrTeamNotFound
- Fix sync all-rules-failed detection: compared against len(reports)
instead of tracking enabled rule count separately
- Fix PR review deduplication: count only latest review per user
- Add GitHub Check Runs support alongside legacy commit statuses
- Fix token refresh TOCTOU race with double-check pattern
- Add Okta API pagination to ListGroups, GetGroupByName, GetGroupMembers
- Normalize username case in team membership comparisons
Test infrastructure:
- Replace hardcoded ports (9001-9003) with dynamic TLS listeners
- Add IP SANs to self-signed test certificates
- Add env var save/restore between integration test scenarios
- Add unexpected-destructive-call validation
- Fix test log handler Enabled() to respect verbose flag
- Add request body size limit (10MB) to HTTP server
Test coverage (before -> after):
- internal/app: 24.5% -> 55.8%
- internal/config: 14.8% -> 74.1%
- internal/notifiers: 2.7% -> 97.3%
- internal/sync: 82.8% -> 83.3%
Cleanup:
- Remove all fmt.Errorf usage, consistently use cockroachdb/errors
- Remove dead ErrOAuthTokenExpired sentinel
- Extract extractGroupName() helper in okta package
- Pre-compile regex in sync.go computeTeamName
- Trim leading/trailing dashes from generated team names1 parent 73c627d commit 4fa3862
File tree
34 files changed
+2606
-515
lines changed- .github
- workflows
- assets/github
- cmd
- lambda
- sample
- server
- verify
- internal
- app
- config
- domain
- github
- client
- webhooks
- notifiers
- okta
- sync
- types
34 files changed
+2606
-515
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
File renamed without changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
91 | | - | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| |||
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
0 commit comments