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

Function TestStaticProxyUpstream

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

Source from the content-addressed store, hash-verified

502}
503
504func 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
535func TestDoNotForwardAccessTokenUpstream(t *testing.T) {
536 patTest, err := NewPassAccessTokenTest(PassAccessTokenTestOptions{

Callers

nothing calls this directly

Calls 4

getCallbackEndpointMethod · 0.95
getEndpointWithCookieMethod · 0.95
ToFunction · 0.92
NewPassAccessTokenTestFunction · 0.85

Tested by

no test coverage detected