open-vault/helper/metricsutil/metricsutil_test.go
Becca Petrin c2894b8d05
Add Kerberos auth agent (#7999)
* add kerberos auth agent

* strip old comment

* changes from feedback

* strip appengine indirect dependency
2020-01-09 14:56:34 -08:00

47 lines
922 B
Go

package metricsutil
import (
"testing"
"github.com/hashicorp/vault/sdk/logical"
)
func TestFormatFromRequest(t *testing.T) {
testCases := []struct {
original *logical.Request
expected string
}{
{
original: &logical.Request{Headers: map[string][]string{
"Accept": {
"application/vnd.google.protobuf",
"schema=\"prometheus/telemetry\"",
},
}},
expected: "prometheus",
},
{
original: &logical.Request{Headers: map[string][]string{
"Accept": {
"schema=\"prometheus\"",
},
}},
expected: "",
},
{
original: &logical.Request{Headers: map[string][]string{
"Accept": {
"application/openmetrics-text",
},
}},
expected: "prometheus",
},
}
for _, tCase := range testCases {
if metricsType := FormatFromRequest(tCase.original); metricsType != tCase.expected {
t.Fatalf("expected %s but got %s", tCase.expected, metricsType)
}
}
}