@@ -428,7 +428,9 @@ func (patTest *PassAccessTokenTest) getCallbackEndpoint() (httpCode int,
428428 return rw.Code, rw.HeaderMap["Set-Cookie"][1]
429429}
430430
431−func (patTest *PassAccessTokenTest) getRootEndpoint(cookie string) (httpCode int, accessToken string) {
431+// getEndpointWithCookie makes a requests againt the oauthproxy with passed requestPath
432+// and cookie and returns body and status code.
433+func (patTest *PassAccessTokenTest) getEndpointWithCookie(cookie string, endpoint string) (httpCode int, accessToken string) {
432434 cookieName := patTest.proxy.CookieName
433435 var value string
434436 keyPrefix := cookieName + "="
@@ -445,7 +447,7 @@ func (patTest *PassAccessTokenTest) getRootEndpoint(cookie string) (httpCode int
445447 return 0, ""
446448 }
447449
448− req, err := http.NewRequest("GET", "/", strings.NewReader(""))
450+ req, err := http.NewRequest("GET", endpoint, strings.NewReader(""))
449451 if err != nil {
450452 return 0, ""
451453 }
@@ -462,39 +464,6 @@ func (patTest *PassAccessTokenTest) getRootEndpoint(cookie string) (httpCode int
462464 return rw.Code, rw.Body.String()
463465}
464466
465−func (patTest *PassAccessTokenTest) getProxyEndpoint(cookie string) (httpCode int, accessToken string) {
466− cookieName := patTest.proxy.CookieName
467− var value string
468− keyPrefix := cookieName + "="
469−
470− for _, field := range strings.Split(cookie, "; ") {
471− value = strings.TrimPrefix(field, keyPrefix)
472− if value != field {
473− break
474− } else {
475− value = ""
476− }
477− }
478− if value == "" {
479− return 0, ""
480− }
481−
482− req, err := http.NewRequest("GET", "/static-proxy", strings.NewReader(""))
483− if err != nil {
484− return 0, ""
485− }
486− req.AddCookie(&http.Cookie{
487− Name: cookieName,
488− Value: value,
489− Path: "/",
490− Expires: time.Now().Add(time.Duration(24)),
491− HttpOnly: true,
492− })
493− rw := httptest.NewRecorder()
494− patTest.proxy.ServeHTTP(rw, req)
495− return rw.Code, rw.Body.String()
496−}
497−
498467func TestForwardAccessTokenUpstream(t *testing.T) {
499468 patTest := NewPassAccessTokenTest(PassAccessTokenTestOptions{
500469 PassAccessToken: true,
@@ -511,7 +480,7 @@ func TestForwardAccessTokenUpstream(t *testing.T) {
511480 // Now we make a regular request; the access_token from the cookie is
512481 // forwarded as the "X-Forwarded-Access-Token" header. The token is
513482 // read by the test provider server and written in the response body.
514− code, payload := patTest.getRootEndpoint(cookie)
483+ code, payload := patTest.getEndpointWithCookie(cookie, "/")
515484 if code != 200 {
516485 t.Fatalf("expected 200; got %d", code)
517486 }
@@ -533,7 +502,9 @@ func TestStaticProxyUpstream(t *testing.T) {
533502 }
534503 assert.NotEqual(t, nil, cookie)
535504
536− code, payload := patTest.getProxyEndpoint(cookie)
505+ // Now we make a regular request againts the upstream proxy; And validate
506+ // the returned status code through the static proxy.
507+ code, payload := patTest.getEndpointWithCookie(cookie, "/static-proxy")
537508 if code != 200 {
538509 t.Fatalf("expected 200; got %d", code)
539510 }
@@ -555,7 +526,7 @@ func TestDoNotForwardAccessTokenUpstream(t *testing.T) {
555526
556527 // Now we make a regular request, but the access token header should
557528 // not be present.
558− code, payload := patTest.getRootEndpoint(cookie)
529+ code, payload := patTest.getEndpointWithCookie(cookie, "/")
559530 if code != 200 {
560531 t.Fatalf("expected 200; got %d", code)
561532 }