1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
12 type basicAuthTestCase struct {
19 func TestBasicAuth(t *testing.T) {
20 tests := []basicAuthTestCase{
21 {"Basic Zm9vOmJhcg==", "foo", "bar", true},
22 {"Bogus Zm9vOmJhcg==", "", "", false},
23 {"Zm9vOmJhcg==", "", "", false},
24 {"Basic", "", "", false},
27 for _, test := range tests {
28 if u, p, ok := BasicAuth(&http.Request{Header: map[string][]string{
29 "Authorization": {test.hdr},
30 }}); u != test.user || p != test.pass || ok != test.ok {
31 t.Error("got:", u, p, ok, "expected:", test.user, test.pass, test.ok, "from:", test.hdr)