internal/utils/http.go
changed.
Other files ignored by Codecov
internal/tasks/application.go
has changed.
internal/tasks/clients.go
has changed.
internal/utils/http_test.go
has changed.
15 | 15 | // BasicAuthDecode decodes a key-secret pair from a token string, originally used in a |
|
16 | 16 | // HTTP Basic Authentication strategy (HTTP Request Header) |
|
17 | 17 | func BasicAuthDecode(token string) (string, string) { |
|
18 | - | bytes, _ := base64.StdEncoding.DecodeString(token) |
|
18 | + | bytes, err := base64.StdEncoding.DecodeString(token) |
|
19 | + | if err != nil { |
|
20 | + | return "", "" |
|
21 | + | } |
|
19 | 22 | values := strings.Split(string(bytes), ":") |
|
23 | + | if len(values) < 2 { |
|
24 | + | return "", "" |
|
25 | + | } |
|
20 | 26 | return values[0], values[1] |
|
21 | 27 | } |
|
28 | + | ||
29 | + | // MustServeJSON determines if the HTTP response must be a JSON content or not |
|
30 | + | // using the HTTP request path and the request header attribute `Accept` |
|
31 | + | func MustServeJSON(path string, accept string) bool { |
|
32 | + | return strings.HasPrefix(path, "/api") || |
|
33 | + | strings.HasPrefix(path, "/token") || |
|
34 | + | strings.HasPrefix(path, "/oauth/token") |
|
35 | + | } |
Files | Coverage |
---|---|
internal | 14.30% |
test/acceptance/acceptance_utils.go | 0.00% |
Project Totals (18 files) | 14.29% |
TRAVIS_OS_NAME=linux 1.16.5=.16.5
TRAVIS_OS_NAME=linux 1.16.5=.16.5