guide: read-only guided manual-rotation layer (links + worklist + TUI)
Advances the guided-rotation goal without rotating anything. - internal/links: offline change-password URL generation — curated per-service table + RFC 8615 /.well-known/change-password + parent-domain fallback; derives a web host from a credential (git/netrc "user @ host", docker registry, aws) - internal/worklist: secrets-free rotation worklist (source, identity, auto/manual, link) + Markdown renderer - internal/tui: Bubble Tea walk-through (one credential per screen, open link, mark done/skip, progress) — READ-ONLY, enters/stores no secret - cmd: `incredigo worklist` (offline, stdout/--out) and `incredigo guide` (TUI) - tests: link derivation, worklist build/markdown + no-secret-column, TUI navigation/done/quit/view Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package links
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"incredigo/internal/discover"
|
||||
)
|
||||
|
||||
func TestFor(t *testing.T) {
|
||||
cases := []struct {
|
||||
host string
|
||||
wantURL string
|
||||
wantSrc Source
|
||||
}{
|
||||
{"github.com", "https://github.com/settings/tokens", SourceKnown},
|
||||
{"GitHub.com:443", "https://github.com/settings/tokens", SourceKnown},
|
||||
{"api.github.com", "https://github.com/settings/tokens", SourceKnown}, // parent-domain fallback
|
||||
{"s3.amazonaws.com", "https://console.aws.amazon.com/iam/home#/security_credentials", SourceKnown},
|
||||
{"example.com", "https://example.com/.well-known/change-password", SourceWellKnown},
|
||||
{"registry.internal.corp", "https://registry.internal.corp/.well-known/change-password", SourceWellKnown},
|
||||
{"", "", SourceNone},
|
||||
}
|
||||
for _, c := range cases {
|
||||
got := For(c.host)
|
||||
if got.URL != c.wantURL || got.Source != c.wantSrc {
|
||||
t.Errorf("For(%q) = {%q,%s}, want {%q,%s}", c.host, got.URL, got.Source, c.wantURL, c.wantSrc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestHostFor(t *testing.T) {
|
||||
cases := []struct {
|
||||
cred discover.Credential
|
||||
want string
|
||||
}{
|
||||
{discover.Credential{Source: "git", Identity: "alice @ github.com"}, "github.com"},
|
||||
{discover.Credential{Source: "netrc", Identity: "bob @ api.example.com"}, "api.example.com"},
|
||||
{discover.Credential{Source: "netrc", Identity: "bob @ default"}, ""}, // netrc "default" is not a host
|
||||
{discover.Credential{Source: "docker", Identity: "ghcr.io"}, "ghcr.io"},
|
||||
{discover.Credential{Source: "aws", Identity: "default / AKIA***"}, "console.aws.amazon.com"},
|
||||
{discover.Credential{Source: "ssh", Identity: "id_ed25519"}, ""},
|
||||
{discover.Credential{Source: "file", Identity: "keys/deploy"}, ""},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := HostFor(c.cred); got != c.want {
|
||||
t.Errorf("HostFor(%s/%q) = %q, want %q", c.cred.Source, c.cred.Identity, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLinkForGit(t *testing.T) {
|
||||
l := LinkFor(discover.Credential{Source: "git", Identity: "alice @ github.com"})
|
||||
if l.Source != SourceKnown || l.URL != "https://github.com/settings/tokens" {
|
||||
t.Errorf("LinkFor git github = {%q,%s}", l.URL, l.Source)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user