Skip to content

Commit

Permalink
Use [T,t]eamID instead of [T,t]eamId
Browse files Browse the repository at this point in the history
  • Loading branch information
mwildehahn committed Jan 29, 2016
1 parent 2993f23 commit 7f06c32
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions cmd/empire/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ func newAuthenticator(c *cli.Context, e *empire.Empire) auth.Authenticator {
}

// After the user is authenticated, check their GitHub Team membership.
if teamId := c.String(FlagGithubTeam); teamId != "" {
if teamID := c.String(FlagGithubTeam); teamID != "" {
authorizer := githubauth.NewTeamAuthorizer(client)
authorizer.TeamId = teamId
authorizer.TeamID = teamID

log.Println("Adding GitHub Team authorizer with the following configuration:")
log.Println(fmt.Sprintf(" Team ID: %v ", teamId))
log.Println(fmt.Sprintf(" Team ID: %v ", teamID))

return auth.WithAuthorization(
authenticator,
Expand Down
4 changes: 2 additions & 2 deletions server/auth/github/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ func (c *Client) IsOrganizationMember(organization, token string) (bool, error)
}

// IsTeamMember returns true if the given user is a member of the team.
func (c *Client) IsTeamMember(teamId, name string, token string) (bool, error) {
req, err := c.NewRequest("GET", fmt.Sprintf("/teams/%s/memberships/%s", teamId, name), nil)
func (c *Client) IsTeamMember(teamID, name string, token string) (bool, error) {
req, err := c.NewRequest("GET", fmt.Sprintf("/teams/%s/memberships/%s", teamID, name), nil)
if err != nil {
return false, err
}
Expand Down
10 changes: 5 additions & 5 deletions server/auth/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ func (a *OrganizationAuthorizer) Authorize(user *empire.User) error {
// TeamAuthorizer is an implementation of the auth.Authorizer interface that
// checks that the user is a member of the given GitHub team.
type TeamAuthorizer struct {
TeamId string
TeamID string

client interface {
IsTeamMember(teamId, name string, token string) (bool, error)
IsTeamMember(teamID, name string, token string) (bool, error)
}
}

Expand All @@ -104,18 +104,18 @@ func NewTeamAuthorizer(c *Client) *TeamAuthorizer {
}

func (a *TeamAuthorizer) Authorize(user *empire.User) error {
if a.TeamId == "" {
if a.TeamID == "" {
panic("no team id set")
}

ok, err := a.client.IsTeamMember(a.TeamId, user.Name, user.GitHubToken)
ok, err := a.client.IsTeamMember(a.TeamID, user.Name, user.GitHubToken)
if err != nil {
return err
}

if !ok {
return &auth.UnauthorizedError{
Reason: fmt.Sprintf("%s is not a member of team %s.", user.Name, a.TeamId),
Reason: fmt.Sprintf("%s is not a member of team %s.", user.Name, a.TeamID),
}
}

Expand Down
8 changes: 4 additions & 4 deletions server/auth/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestOrganizationAuthorizer_Unauthorized(t *testing.T) {
func TestTeamAuthorizer(t *testing.T) {
c := new(mockClient)
a := &TeamAuthorizer{
TeamId: "123",
TeamID: "123",
client: c,
}

Expand All @@ -108,7 +108,7 @@ func TestTeamAuthorizer(t *testing.T) {
func TestTeamAuthorizer_Unauthorized(t *testing.T) {
c := new(mockClient)
a := &TeamAuthorizer{
TeamId: "123",
TeamID: "123",
client: c,
}

Expand Down Expand Up @@ -149,7 +149,7 @@ func (m *mockClient) IsOrganizationMember(organization, token string) (bool, err
return args.Bool(0), args.Error(1)
}

func (m *mockClient) IsTeamMember(teamId, name string, token string) (bool, error) {
args := m.Called(teamId, name, token)
func (m *mockClient) IsTeamMember(teamID, name string, token string) (bool, error) {
args := m.Called(teamID, name, token)
return args.Bool(0), args.Error(1)
}

0 comments on commit 7f06c32

Please sign in to comment.