(t *testing.T)
| 19 | } |
| 20 | |
| 21 | func 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 | |
| 50 | func TestPasswordAuthBadPass(t *testing.T) { |
| 51 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…