()
| 404 | } |
| 405 | |
| 406 | func (patTest *PassAccessTokenTest) getCallbackEndpoint() (httpCode int, cookie string) { |
| 407 | rw := httptest.NewRecorder() |
| 408 | |
| 409 | csrf, err := cookies.NewCSRF(patTest.proxy.CookieOptions, "") |
| 410 | if err != nil { |
| 411 | panic(err) |
| 412 | } |
| 413 | |
| 414 | req, err := http.NewRequest( |
| 415 | http.MethodGet, |
| 416 | fmt.Sprintf( |
| 417 | "/oauth2/callback?code=callback_code&state=%s", |
| 418 | encodeState(csrf.HashOAuthState(), "%2F", false), |
| 419 | ), |
| 420 | strings.NewReader(""), |
| 421 | ) |
| 422 | if err != nil { |
| 423 | return 0, "" |
| 424 | } |
| 425 | |
| 426 | // rw is a dummy here, we just want the csrfCookie to add to our req |
| 427 | csrfCookie, err := csrf.SetCookie(httptest.NewRecorder(), req) |
| 428 | if err != nil { |
| 429 | panic(err) |
| 430 | } |
| 431 | req.AddCookie(csrfCookie) |
| 432 | |
| 433 | patTest.proxy.ServeHTTP(rw, req) |
| 434 | |
| 435 | if len(rw.Header().Values("Set-Cookie")) >= 2 { |
| 436 | cookie = rw.Header().Values("Set-Cookie")[1] |
| 437 | } |
| 438 | |
| 439 | return rw.Code, cookie |
| 440 | } |
| 441 | |
| 442 | // getEndpointWithCookie makes a requests againt the oauthproxy with passed requestPath |
| 443 | // and cookie and returns body and status code. |
no test coverage detected