Skip to content

Commit 3bb0770

Browse files
authored
fix nilnil in onedev downloader (#36154)
onedev migration never used the migration transport, it now uses it the same way gogs one does --- cuts 3 nilnils for #36152
1 parent 822ee60 commit 3bb0770

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

cmd/admin_auth_ldap_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func TestAddLdapBindDn(t *testing.T) {
233233
},
234234
getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) {
235235
assert.FailNow(t, "getAuthSourceByID called", "case %d: should not call getAuthSourceByID", n)
236-
return nil, nil
236+
return nil, nil //nolint:nilnil // mock function covering improper behavior
237237
},
238238
}
239239

@@ -463,7 +463,7 @@ func TestAddLdapSimpleAuth(t *testing.T) {
463463
},
464464
getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) {
465465
assert.FailNow(t, "getAuthSourceById called", "case %d: should not call getAuthSourceByID", n)
466-
return nil, nil
466+
return nil, nil //nolint:nilnil // mock function covering improper behavior
467467
},
468468
}
469469

services/migrations/onedev.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,19 @@ type OneDevDownloader struct {
7777
}
7878

7979
// NewOneDevDownloader creates a new downloader
80-
func NewOneDevDownloader(_ context.Context, baseURL *url.URL, username, password, repoPath string) *OneDevDownloader {
80+
func NewOneDevDownloader(ctx context.Context, baseURL *url.URL, username, password, repoPath string) *OneDevDownloader {
81+
httpTransport := NewMigrationHTTPTransport()
8182
downloader := &OneDevDownloader{
8283
baseURL: baseURL,
8384
repoPath: repoPath,
8485
client: &http.Client{
85-
Transport: &http.Transport{
86-
Proxy: func(req *http.Request) (*url.URL, error) {
87-
if len(username) > 0 && len(password) > 0 {
86+
Transport: roundTripperFunc(
87+
func(req *http.Request) (*http.Response, error) {
88+
if username != "" && password != "" {
8889
req.SetBasicAuth(username, password)
8990
}
90-
return nil, nil
91-
},
92-
},
91+
return httpTransport.RoundTrip(req.WithContext(ctx))
92+
}),
9393
},
9494
userMap: make(map[int64]*onedevUser),
9595
milestoneMap: make(map[int64]string),

0 commit comments

Comments
 (0)