Domain names become an allocatable resource with one authority. A new core module (schema `domains`, own migration stream between core and the integrations) owns claims — a DNS node plus its whole subtree, mutually disjoint: operator shared-domain roots, member claims carved from them, and bring-your-own names proven by TXT verification — and placements, which bind a name inside a claim to a provider slug and resource ref. Verification moves to the claim and decouples from creation. A member proves control of a domain once; afterwards every name inside it places instantly, wildcard-CNAME friendly, with no further DNS work. The claim workflow activates the claim and stops — it no longer creates a site — so the sites list offers a one-click create once a domain verifies. /domains/ask answers from placements and is registered by core rather than the FedWiki adapter; its HTTP contract is unchanged. A configured `domains-ask-fallback-url` forwards names the registry does not know to a legacy answerer, the strangler seam wiki.cafe's migration needs; a name the registry knows but has archived is refused locally. FedWiki's create saga reserves the name before the farm call, carrying a workflow-minted site id so retries are idempotent, and compensates on failure. Sync places only names it owns, never stealing a member's; lifecycle transitions and the retention purge maintain servability. An unconditional boot pass seeds operator roots, releases orphaned placements, and adopts pre-existing sites — grandfathering member-owned external domains shortest-name-first, and skipping name policy, so a live single-letter site cannot lose its certificate. Members manage domains at /domains: claims with verification status, DNS records including an optional wildcard row, check-now, cancel, release. Name policy (reserved, blocked, premium, plus a single-letter guard) is operator data; refusals collapse to a plain "unavailable" so the console never becomes an oracle for who holds what. BREAKING (pre-release): `fedwiki.custom_domain_verifications` and `sites.is_custom_domain` are dropped, the flag now derived from the placement's claim kind; resource key `fedwiki_custom_domains` migrates to the platform-owned `external_domain_claims`; running verify-custom-domain workflows must be terminated before deploy.
50 lines
2.2 KiB
Go
50 lines
2.2 KiB
Go
package dnsname
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestValidateExternalFQDN(t *testing.T) {
|
|
// Four maximal labels + three dots = 255 chars, over the 253 limit.
|
|
overlongName := strings.Repeat("a", 63) + "." + strings.Repeat("b", 63) + "." +
|
|
strings.Repeat("c", 63) + "." + strings.Repeat("d", 63)
|
|
|
|
tests := []struct {
|
|
name string
|
|
domain string
|
|
operatorRoots []string
|
|
wantErr bool
|
|
}{
|
|
{"valid external domain", "wiki.example.org", []string{"example.test"}, false},
|
|
{"valid deep external domain", "a.b.wiki.example.org", []string{"example.test"}, false},
|
|
{"shape check only with no operator roots", "wiki.example.org", nil, false},
|
|
{"empty root entry ignored", "wiki.example.org", []string{""}, false},
|
|
{"punycode label accepted", "xn--53h.example.org", nil, false},
|
|
{"similar suffix is not under an operator root", "notexample.test", []string{"example.test"}, false},
|
|
{"clear of every operator root", "wiki.example.org", []string{"example.test", "other.test"}, false},
|
|
{"single label rejected", "intranet", nil, true},
|
|
{"empty rejected", "", nil, true},
|
|
{"operator root itself rejected", "example.test", []string{"example.test"}, true},
|
|
{"name under an operator root rejected", "foo.example.test", []string{"example.test"}, true},
|
|
{"deep name under an operator root rejected", "a.b.example.test", []string{"example.test"}, true},
|
|
{"name under a later operator root rejected", "a.other.test", []string{"example.test", "other.test"}, true},
|
|
{"uppercase rejected — caller must normalize", "Wiki.Example.org", nil, true},
|
|
{"label over 63 chars rejected", strings.Repeat("a", 64) + ".example.org", nil, true},
|
|
{"total over 253 chars rejected", overlongName, nil, true},
|
|
{"leading hyphen rejected", "-wiki.example.org", nil, true},
|
|
{"empty label rejected", "wiki..example.org", nil, true},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := ValidateExternalFQDN(tt.domain, tt.operatorRoots)
|
|
if tt.wantErr && got == "" {
|
|
t.Errorf("ValidateExternalFQDN(%q, %v) = no error, want error", tt.domain, tt.operatorRoots)
|
|
}
|
|
if !tt.wantErr && got != "" {
|
|
t.Errorf("ValidateExternalFQDN(%q, %v) = %q, want no error", tt.domain, tt.operatorRoots, got)
|
|
}
|
|
})
|
|
}
|
|
}
|