mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
fix(tests): add missing test coverage for basic auth
This commit is contained in:
committed by
Łukasz Mierzwa
parent
325902857c
commit
ed965a74d2
@@ -1032,6 +1032,35 @@ func TestAuthentication(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidBasicAuthHeader(t *testing.T) {
|
||||
config.Config.Authentication.Header.Name = ""
|
||||
config.Config.Authentication.Header.ValueRegex = ""
|
||||
config.Config.Authentication.BasicAuth.Users = []config.AuthenticationUser{
|
||||
{Username: "john", Password: "foobar"},
|
||||
}
|
||||
r := testRouter()
|
||||
setupRouter(r)
|
||||
mockCache()
|
||||
for _, path := range []string{
|
||||
"/",
|
||||
"/alerts.json",
|
||||
"/autocomplete.json?term=foo",
|
||||
"/labelNames.json",
|
||||
"/labelValues.json?name=foo",
|
||||
"/silences.json",
|
||||
"/custom.css",
|
||||
"/custom.js",
|
||||
} {
|
||||
req := httptest.NewRequest("GET", path, nil)
|
||||
req.Header.Set("Authorization", "")
|
||||
resp := httptest.NewRecorder()
|
||||
r.ServeHTTP(resp, req)
|
||||
if resp.Code != 401 {
|
||||
t.Errorf("Expected 401 from %s, got %d", path, resp.Code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpstreamStatus(t *testing.T) {
|
||||
zerolog.SetGlobalLevel(zerolog.FatalLevel)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user