8 type basicAuthTestCase struct {
15 func TestBasicAuth(t *testing.T) {
16 tests := []basicAuthTestCase{
17 {"Basic Zm9vOmJhcg==", "foo", "bar", true},
18 {"Bogus Zm9vOmJhcg==", "", "", false},
19 {"Zm9vOmJhcg==", "", "", false},
20 {"Basic", "", "", false},
23 for _, test := range tests {
24 if u, p, ok := BasicAuth(&http.Request{Header: map[string][]string{
25 "Authorization": {test.hdr},
26 }}); u != test.user || p != test.pass || ok != test.ok {
27 t.Error("got:", u, p, ok, "expected:", test.user, test.pass, test.ok, "from:", test.hdr)