MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / TestHandleRedirects_AttachOrgToken

Function TestHandleRedirects_AttachOrgToken

token/token_test.go:10–30  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestHandleRedirects_AttachOrgToken(t *testing.T) {
11 req, _ := http.NewRequest("GET", "http://example.com/cdn-cgi/access/login", nil)
12 via := []*http.Request{}
13 orgToken := "orgTokenValue"
14
15 _ = handleRedirects(req, via, orgToken)
16
17 // Check if the orgToken cookie is attached
18 cookies := req.Cookies()
19 found := false
20 for _, cookie := range cookies {
21 if cookie.Name == tokenCookie && cookie.Value == orgToken {
22 found = true
23 break
24 }
25 }
26
27 if !found {
28 t.Errorf("OrgToken cookie not attached to the request.")
29 }
30}
31
32func TestHandleRedirects_AttachAppSessionCookie(t *testing.T) {
33 req, _ := http.NewRequest("GET", "http://example.com/cdn-cgi/access/authorized", nil)

Callers

nothing calls this directly

Calls 2

handleRedirectsFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected