Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
ce3cd53a
Commit
ce3cd53a
authored
Nov 15, 2018
by
Alexander Matyushentsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fix: take into account 'teamNameField' settings while fetching all user groups
parent
e8763531
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
9 deletions
+36
-9
github.go
connector/github/github.go
+14
-9
github_test.go
connector/github/github_test.go
+22
-0
No files found.
connector/github/github.go
View file @
ce3cd53a
...
@@ -445,7 +445,7 @@ func (c *githubConnector) userOrgTeams(ctx context.Context, client *http.Client)
...
@@ -445,7 +445,7 @@ func (c *githubConnector) userOrgTeams(ctx context.Context, client *http.Client)
}
}
for
_
,
t
:=
range
teams
{
for
_
,
t
:=
range
teams
{
groups
[
t
.
Org
.
Login
]
=
append
(
groups
[
t
.
Org
.
Login
],
t
.
Name
)
groups
[
t
.
Org
.
Login
]
=
append
(
groups
[
t
.
Org
.
Login
],
c
.
teamGroupClaim
(
t
)
)
}
}
if
apiURL
==
""
{
if
apiURL
==
""
{
...
@@ -680,14 +680,9 @@ func (c *githubConnector) teamsForOrg(ctx context.Context, client *http.Client,
...
@@ -680,14 +680,9 @@ func (c *githubConnector) teamsForOrg(ctx context.Context, client *http.Client,
return
nil
,
fmt
.
Errorf
(
"github: get teams: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"github: get teams: %v"
,
err
)
}
}
for
_
,
team
:=
range
teams
{
for
_
,
t
:=
range
teams
{
if
team
.
Org
.
Login
==
orgName
{
if
t
.
Org
.
Login
==
orgName
{
switch
c
.
teamNameField
{
groups
=
append
(
groups
,
c
.
teamGroupClaim
(
t
))
case
"name"
,
""
:
groups
=
append
(
groups
,
team
.
Name
)
case
"slug"
:
groups
=
append
(
groups
,
team
.
Slug
)
}
}
}
}
}
...
@@ -698,3 +693,13 @@ func (c *githubConnector) teamsForOrg(ctx context.Context, client *http.Client,
...
@@ -698,3 +693,13 @@ func (c *githubConnector) teamsForOrg(ctx context.Context, client *http.Client,
return
groups
,
nil
return
groups
,
nil
}
}
// teamGroupClaim returns team slag if 'teamNameField; option is set to 'slug' otherwise returns team name.
func
(
c
*
githubConnector
)
teamGroupClaim
(
t
team
)
string
{
switch
c
.
teamNameField
{
case
"slug"
:
return
t
.
Slug
default
:
return
t
.
Name
}
}
connector/github/github_test.go
View file @
ce3cd53a
...
@@ -77,6 +77,28 @@ func TestUserGroupsWithoutOrgs(t *testing.T) {
...
@@ -77,6 +77,28 @@ func TestUserGroupsWithoutOrgs(t *testing.T) {
}
}
func
TestUserGroupsWithTeamNameFieldConfig
(
t
*
testing
.
T
)
{
s
:=
newTestServer
(
map
[
string
]
testResponse
{
"/user/orgs"
:
{
data
:
[]
org
{{
Login
:
"org-1"
}},
},
"/user/teams"
:
{
data
:
[]
team
{
{
Name
:
"Team 1"
,
Slug
:
"team-1"
,
Org
:
org
{
Login
:
"org-1"
}},
},
},
})
defer
s
.
Close
()
c
:=
githubConnector
{
apiURL
:
s
.
URL
,
teamNameField
:
"slug"
}
groups
,
err
:=
c
.
userGroups
(
context
.
Background
(),
newClient
())
expectNil
(
t
,
err
)
expectEquals
(
t
,
groups
,
[]
string
{
"org-1:team-1"
,
})
}
func
TestUsernameIncludedInFederatedIdentity
(
t
*
testing
.
T
)
{
func
TestUsernameIncludedInFederatedIdentity
(
t
*
testing
.
T
)
{
s
:=
newTestServer
(
map
[
string
]
testResponse
{
s
:=
newTestServer
(
map
[
string
]
testResponse
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment