(t *testing.T)
| 502 | } |
| 503 | |
| 504 | func TestStaticProxyUpstream(t *testing.T) { |
| 505 | patTest, err := NewPassAccessTokenTest(PassAccessTokenTestOptions{ |
| 506 | PassAccessToken: true, |
| 507 | ValidToken: true, |
| 508 | ProxyUpstream: options.Upstream{ |
| 509 | ID: "static-proxy", |
| 510 | Path: "/static-proxy", |
| 511 | Static: ptr.To(true), |
| 512 | }, |
| 513 | }) |
| 514 | if err != nil { |
| 515 | t.Fatal(err) |
| 516 | } |
| 517 | t.Cleanup(patTest.Close) |
| 518 | |
| 519 | // A successful validation will redirect and set the auth cookie. |
| 520 | code, cookie := patTest.getCallbackEndpoint() |
| 521 | if code != 302 { |
| 522 | t.Fatalf("expected 302; got %d", code) |
| 523 | } |
| 524 | assert.NotEqual(t, nil, cookie) |
| 525 | |
| 526 | // Now we make a regular request against the upstream proxy; And validate |
| 527 | // the returned status code through the static proxy. |
| 528 | code, payload := patTest.getEndpointWithCookie(cookie, "/static-proxy") |
| 529 | if code != 200 { |
| 530 | t.Fatalf("expected 200; got %d", code) |
| 531 | } |
| 532 | assert.Equal(t, "Authenticated", payload) |
| 533 | } |
| 534 | |
| 535 | func TestDoNotForwardAccessTokenUpstream(t *testing.T) { |
| 536 | patTest, err := NewPassAccessTokenTest(PassAccessTokenTestOptions{ |
nothing calls this directly
no test coverage detected