fix: finish profile editor preview scrolling
This commit is contained in:
@@ -167,7 +167,70 @@ func TestCompleteModelProfileEditorScrollsLongBypassPreviewAt80Columns(t *testin
|
||||
model = updateKey(model, "pgdown")
|
||||
}
|
||||
model = resize(model, 80, 24)
|
||||
assertUsableFrame(t, model.View(), 80, 24, "! item 25", "late invalid entry", "invalid", "PgUp/PgDn: scroll form")
|
||||
assertUsableFrame(t, model.View(), 80, 24,
|
||||
"> Bypass [focused]", "! item 25", "late invalid entry", "invalid", "PgUp/PgDn: scroll form")
|
||||
|
||||
model = updateKey(model, "pgup")
|
||||
view := model.View()
|
||||
assertUsableFrame(t, view, 80, 24, "> Bypass [focused]", "host-19.example", "PgUp/PgDn: scroll form")
|
||||
if strings.Contains(view, "! item 25") {
|
||||
t.Fatalf("PgUp did not move the persistent Bypass preview viewport:\n%s", view)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompleteModelProfileEditorObscuresCredentialsInScrolledBypassValidation(t *testing.T) {
|
||||
module := &profileManagementModule{}
|
||||
model := openNewProfileEditor(t, module)
|
||||
model = updateRunes(model, "office")
|
||||
model = updateKey(model, "tab")
|
||||
model = updateRunes(model, "proxy.example:8080")
|
||||
model = updateKey(model, "tab")
|
||||
items := make([]string, 0, 25)
|
||||
for i := range 24 {
|
||||
items = append(items, fmt.Sprintf("host-%02d.example", i))
|
||||
}
|
||||
const secret = "late-bypass-secret"
|
||||
items = append(items, "http://operator:"+secret+"@proxy.invalid")
|
||||
model = updateRunes(model, strings.Join(items, ","))
|
||||
for range 6 {
|
||||
model = updateKey(model, "pgdown")
|
||||
}
|
||||
|
||||
for _, size := range []struct{ width, height int }{{80, 24}, {60, 16}, {120, 36}, {80, 24}} {
|
||||
model = resize(model, size.width, size.height)
|
||||
view := model.View()
|
||||
assertUsableFrame(t, view, size.width, size.height, "> Bypass [focused]", "REDACTED@proxy.invalid")
|
||||
if strings.Contains(view, secret) {
|
||||
t.Fatalf("scrolled Bypass validation exposed credentials at %dx%d:\n%s", size.width, size.height, view)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompleteModelProfileEditorObscuresSchemeLessCredentialsDuringEntryValidationAndScroll(t *testing.T) {
|
||||
module := &profileManagementModule{}
|
||||
model := openNewProfileEditor(t, module)
|
||||
model = updateRunes(model, "office")
|
||||
model = updateKey(model, "tab")
|
||||
const secret = "scheme-less-secret"
|
||||
const raw = "operator:" + secret + "@this-is-a-very-long-proxy-hostname-for-scroll.example:notaport"
|
||||
model = updateRunes(model, raw)
|
||||
|
||||
for _, step := range []func(Model) Model{
|
||||
func(value Model) Model { return value },
|
||||
func(value Model) Model { return editorKey(value, tea.KeyHome) },
|
||||
func(value Model) Model { return editorKey(value, tea.KeyEnd) },
|
||||
func(value Model) Model { return updateKey(value, "ctrl+s") },
|
||||
func(value Model) Model { return resize(value, 60, 16) },
|
||||
func(value Model) Model { return resize(value, 80, 24) },
|
||||
} {
|
||||
model = step(model)
|
||||
if view := model.View(); strings.Contains(view, secret) {
|
||||
t.Fatalf("scheme-less credential rendered during entry, validation, or scroll:\n%s", view)
|
||||
}
|
||||
}
|
||||
if len(module.intents) != 0 {
|
||||
t.Fatalf("invalid credential-bearing URL dispatched %#v", module.intents)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompleteModelProfileEditorShowsNameConflictsInlineAndBlocksContradictorySave(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user