(t *testing.T)
| 4080 | } |
| 4081 | |
| 4082 | func TestBasicAuthTransport(t *testing.T) { |
| 4083 | t.Parallel() |
| 4084 | client, mux, _ := setup(t) |
| 4085 | |
| 4086 | username, password, otp := "u", "p", "123456" |
| 4087 | |
| 4088 | mux.HandleFunc("/", func(_ http.ResponseWriter, r *http.Request) { |
| 4089 | u, p, ok := r.BasicAuth() |
| 4090 | if !ok { |
| 4091 | t.Error("request does not contain basic auth credentials") |
| 4092 | } |
| 4093 | if u != username { |
| 4094 | t.Errorf("request contained basic auth username %q, want %q", u, username) |
| 4095 | } |
| 4096 | if p != password { |
| 4097 | t.Errorf("request contained basic auth password %q, want %q", p, password) |
| 4098 | } |
| 4099 | if got, want := r.Header.Get(headerOTP), otp; got != want { |
| 4100 | t.Errorf("request contained OTP %q, want %q", got, want) |
| 4101 | } |
| 4102 | }) |
| 4103 | |
| 4104 | tp := &BasicAuthTransport{ |
| 4105 | Username: username, |
| 4106 | Password: password, |
| 4107 | OTP: otp, |
| 4108 | } |
| 4109 | basicAuthClient := mustNewClient(t, WithHTTPClient(tp.Client())) |
| 4110 | basicAuthClient.baseURL = client.baseURL |
| 4111 | req, _ := basicAuthClient.NewRequest(t.Context(), "GET", ".", nil) |
| 4112 | _, err := basicAuthClient.Do(req, nil) |
| 4113 | assertNilError(t, err) |
| 4114 | } |
| 4115 | |
| 4116 | func TestBasicAuthTransport_transport(t *testing.T) { |
| 4117 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…