From 33eda54c8bc3ae86f08dba4fa8e5e8066ecdd52a Mon Sep 17 00:00:00 2001 From: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com> Date: Wed, 26 Mar 2025 15:33:39 -0700 Subject: [PATCH] trying to get keyboard-interactive challenge to trigger --- integration2/ssh_int_test.go | 4 +++- internal/testenv/scenarios/ssh.go | 15 +++++++++++++++ internal/testenv/types.go | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/integration2/ssh_int_test.go b/integration2/ssh_int_test.go index 80f92a05f..960c751df 100644 --- a/integration2/ssh_int_test.go +++ b/integration2/ssh_int_test.go @@ -23,11 +23,12 @@ func TestSSH(t *testing.T) { serverHostKey := newSSHKey(t) // ssh client setup + var ki scenarios.EmptyKeyboardInteractiveChallenge clientConfig := &ssh.ClientConfig{ User: "demo", Auth: []ssh.AuthMethod{ ssh.PublicKeys(clientKey), - //ssh.KeyboardInteractive() + ssh.KeyboardInteractive(ki.Do), }, HostKeyCallback: ssh.InsecureIgnoreHostKey(), } @@ -36,6 +37,7 @@ func TestSSH(t *testing.T) { env := testenv.New(t) env.Add(scenarios.SSH(scenarios.SSHConfig{})) + env.Add(&ki) up := upstreams.SSH( upstreams.WithHostKeys(serverHostKey), diff --git a/internal/testenv/scenarios/ssh.go b/internal/testenv/scenarios/ssh.go index 13ea7f800..d31901459 100644 --- a/internal/testenv/scenarios/ssh.go +++ b/internal/testenv/scenarios/ssh.go @@ -97,3 +97,18 @@ func writeSSHKeyPair(env testenv.Environment, key any) config.SSHKeyPair { PrivateKeyFile: privname, } } + +// EmptyKeyboardInteractiveChallenge responds to any keyboard-interactive +// challenges with zero prompts, and fails otherwise. +type EmptyKeyboardInteractiveChallenge struct { + testenv.DefaultAttach +} + +func (c *EmptyKeyboardInteractiveChallenge) Do( + name, instruction string, questions []string, echos []bool, +) (answers []string, err error) { + if len(questions) > 0 { + c.Env().Require().FailNow("unsupported keyboard-interactive challenge") + } + return nil, nil +} diff --git a/internal/testenv/types.go b/internal/testenv/types.go index 959fd9a33..dfbec80ab 100644 --- a/internal/testenv/types.go +++ b/internal/testenv/types.go @@ -69,6 +69,8 @@ func (d *DefaultAttach) RecordCaller() { d.caller = getCaller(4) } +func (d *DefaultAttach) Modify(*config.Config) {} + // Aggregate should be embedded in types implementing [Modifier] when the type // contains other modifiers. Used as an alternative to [DefaultAttach]. // Embedding this struct will properly keep track of when constituent modifiers