(t *testing.T)
| 127 | } |
| 128 | |
| 129 | func TestBasicAuthTokenResolver(t *testing.T) { |
| 130 | th := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { |
| 131 | if r.Method != http.MethodGet { |
| 132 | rw.WriteHeader(http.StatusMethodNotAllowed) |
| 133 | return |
| 134 | } |
| 135 | rw.Header().Set("Content-Type", "application/json") |
| 136 | rw.WriteHeader(http.StatusOK) |
| 137 | username, password, ok := r.BasicAuth() |
| 138 | if !ok || username != "user1" || password != "password1" { |
| 139 | rw.Write([]byte(`{"access_token":"insufficientscope"}`)) |
| 140 | } else { |
| 141 | rw.Write([]byte(`{"access_token":"perfectlyvalidopaquetoken"}`)) |
| 142 | } |
| 143 | }) |
| 144 | creds := func(string) (string, string, error) { |
| 145 | return "user1", "password1", nil |
| 146 | } |
| 147 | |
| 148 | runBasicTest(t, "testname", withTokenServer(th, creds)) |
| 149 | } |
| 150 | |
| 151 | func TestRefreshTokenResolver(t *testing.T) { |
| 152 | th := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…