Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions scm/driver/bitbucket/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,7 @@ func (s *repositoryService) Find(ctx context.Context, repo string) (*scm.Reposit
path := fmt.Sprintf("2.0/repositories/%s", repo)
out := new(repository)
res, err := s.client.do(ctx, "GET", path, nil, out)
if err != nil {
return nil, res, err
}
repoPerm, _, err := s.FindPerms(ctx, repo)
return convertRepository2(out, repoPerm), res, err
return convertRepository(out), res, err
}

// FindHook returns a repository hook.
Expand Down
7 changes: 1 addition & 6 deletions scm/driver/bitbucket/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ func TestRepositoryFind(t *testing.T) {
Type("application/json").
File("testdata/repo.json")

gock.New("https://api.bitbucket.org").
Get("/2.0/user/permissions/repositories").
MatchParam("q", `repository.full_name="atlassian/stash-example-plugin"`).
Reply(200).
Type("application/json").
File("testdata/perms.json")


client, _ := New("https://api.bitbucket.org")
got, _, err := client.Repositories.Find(context.Background(), "atlassian/stash-example-plugin")
Expand Down
6 changes: 1 addition & 5 deletions scm/driver/bitbucket/testdata/repo.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
"ID": "{7dd600e6-0d9c-4801-b967-cb4cc17359ff}",
"Namespace": "atlassian",
"Name": "stash-example-plugin",
"Perm": {
"Pull": true,
"Push": true,
"Admin": true
},

"Branch": "master",
"Private": true,
"Clone": "https://bitbucket.org/atlassian/stash-example-plugin.git",
Expand Down
6 changes: 2 additions & 4 deletions scm/transport/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ func NewTransport(base http.RoundTripper, proxyURL string) (http.RoundTripper, e
if err != nil {
return nil, err
}

return &Transport{
Base: base,
ProxyURL: parsedURL,
return &http.Transport{
Proxy: http.ProxyURL(parsedURL),
}, nil
}
25 changes: 19 additions & 6 deletions scm/transport/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,28 @@ func TestNewTransport_ValidProxyURL(t *testing.T) {
if err != nil {
t.Fatalf("Expected no error for valid proxy URL, got: %v", err)
}
proxyTransport, ok := transport.(*Transport)

proxyTransport, ok := transport.(*http.Transport)
if !ok {
t.Fatal("Expected transport to be of type *Transport")
t.Fatal("Expected transport to be of type *http.Transport")
}

// Test that the proxy function is set correctly
if proxyTransport.Proxy == nil {
t.Fatal("Expected proxy function to be set")
}


// Test the proxy function with a sample request
testURL, _ := url.Parse("http://example.com")
req := &http.Request{URL: testURL}
proxyURLResult, err := proxyTransport.Proxy(req)
if err != nil {
t.Fatalf("Expected no error from proxy function, got: %v", err)
}

expectedURL, _ := url.Parse(proxyURL)
if proxyTransport.ProxyURL.String() != expectedURL.String() {
t.Errorf("Expected proxy URL %s, got %s", expectedURL.String(), proxyTransport.ProxyURL.String())
if proxyURLResult.String() != expectedURL.String() {
t.Errorf("Expected proxy URL %s, got %s", expectedURL.String(), proxyURLResult.String())
}
}

Expand Down