mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 01:38:10 +00:00
Support setting headers on requests to Prometheus
This commit is contained in:
parent
93450fc29f
commit
d84340cc85
3 changed files with 64 additions and 5 deletions
|
|
@ -20,6 +20,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
|
@ -146,3 +147,41 @@ func TestMakePrometheusCAClient(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseHeaderArgs(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
args []string
|
||||
headers http.Header
|
||||
}{
|
||||
{
|
||||
headers: http.Header{},
|
||||
},
|
||||
{
|
||||
args: []string{"foo=bar"},
|
||||
headers: http.Header{
|
||||
"Foo": []string{"bar"},
|
||||
},
|
||||
},
|
||||
{
|
||||
args: []string{"foo"},
|
||||
headers: http.Header{
|
||||
"Foo": []string{""},
|
||||
},
|
||||
},
|
||||
{
|
||||
args: []string{"foo=bar", "foo=baz", "bux=baz=23"},
|
||||
headers: http.Header{
|
||||
"Foo": []string{"bar", "baz"},
|
||||
"Bux": []string{"baz=23"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
got := parseHeaderArgs(test.args)
|
||||
if !reflect.DeepEqual(got, test.headers) {
|
||||
t.Errorf("Expected %#v but got %#v", test.headers, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue