File tree 1 file changed +39
-3
lines changed
1 file changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,6 @@ import (
10
10
"testing"
11
11
)
12
12
13
- // TODO(mattn):
14
- // test ProxyAuth
15
-
16
13
var cacheKeysTests = []struct {
17
14
proxy string
18
15
scheme string
@@ -48,3 +45,42 @@ func ResetProxyEnv() {
48
45
}
49
46
ResetCachedEnvironment ()
50
47
}
48
+
49
+ var proxyAuthTests = []struct {
50
+ proxy string
51
+ key string
52
+ }{
53
+ {
54
+ "" ,
55
+ "" ,
56
+ },
57
+ {
58
+ "http://bar.com" ,
59
+ "" ,
60
+ },
61
+ {
62
+ "http://foo@bar.com" ,
63
+ "Basic Zm9vOg==" ,
64
+ },
65
+ {
66
+ "http://foo:bar@bar.com" ,
67
+ "Basic Zm9vOmJhcg==" ,
68
+ },
69
+ }
70
+
71
+ func TestProxyAuthKeys (t * testing.T ) {
72
+ for _ , tt := range proxyAuthTests {
73
+ var proxy * url.URL
74
+ if tt .proxy != "" {
75
+ u , err := url .Parse (tt .proxy )
76
+ if err != nil {
77
+ t .Fatal (err )
78
+ }
79
+ proxy = u
80
+ }
81
+ cm := connectMethod {proxyURL : proxy }
82
+ if got := cm .proxyAuth (); got != tt .key {
83
+ t .Fatalf ("{%q} proxyAuth key = %q; want %q" , tt .proxy , got , tt .key )
84
+ }
85
+ }
86
+ }
You can’t perform that action at this time.
0 commit comments