MCPcopy
hub / github.com/gliderlabs/ssh / TestPasswordAuth

Function TestPasswordAuth

options_test.go:21–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19}
20
21func TestPasswordAuth(t *testing.T) {
22 t.Parallel()
23 testUser := "testuser"
24 testPass := "testpass"
25 session, _, cleanup := newTestSessionWithOptions(t, &Server{
26 Handler: func(s Session) {
27 // noop
28 },
29 }, &gossh.ClientConfig{
30 User: testUser,
31 Auth: []gossh.AuthMethod{
32 gossh.Password(testPass),
33 },
34 HostKeyCallback: gossh.InsecureIgnoreHostKey(),
35 }, PasswordAuth(func(ctx Context, password string) bool {
36 if ctx.User() != testUser {
37 t.Fatalf("user = %#v; want %#v", ctx.User(), testUser)
38 }
39 if password != testPass {
40 t.Fatalf("user = %#v; want %#v", password, testPass)
41 }
42 return true
43 }))
44 defer cleanup()
45 if err := session.Run(""); err != nil {
46 t.Fatal(err)
47 }
48}
49
50func TestPasswordAuthBadPass(t *testing.T) {
51 t.Parallel()

Callers

nothing calls this directly

Calls 3

PasswordAuthFunction · 0.85
UserMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…