Artifact b664afdff63359eaac4b5b33be833fd774247fafb5fb5931434d9e69bd35fc55:
- File
internal/auth/invite_test.go
— part of check-in
[f5744359d3]
at
2026-04-19 16:30:54
on branch trunk
— Initial open source release
libfossil is a pure-Go implementation of the Fossil SCM, reading and writing the same .fossil SQLite repository format as upstream Fossil.
This is the first public release of code that previously lived in a private repository. The module path is github.com/danmestas/libfossil and the binary is named libfossil to avoid $PATH collisions with upstream fossil.
Included: - Repo lifecycle (create, clone), checkout/checkin, timeline, merge, diff, annotate, shun, tag, branch, bisect, stash, undo/redo - Sync-over-HTTP protocol (client and handler) - Two SQLite drivers: modernc (pure Go, default) and ncruces (wasm-capable) - Observer interfaces (SyncObserver, CheckoutObserver) with an optional OpenTelemetry implementation in observer/otel (separate submodule) - Deterministic simulation testing harness with BUGGIFY fault injection - Kong-based embeddable CLI under cli/ and a standalone binary under cmd/libfossil/ (user: [email protected], size: 1154) [annotate] [blame] [check-ins using]
package auth import "testing" func TestInviteTokenRoundTrip(t *testing.T) { tok := InviteToken{ URL: "nats://100.78.32.45:4222/my-repo", Login: "bob", Password: "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2", Caps: "oi", } encoded := tok.Encode() if encoded == "" { t.Fatal("Encode returned empty string") } decoded, err := DecodeInviteToken(encoded) if err != nil { t.Fatalf("DecodeInviteToken: %v", err) } if decoded.URL != tok.URL { t.Errorf("URL = %q, want %q", decoded.URL, tok.URL) } if decoded.Login != tok.Login { t.Errorf("Login = %q, want %q", decoded.Login, tok.Login) } if decoded.Password != tok.Password { t.Errorf("Password = %q, want %q", decoded.Password, tok.Password) } if decoded.Caps != tok.Caps { t.Errorf("Caps = %q, want %q", decoded.Caps, tok.Caps) } } func TestDecodeInviteTokenInvalid(t *testing.T) { _, err := DecodeInviteToken("not-valid-base64!!!") if err == nil { t.Fatal("expected error for invalid token") } _, err = DecodeInviteToken("bm90LWpzb24=") // "not-json" in base64 if err == nil { t.Fatal("expected error for non-JSON token") } }