Skip to content

Commit

Permalink
fixes issue due to change by atlassian https://developer.atlassian.co…
Browse files Browse the repository at this point in the history
  • Loading branch information
eoinmcafee00 authored Dec 30, 2021
1 parent fdfe239 commit 3dbe29d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
6 changes: 3 additions & 3 deletions scm/driver/bitbucket/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type organizationService struct {
}

func (s *organizationService) Find(ctx context.Context, name string) (*scm.Organization, *scm.Response, error) {
path := fmt.Sprintf("2.0/teams/%s", name)
path := fmt.Sprintf("2.0/workspaces/%s", name)
out := new(organization)
res, err := s.client.do(ctx, "GET", path, nil, out)
return convertOrganization(out), res, err
Expand All @@ -27,7 +27,7 @@ func (s *organizationService) FindMembership(ctx context.Context, name, username
}

func (s *organizationService) List(ctx context.Context, opts scm.ListOptions) ([]*scm.Organization, *scm.Response, error) {
path := fmt.Sprintf("2.0/teams?%s", encodeListRoleOptions(opts))
path := fmt.Sprintf("2.0/workspaces?%s", encodeListRoleOptions(opts))
out := new(organizationList)
res, err := s.client.do(ctx, "GET", path, nil, out)
copyPagination(out.pagination, res)
Expand All @@ -48,7 +48,7 @@ type organizationList struct {
}

type organization struct {
Login string `json:"username"`
Login string `json:"slug"`
}

func convertOrganization(from *organization) *scm.Organization {
Expand Down
4 changes: 2 additions & 2 deletions scm/driver/bitbucket/org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestOrganizationFind(t *testing.T) {
defer gock.Off()

gock.New("https://api.bitbucket.org").
Get("/2.0/teams/atlassian").
Get("/2.0/workspaces/atlassian").
Reply(200).
Type("application/json").
File("testdata/team.json")
Expand All @@ -45,7 +45,7 @@ func TestOrganizationList(t *testing.T) {
defer gock.Off()

gock.New("https://api.bitbucket.org").
Get("/2.0/teams").
Get("/2.0/workspaces").
MatchParam("pagelen", "30").
MatchParam("page", "1").
Reply(200).
Expand Down
34 changes: 27 additions & 7 deletions scm/driver/bitbucket/testdata/team.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
{
"username": "atlassian",
"type": "team",
"display_name": "Atlassian",
"uuid": "{02b941e3-cfaa-40f9-9a58-cec53e20bdc3}",
"links": {
"owners": {
"href": "https://api.bitbucket.org/2.0/workspaces/atlassian/members?q=permission%3D%22owner%22"
},
"hooks": {
"href": "https://api.bitbucket.org/2.0/workspaces/atlassian/hooks"
},
"self": {
"href": "https:\/\/api.bitbucket.org\/2.0\/teams\/atlassian"
"href": "https://api.bitbucket.org/2.0/workspaces/atlassian"
},
"repositories": {
"href": "https://api.bitbucket.org/2.0/repositories/atlassian"
},
"html": {
"href": "https:\/\/bitbucket.org\/atlassian\/"
"href": "https://bitbucket.org/atlassian/"
},
"avatar": {
"href": "https:\/\/bitbucket.org\/account\/atlassian\/avatar\/32\/"
"href": "https://bitbucket.org/workspaces/atlassian/avatar/?ts=1612327398"
},
"members": {
"href": "https://api.bitbucket.org/2.0/workspaces/atlassian/members"
},
"projects": {
"href": "https://api.bitbucket.org/2.0/workspaces/atlassian/projects"
},
"snippets": {
"href": "https://api.bitbucket.org/2.0/snippets/atlassian"
}
}
},
"created_on": "2018-11-29T02:26:39.297476+00:00",
"type": "workspace",
"slug": "atlassian",
"is_private": true,
"name": "Atlassian"
}
8 changes: 4 additions & 4 deletions scm/driver/bitbucket/testdata/teams.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"pagelen": 30,
"values": [
{
"username": "atlassian",
"slug": "atlassian",
"website": null,
"display_name": "Atlassian",
"is_private": false,
"name": "Atlassian",
"uuid": "{d5bb8c49-f033-4498-910e-7e4b546b04ee}",
"links": {
"hooks": {
Expand Down Expand Up @@ -39,8 +40,7 @@
}
},
"created_on": "2012-11-08T19:05:39.080491+00:00",
"location": null,
"type": "team"
"type": "workspace"
}
],
"page": 1,
Expand Down

0 comments on commit 3dbe29d

Please sign in to comment.