File tree Expand file tree Collapse file tree 4 files changed +95
-3
lines changed Expand file tree Collapse file tree 4 files changed +95
-3
lines changed Original file line number Diff line number Diff line change @@ -165,12 +165,12 @@ workflows:
165
165
context : go-getter
166
166
matrix :
167
167
parameters :
168
- go-version : ["1.15.13"]
168
+ go-version : ["1.15.13", "1.14.15" ]
169
169
name : linux-test-go-<< matrix.go-version >>
170
170
- windows-tests :
171
171
context : go-getter
172
172
matrix :
173
173
parameters :
174
- go-version : ["1.15.13"]
174
+ go-version : ["1.15.13", "1.14.15" ]
175
175
gotestsum-version : ["0.4.1"]
176
176
name : win-test-go-<< matrix.go-version >>
Original file line number Diff line number Diff line change @@ -298,7 +298,7 @@ func (c *Client) Get() error {
298
298
// if we're specifying a subdir.
299
299
err := g .Get (dst , u )
300
300
if err != nil {
301
- err = fmt .Errorf ("error downloading '%s': %s" , u . Redacted ( ), err )
301
+ err = fmt .Errorf ("error downloading '%s': %s" , RedactURL ( u ), err )
302
302
return err
303
303
}
304
304
}
Original file line number Diff line number Diff line change
1
+ package getter
2
+
3
+ import "net/url"
4
+
5
+ // RedactURL is a port of url.Redacted from the standard library,
6
+ // which is like url.String but replaces any password with "xxxxx".
7
+ // Only the password in u.URL is redacted. This allows the library
8
+ // to maintain compatibility with go1.14.
9
+ func RedactURL (u * url.URL ) string {
10
+ if u == nil {
11
+ return ""
12
+ }
13
+
14
+ ru := * u
15
+ if _ , has := ru .User .Password (); has {
16
+ ru .User = url .UserPassword (ru .User .Username (), "xxxxx" )
17
+ }
18
+ return ru .String ()
19
+ }
Original file line number Diff line number Diff line change
1
+ package getter
2
+
3
+ import (
4
+ "net/url"
5
+ "testing"
6
+ )
7
+
8
+ func TestRedactURL (t * testing.T ) {
9
+ cases := []struct {
10
+ name string
11
+ url * url.URL
12
+ want string
13
+ }{
14
+ {
15
+ name : "non-blank Password" ,
16
+ url : & url.URL {
17
+ Scheme : "http" ,
18
+ Host : "host.tld" ,
19
+ Path : "this:that" ,
20
+ User : url .UserPassword ("user" , "password" ),
21
+ },
22
+ want :
"http://user:[email protected] /this:that" ,
23
+ },
24
+ {
25
+ name : "blank Password" ,
26
+ url : & url.URL {
27
+ Scheme : "http" ,
28
+ Host : "host.tld" ,
29
+ Path : "this:that" ,
30
+ User : url .User ("user" ),
31
+ },
32
+ want :
"http://[email protected] /this:that" ,
33
+ },
34
+ {
35
+ name : "nil User" ,
36
+ url : & url.URL {
37
+ Scheme : "http" ,
38
+ Host : "host.tld" ,
39
+ Path : "this:that" ,
40
+ User : url .UserPassword ("" , "password" ),
41
+ },
42
+ want :
"http://:[email protected] /this:that" ,
43
+ },
44
+ {
45
+ name : "blank Username, blank Password" ,
46
+ url : & url.URL {
47
+ Scheme : "http" ,
48
+ Host : "host.tld" ,
49
+ Path : "this:that" ,
50
+ },
51
+ want : "http://host.tld/this:that" ,
52
+ },
53
+ {
54
+ name : "empty URL" ,
55
+ url : & url.URL {},
56
+ want : "" ,
57
+ },
58
+ {
59
+ name : "nil URL" ,
60
+ url : nil ,
61
+ want : "" ,
62
+ },
63
+ }
64
+
65
+ for _ , tt := range cases {
66
+ t := t
67
+ t .Run (tt .name , func (t * testing.T ) {
68
+ if g , w := RedactURL (tt .url ), tt .want ; g != w {
69
+ t .Fatalf ("got: %q\n want: %q" , g , w )
70
+ }
71
+ })
72
+ }
73
+ }
You can’t perform that action at this time.
0 commit comments