Skip to content

Find, verify, and analyze leaked credentials

Fix bug in GitHub unit test mocking (#608)

Miccah907400669530
diff --git a/pkg/sources/github/github.go b/pkg/sources/github/github.go
index 6feae4f48..7866e9e8f 100644
--- a/pkg/sources/github/github.go
+++ b/pkg/sources/github/github.go
@@ -242,7 +242,7 @@ func (s *Source) enumerateWithApp(ctx context.Context, apiEndpoint string, app *
// This client is used for most APIs
itr, err := ghinstallation.New(
- common.SaneHttpClient().Transport,
+ s.httpClient.Transport,
appID,
installationID,
[]byte(app.PrivateKey))
@@ -258,7 +258,7 @@ func (s *Source) enumerateWithApp(ctx context.Context, apiEndpoint string, app *
// This client is required to create installation tokens for cloning.. Otherwise the required JWT is not in the
// request for the token :/
appItr, err := ghinstallation.NewAppsTransport(
- common.SaneHttpClient().Transport,
+ s.httpClient.Transport,
appID,
[]byte(app.PrivateKey))
if err != nil {
diff --git a/pkg/sources/github/github_test.go b/pkg/sources/github/github_test.go
index 15d6bb99e..a73f60fc5 100644
--- a/pkg/sources/github/github_test.go
+++ b/pkg/sources/github/github_test.go
@@ -7,7 +7,6 @@ import (
"crypto/rsa"
"crypto/x509"
"encoding/pem"
- "fmt"
"io"
"net/http"
"reflect"
@@ -40,6 +39,7 @@ func initTestSource(src *sourcespb.GitHub) *Source {
if err := s.Init(context.TODO(), "test - github", 0, 1337, false, conn, 1); err != nil {
panic(err)
}
+ gock.InterceptClient(s.httpClient)
return s
}
@@ -334,7 +334,6 @@ func TestEnumerateWithApp(t *testing.T) {
PrivateKey: privateKey,
},
)
- fmt.Println(err)
assert.Nil(t, err)
assert.Equal(t, 0, len(s.repos))