@@ -80,7 +80,7 @@ func TestCheckoutStrategyForImplementation_Proxied(t *testing.T) {
80
80
gitImpl : gogit .Implementation ,
81
81
url : "http://example.com/bar/test-reponame" ,
82
82
branch : "main" ,
83
- setupGitProxy : func (g * WithT , proxy * goproxy.ProxyHttpServer , proxyGotRequest * bool ) (* git.AuthOptions , cleanupFunc ) {
83
+ setupGitProxy : func (g * WithT , proxy * goproxy.ProxyHttpServer , proxiedRequests * int32 ) (* git.AuthOptions , cleanupFunc ) {
84
84
// Create the git server.
85
85
gitServer , err := gittestserver .NewTempGitServer ()
86
86
g .Expect (err ).ToNot (HaveOccurred ())
@@ -103,7 +103,7 @@ func TestCheckoutStrategyForImplementation_Proxied(t *testing.T) {
103
103
var proxyHandler goproxy.FuncReqHandler = func (req * http.Request , ctx * goproxy.ProxyCtx ) (* http.Request , * http.Response ) {
104
104
userAgent := req .Header .Get ("User-Agent" )
105
105
if strings .Contains (req .Host , "example.com" ) && strings .Contains (userAgent , "git" ) {
106
- * proxyGotRequest = true
106
+ atomic . AddInt32 ( proxiedRequests , 1 )
107
107
req .Host = u .Host
108
108
req .URL .Host = req .Host
109
109
return req , nil
@@ -131,13 +131,13 @@ func TestCheckoutStrategyForImplementation_Proxied(t *testing.T) {
131
131
gitImpl : gogit .Implementation ,
132
132
url : "https://github.com/git-fixtures/basic" ,
133
133
branch : "master" ,
134
- setupGitProxy : func (g * WithT , proxy * goproxy.ProxyHttpServer , proxyGotRequest * bool ) (* git.AuthOptions , cleanupFunc ) {
134
+ setupGitProxy : func (g * WithT , proxy * goproxy.ProxyHttpServer , proxiedRequests * int32 ) (* git.AuthOptions , cleanupFunc ) {
135
135
var proxyHandler goproxy.FuncHttpsHandler = func (host string , ctx * goproxy.ProxyCtx ) (* goproxy.ConnectAction , string ) {
136
136
// We don't check for user agent as this handler is only going to process CONNECT requests, and because Go's net/http
137
137
// is the one making such a request on behalf of go-git, adding a check for the go net/http user agent (Go-http-client)
138
138
// would only allow false positives from any request originating from Go's net/http.
139
139
if strings .Contains (host , "github.com" ) {
140
- * proxyGotRequest = true
140
+ atomic . AddInt32 ( proxiedRequests , 1 )
141
141
return goproxy .OkConnect , host
142
142
}
143
143
// Reject if it isnt our request.
@@ -158,10 +158,10 @@ func TestCheckoutStrategyForImplementation_Proxied(t *testing.T) {
158
158
gitImpl : gogit .Implementation ,
159
159
url : "https://192.0.2.1/bar/test-reponame" ,
160
160
branch : "main" ,
161
- setupGitProxy : func (g * WithT , proxy * goproxy.ProxyHttpServer , proxyGotRequest * bool ) (* git.AuthOptions , cleanupFunc ) {
161
+ setupGitProxy : func (g * WithT , proxy * goproxy.ProxyHttpServer , proxiedRequests * int32 ) (* git.AuthOptions , cleanupFunc ) {
162
162
var proxyHandler goproxy.FuncHttpsHandler = func (host string , ctx * goproxy.ProxyCtx ) (* goproxy.ConnectAction , string ) {
163
163
// We shouldn't hit the proxy so we just want to check for any interaction, then reject.
164
- * proxyGotRequest = true
164
+ atomic . AddInt32 ( proxiedRequests , 1 )
165
165
return goproxy .RejectConnect , host
166
166
}
167
167
proxy .OnRequest ().HandleConnect (proxyHandler )
0 commit comments