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

Function TestDoNotForwardAccessTokenUpstream

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

Source from the content-addressed store, hash-verified

533}
534
535func TestDoNotForwardAccessTokenUpstream(t *testing.T) {
536 patTest, err := NewPassAccessTokenTest(PassAccessTokenTestOptions{
537 PassAccessToken: false,
538 ValidToken: true,
539 })
540 if err != nil {
541 t.Fatal(err)
542 }
543 t.Cleanup(patTest.Close)
544
545 // A successful validation will redirect and set the auth cookie.
546 code, cookie := patTest.getCallbackEndpoint()
547 if code != 302 {
548 t.Fatalf("expected 302; got %d", code)
549 }
550 assert.NotEqual(t, nil, cookie)
551
552 // Now we make a regular request, but the access token header should
553 // not be present.
554 code, payload := patTest.getEndpointWithCookie(cookie, "/")
555 if code != 200 {
556 t.Fatalf("expected 200; got %d", code)
557 }
558 assert.Equal(t, "No access token found.", payload)
559}
560
561func TestSessionValidationFailure(t *testing.T) {
562 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