MCPcopy
hub / github.com/oauth2-proxy/oauth2-proxy / TestForwardAccessTokenUpstream

Function TestForwardAccessTokenUpstream

oauthproxy_test.go:477–502  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

475}
476
477func 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
504func TestStaticProxyUpstream(t *testing.T) {
505 patTest, err := NewPassAccessTokenTest(PassAccessTokenTestOptions{

Callers

nothing calls this directly

Calls 3

getCallbackEndpointMethod · 0.95
getEndpointWithCookieMethod · 0.95
NewPassAccessTokenTestFunction · 0.85

Tested by

no test coverage detected