MCPcopy
hub / github.com/cloudfoundry/cli / refreshTokenAPIEndPoint

Function refreshTokenAPIEndPoint

cf/net/gateway_test.go:649–672  ·  view source on GitHub ↗
(unauthorizedBody string, secondReqResp testnet.TestResponse)

Source from the content-addressed store, hash-verified

647}
648
649func refreshTokenAPIEndPoint(unauthorizedBody string, secondReqResp testnet.TestResponse) http.HandlerFunc {
650 return func(writer http.ResponseWriter, request *http.Request) {
651 var jsonResponse string
652
653 bodyBytes, err := ioutil.ReadAll(request.Body)
654 if err != nil || string(bodyBytes) != "expected body" {
655 writer.WriteHeader(http.StatusInternalServerError)
656 return
657 }
658
659 switch request.Header.Get("Authorization") {
660 case initialAccessToken:
661 writer.WriteHeader(http.StatusUnauthorized)
662 jsonResponse = unauthorizedBody
663 case refreshedAccessToken:
664 writer.WriteHeader(secondReqResp.Status)
665 jsonResponse = secondReqResp.Body
666 default:
667 writer.WriteHeader(http.StatusInternalServerError)
668 }
669
670 fmt.Fprintln(writer, jsonResponse)
671 }
672}
673
674func createAuthenticationRepository(apiServer *httptest.Server, authServer *httptest.Server) (coreconfig.ReadWriter, authentication.Repository) {
675 config := testconfig.NewRepository()

Callers 1

gateway_test.goFile · 0.85

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected