MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / TestAuthKeyboardInteractive

Function TestAuthKeyboardInteractive

internal/sshserver/Server_test.go:101–136  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

99}
100
101func TestAuthKeyboardInteractive(t *testing.T) {
102 //t.Parallel()()
103 user1 := sshserver.NewTestUser("test")
104 user1.AddKeyboardInteractiveChallengeResponse("foo", "bar")
105
106 user2 := sshserver.NewTestUser("test")
107 user2.AddKeyboardInteractiveChallengeResponse("foo", "baz")
108
109 logger := log.NewTestLogger(t)
110 srv := sshserver.NewTestServer(
111 t,
112 sshserver.NewTestAuthenticationHandler(
113 sshserver.NewTestHandler(),
114 user2,
115 ),
116 logger,
117 nil,
118 )
119 srv.Start()
120
121 client1 := sshserver.NewTestClient(srv.GetListen(), srv.GetHostKey(), user1, logger)
122 conn, err := client1.Connect()
123 if err == nil {
124 _ = conn.Close()
125 t.Fatal("invalid keyboard-interactive authentication did not result in an error")
126 }
127
128 client2 := sshserver.NewTestClient(srv.GetListen(), srv.GetHostKey(), user2, logger)
129 conn, err = client2.Connect()
130 if err != nil {
131 t.Fatalf("valid keyboard-interactive authentication resulted in an error (%v)", err)
132 }
133 _ = conn.Close()
134
135 defer srv.Stop(10 * time.Second)
136}
137
138type gssApiClient struct {
139 username string

Callers

nothing calls this directly

Calls 15

StartMethod · 0.95
GetListenMethod · 0.95
GetHostKeyMethod · 0.95
ConnectMethod · 0.95
StopMethod · 0.95
NewTestUserFunction · 0.92
NewTestLoggerFunction · 0.92
NewTestServerFunction · 0.92
NewTestHandlerFunction · 0.92
NewTestClientFunction · 0.92

Tested by

no test coverage detected