Normalize configured team hostnames before binding checks
2 files changed,
+14
−2
internal/docs/contract_demo.go+3 −2internal/docs/contract_demo_test.go+11 −0
CI failed — run details
diff --git a/internal/docs/contract_demo.go b/internal/docs/contract_demo.go| index 87945d9..17b7fee 100644 |
| --- a/internal/docs/contract_demo.go |
| +++ b/internal/docs/contract_demo.go |
| @@ -300,8 +300,9 @@ func contractTeam(origin, team string) bool { |
| if e != nil { |
| return false |
| } |
| - parts := strings.Split(u.Hostname(), ".") |
| - if strings.HasSuffix(u.Hostname(), ".oficina.works") && len(parts) >= 4 { |
| + host := strings.TrimSuffix(strings.ToLower(u.Hostname()), ".") |
| + parts := strings.Split(host, ".") |
| + if strings.HasSuffix(host, ".oficina.works") && len(parts) >= 4 { |
| return len(parts) == 4 && parts[0] == team |
| } |
| return true |
diff --git a/internal/docs/contract_demo_test.go b/internal/docs/contract_demo_test.go| index 77efc39..85ece46 100644 |
| --- a/internal/docs/contract_demo_test.go |
| +++ b/internal/docs/contract_demo_test.go |
| @@ -183,3 +183,14 @@ func TestContractLiveFlowAndBoundaries(t *testing.T) { |
| t.Fatal("stale writer accepted") |
| } |
| } |
| + |
| +func TestContractTeamBinding(t *testing.T) { |
| + for _, origin := range []string{"https://other.docs.oficina.works", "https://other.docs.OFICINA.WORKS", "https://other.docs.oficina.works."} { |
| + if contractTeam(origin, "ours") { |
| + t.Errorf("accepted different team: %s", origin) |
| + } |
| + } |
| + if !contractTeam("https://ours.docs.oficina.works", "ours") || !contractTeam("https://docs.oficina.works", "standalone") { |
| + t.Fatal("valid explicit binding refused") |
| + } |
| +} |