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