mirror of https://github.com/golang/go.git
net/http: add test for proxyAuth
This commit is contained in:
parent
326a792517
commit
19d87d12ab
|
|
@ -10,9 +10,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO(mattn):
|
|
||||||
// test ProxyAuth
|
|
||||||
|
|
||||||
var cacheKeysTests = []struct {
|
var cacheKeysTests = []struct {
|
||||||
proxy string
|
proxy string
|
||||||
scheme string
|
scheme string
|
||||||
|
|
@ -48,3 +45,42 @@ func ResetProxyEnv() {
|
||||||
}
|
}
|
||||||
ResetCachedEnvironment()
|
ResetCachedEnvironment()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var proxyAuthTests = []struct {
|
||||||
|
proxy string
|
||||||
|
key string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"http://bar.com",
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"http://foo@bar.com",
|
||||||
|
"Basic Zm9vOg==",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"http://foo:bar@bar.com",
|
||||||
|
"Basic Zm9vOmJhcg==",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestProxyAuthKeys(t *testing.T) {
|
||||||
|
for _, tt := range proxyAuthTests {
|
||||||
|
var proxy *url.URL
|
||||||
|
if tt.proxy != "" {
|
||||||
|
u, err := url.Parse(tt.proxy)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
proxy = u
|
||||||
|
}
|
||||||
|
cm := connectMethod{proxyURL: proxy}
|
||||||
|
if got := cm.proxyAuth(); got != tt.key {
|
||||||
|
t.Fatalf("{%q} proxyAuth key = %q; want %q", tt.proxy, got, tt.key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue