MCPcopy
hub / github.com/golang-jwt/jwt / TestExtractor

Function TestExtractor

request/extractor_test.go:66–83  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func TestExtractor(t *testing.T) {
67 // Bearer token request
68 for _, data := range extractorTestData {
69 // Make request from test struct
70 r := makeExampleRequest("GET", "/", data.headers, data.query)
71
72 // Test extractor
73 token, err := data.extractor.ExtractToken(r)
74 if token != data.token {
75 t.Errorf("[%v] Expected token '%v'. Got '%v'", data.name, data.token, token)
76 continue
77 }
78 if err != data.err {
79 t.Errorf("[%v] Expected error '%v'. Got '%v'", data.name, data.err, err)
80 continue
81 }
82 }
83}
84
85func makeExampleRequest(method, path string, headers map[string]string, urlArgs url.Values) *http.Request {
86 r, _ := http.NewRequest(method, fmt.Sprintf("%v?%v", path, urlArgs.Encode()), nil)

Callers

nothing calls this directly

Calls 2

makeExampleRequestFunction · 0.85
ExtractTokenMethod · 0.65

Tested by

no test coverage detected