mirror of
https://github.com/hanzoai/iam.git
synced 2026-11-19 18:37:16 +00:00
Comments and published descriptions here explained several controls by
recounting the state of the service before them — a date, the credential
involved, the tenants probed, the record counts returned, the endpoint that
answered ok when nothing was sent, the named app that shipped broken. A reader
who wants to know what the code does has to reconstruct it from that; a reader
who wants somewhere to push learns where. This repository is public, and several
of these were served as API documentation: the OpenAPI description, the MCP tool
list and every generated client and CLI carried them.
Each now states the property the control holds, which is the durable half and
the half a reader needs. Genuine design rationale ("it used to do X, now Y")
stays where it carries no incident specifics. Source comments and generated docs
only; the executable tree is untouched.
zipdoc is regenerated from the corrected sources. internal/mfa carried a
committed zipdoc_gen.go but no //go:generate directive, so the check loop skipped
it and its published MFA-enable description would have drifted unseen; the
directive is added here, alongside the mfa comment fix it belongs with, so the
package is regenerated and checked like every other.
Covers the reads and writes whose comments recounted an incident: the
organization listing and its agent-door reach, ScopeRead's membership clause, the
entity-noun fold, the token endpoint's one named error, refresh and revoke for a
public client, wallet and signup tenant isolation, the seed reconcile and its
passkey convergence, the per-org OIDC callback, the machine-bearer principal, the
update-application secret preserve, the one-key-per-member mint, the MFA enable
gate, the passkey list scope, both logout routes, the service-account credential
home, the new-application signing cert, and the no-org-choice tenant confinement.
Co-authored-by: Hanzo Dev <[email protected]>
42 lines
1.7 KiB
Go
42 lines
1.7 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
|
|
package bootstrap
|
|
|
|
import "testing"
|
|
|
|
// A new application must be created able to SIGN. issueTokens resolves app.Cert,
|
|
// so a registration without one authenticates the user, mints a code, redeems it,
|
|
// and only then answers `500 server_error` — a login that fails after the user has
|
|
// already done everything right, and looks from the browser like an outage.
|
|
//
|
|
// An application registered by an upsert that never mentioned a cert lands in
|
|
// exactly that state, and every sign-in dies at the token exchange — which is what
|
|
// this refuses.
|
|
func TestResolveCert_ANewApplicationCanAlwaysSign(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
name string
|
|
requested string
|
|
org string
|
|
want string
|
|
}{
|
|
{name: "explicit wins", requested: "cert-special", org: "hanzo", want: "cert-special"},
|
|
{name: "explicit wins with no org", requested: "cert-special", want: "cert-special"},
|
|
{name: "derived from the organization", org: "hanzo", want: "cert-hanzo"},
|
|
{name: "derived for any brand", org: "lux", want: "cert-lux"},
|
|
{name: "blank is not a cert", requested: " ", org: "zoo", want: "cert-zoo"},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
if got := resolveCert(tc.requested, tc.org); got != tc.want {
|
|
t.Errorf("resolveCert(%q, %q) = %q, want %q", tc.requested, tc.org, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Nothing to derive from. The caller must REFUSE rather than create a client
|
|
// that can never mint a token — an empty result is what triggers that, so it
|
|
// has to stay empty rather than become a plausible-looking guess.
|
|
if got := resolveCert("", ""); got != "" {
|
|
t.Errorf("resolveCert with nothing to go on = %q, want empty so the caller refuses", got)
|
|
}
|
|
}
|