3
3
4
4
env GOPROXY=direct
5
5
env GOSUMDB=off
6
-
7
- # Use a custom authenticator to provide custom credentials
8
6
mkdir $WORK/bin
9
7
env PATH=$WORK/bin${:}$PATH
10
- cd auth
11
- go build -o $WORK/bin/my-auth$GOEXE .
12
- cd ..
13
8
14
9
# Without credentials, downloading a module from a path that requires HTTPS
15
10
# basic auth should fail.
@@ -21,16 +16,65 @@ stderr '^\tserver response: ACCESS DENIED, buddy$'
21
16
! go mod tidy
22
17
stderr '^\tserver response: ACCESS DENIED, buddy$'
23
18
24
- # With credentials from the my-auth binary, it should succeed.
25
- env GOAUTH='my-auth'$GOEXE' --arg1 "value with spaces"'
19
+ # Initial invocation of authenticator is successful.
20
+ go build -o $WORK/bin/basic$GOEXE scripts/basic.go
21
+ # With credentials from the binary, it should succeed.
22
+ env GOAUTH='basic'$GOEXE
23
+ cp go.mod.orig go.mod
24
+ go get vcs-test.golang.org/auth/or401
25
+ # go imports should resolve correctly as well.
26
+ go mod tidy
27
+ go list all
28
+ stdout vcs-test.golang.org/auth/or401
29
+
30
+ # Second invocation of authenticator is successful.
31
+ go build -o $WORK/bin/reinvocation$GOEXE scripts/reinvocation.go
32
+ # With credentials from the binary, it should succeed.
33
+ env GOAUTH='reinvocation'$GOEXE
26
34
cp go.mod.orig go.mod
27
35
go get vcs-test.golang.org/auth/or401
28
36
# go imports should resolve correctly as well.
29
37
go mod tidy
30
38
go list all
31
39
stdout vcs-test.golang.org/auth/or401
32
40
33
- -- auth/main.go --
41
+ # Authenticator can parse arguments correctly.
42
+ go build -o $WORK/bin/arguments$GOEXE scripts/arguments.go
43
+ # With credentials from the binary, it should succeed.
44
+ env GOAUTH='arguments'$GOEXE' --arg1 "value with spaces"'
45
+ cp go.mod.orig go.mod
46
+ go get vcs-test.golang.org/auth/or401
47
+ # go imports should resolve correctly as well.
48
+ go mod tidy
49
+ go list all
50
+ stdout vcs-test.golang.org/auth/or401
51
+
52
+ # Authenticator provides bad credentials.
53
+ go build -o $WORK/bin/invalid$GOEXE scripts/invalid.go
54
+ # With credentials from the binary, it should fail.
55
+ env GOAUTH='invalid'$GOEXE
56
+ cp go.mod.orig go.mod
57
+ ! go get vcs-test.golang.org/auth/or401
58
+ stderr '^\tserver response: ACCESS DENIED, buddy$'
59
+ # go imports should fail as well.
60
+ ! go mod tidy
61
+ stderr '^\tserver response: ACCESS DENIED, buddy$'
62
+
63
+ -- go.mod.orig --
64
+ module private.example.com
65
+ -- main.go --
66
+ package useprivate
67
+
68
+ import "vcs-test.golang.org/auth/or401"
69
+ -- scripts/basic.go --
70
+ package main
71
+
72
+ import "fmt"
73
+
74
+ func main() {
75
+ fmt.Printf("https://vcs-test.golang.org\n\nAuthorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l\n\n")
76
+ }
77
+ -- scripts/reinvocation.go --
34
78
package main
35
79
36
80
import(
@@ -45,11 +89,7 @@ import(
45
89
)
46
90
47
91
func main() {
48
- arg1 := flag.String("arg1", "", "")
49
92
flag.Parse()
50
- if *arg1 != "value with spaces" {
51
- log.Fatal("argument with spaces does not work")
52
- }
53
93
// wait for re-invocation
54
94
if !strings.HasPrefix(flag.Arg(0), "https://vcs-test.golang.org") {
55
95
return
@@ -68,12 +108,28 @@ func main() {
68
108
}
69
109
fmt.Printf("https://vcs-test.golang.org\n\nAuthorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l\n\n")
70
110
}
111
+ -- scripts/arguments.go --
112
+ package main
71
113
72
- -- auth/go.mod --
73
- module my-auth
74
- -- go.mod.orig --
75
- module private.example.com
76
- -- main.go --
77
- package useprivate
114
+ import(
115
+ "flag"
116
+ "fmt"
117
+ "log"
118
+ )
78
119
79
- import "vcs-test.golang.org/auth/or401"
120
+ func main() {
121
+ arg1 := flag.String("arg1", "", "")
122
+ flag.Parse()
123
+ if *arg1 != "value with spaces" {
124
+ log.Fatal("argument with spaces does not work")
125
+ }
126
+ fmt.Printf("https://vcs-test.golang.org\n\nAuthorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l\n\n")
127
+ }
128
+ -- scripts/invalid.go --
129
+ package main
130
+
131
+ import "fmt"
132
+
133
+ func main() {
134
+ fmt.Printf("https://vcs-test.golang.org\n\nAuthorization: Basic invalid\n\n")
135
+ }
0 commit comments