MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestHamrpassRejectsMultipleArgs

Function TestHamrpassRejectsMultipleArgs

internal/tui/tui_test.go:3084–3100  ·  view source on GitHub ↗

TestHamrpassRejectsMultipleArgs: a paste with embedded whitespace splits into multiple args via strings.Fields. The handler refuses with a dedicated message rather than silently joining or accepting one half.

(t *testing.T)

Source from the content-addressed store, hash-verified

3082 final := m2.(Model)
3083 if final.cfg.Active != beforeActive {
3084 t.Fatalf("active changed on rejected key: %q", final.cfg.Active)
3085 }
3086 if final.cfg.Models["hamrpass"].Key != beforeKey {
3087 t.Fatalf("rejected key was stored: %q", final.cfg.Models["hamrpass"].Key)
3088 }
3089 out := stripANSI(final.scroll.String())
3090 // New wording stays consistent with the popover hint:
3091 // "N/16 chars · keep typing".
3092 if !strings.Contains(out, "/16 chars") || !strings.Contains(out, "keep typing") {
3093 t.Fatalf("expected length hint in scrollback:\n%s", out)
3094 }
3095}
3096
3097// TestHamrpassRejectsControlChars: a key with an embedded escape / NUL / DEL must
3098// be rejected by hamrpassValidate, not persisted, else every dial-out errors
3099// with net/http's cryptic "invalid header field value for Authorization". Real
3100// hamrpass keys are ASCII-printable.
3101func TestHamrpassRejectsControlChars(t *testing.T) {
3102 cases := map[string]string{
3103 "NUL": "hp_secret_key_with\x00null",

Callers

nothing calls this directly

Calls 4

newTestModelFunction · 0.85
stripANSIFunction · 0.85
runSlashMethod · 0.80
StringMethod · 0.80

Tested by

no test coverage detected