(t *testing.T)
| 64 | } |
| 65 | |
| 66 | func 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 | |
| 85 | func 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) |
nothing calls this directly
no test coverage detected