(t *testing.T)
| 22 | } |
| 23 | |
| 24 | func TestAuthenticate(t *testing.T) { |
| 25 | auth := &UsernamePassword{ |
| 26 | Username: "imroc", |
| 27 | Password: "123456", |
| 28 | } |
| 29 | buf := bytes.NewBuffer([]byte{byte(0x01), byte(0x00)}) |
| 30 | err := auth.Authenticate(context.Background(), buf, AuthMethodUsernamePassword) |
| 31 | tests.AssertNoError(t, err) |
| 32 | auth.Username = "this is a very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long name" |
| 33 | err = auth.Authenticate(context.Background(), buf, AuthMethodUsernamePassword) |
| 34 | tests.AssertErrorContains(t, err, "invalid") |
| 35 | |
| 36 | auth.Username = "imroc" |
| 37 | buf = bytes.NewBuffer([]byte{byte(0x03), byte(0x00)}) |
| 38 | err = auth.Authenticate(context.Background(), buf, AuthMethodUsernamePassword) |
| 39 | tests.AssertErrorContains(t, err, "invalid username/password version") |
| 40 | |
| 41 | buf = bytes.NewBuffer([]byte{byte(0x01), byte(0x02)}) |
| 42 | err = auth.Authenticate(context.Background(), buf, AuthMethodUsernamePassword) |
| 43 | tests.AssertErrorContains(t, err, "authentication failed") |
| 44 | |
| 45 | err = auth.Authenticate(context.Background(), buf, AuthMethodNoAcceptableMethods) |
| 46 | tests.AssertErrorContains(t, err, "unsupported authentication method") |
| 47 | |
| 48 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…