(t *testing.T)
| 475 | } |
| 476 | |
| 477 | func TestForwardAccessTokenUpstream(t *testing.T) { |
| 478 | patTest, err := NewPassAccessTokenTest(PassAccessTokenTestOptions{ |
| 479 | PassAccessToken: true, |
| 480 | ValidToken: true, |
| 481 | }) |
| 482 | if err != nil { |
| 483 | t.Fatal(err) |
| 484 | } |
| 485 | t.Cleanup(patTest.Close) |
| 486 | |
| 487 | // A successful validation will redirect and set the auth cookie. |
| 488 | code, cookie := patTest.getCallbackEndpoint() |
| 489 | if code != 302 { |
| 490 | t.Fatalf("expected 302; got %d", code) |
| 491 | } |
| 492 | assert.NotNil(t, cookie) |
| 493 | |
| 494 | // Now we make a regular request; the access_token from the cookie is |
| 495 | // forwarded as the "X-Forwarded-Access-Token" header. The token is |
| 496 | // read by the test provider server and written in the response body. |
| 497 | code, payload := patTest.getEndpointWithCookie(cookie, "/") |
| 498 | if code != 200 { |
| 499 | t.Fatalf("expected 200; got %d", code) |
| 500 | } |
| 501 | assert.Equal(t, "my_auth_token", payload) |
| 502 | } |
| 503 | |
| 504 | func TestStaticProxyUpstream(t *testing.T) { |
| 505 | patTest, err := NewPassAccessTokenTest(PassAccessTokenTestOptions{ |
nothing calls this directly
no test coverage detected