Browse Source

Merge ce8be860b8 into 6b9ce00e11

pull/2661/merge
Alex Smith 12 hours ago committed by GitHub
parent
commit
8c82bac022
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 15
      connector/atlassiancrowd/atlassiancrowd.go
  2. 11
      connector/atlassiancrowd/atlassiancrowd_test.go

15
connector/atlassiancrowd/atlassiancrowd.go

@ -53,10 +53,11 @@ type Config struct {
}
type crowdUser struct {
Key string
Name string
Active bool
Email string
Key string
Name string
DisplayName string `json:"display-name"`
Active bool
Email string
}
type crowdGroups struct {
@ -128,7 +129,7 @@ func (c *crowdConnector) Login(ctx context.Context, s connector.Scopes, username
ident = c.identityFromCrowdUser(user)
if s.Groups {
userGroups, err := c.getGroups(ctx, client, s.Groups, ident.Username)
userGroups, err := c.getGroups(ctx, client, s.Groups, username)
if err != nil {
return connector.Identity{}, false, fmt.Errorf("crowd: failed to query groups: %v", err)
}
@ -170,7 +171,7 @@ func (c *crowdConnector) Refresh(ctx context.Context, s connector.Scopes, ident
}
if s.Groups {
userGroups, err := c.getGroups(ctx, client, s.Groups, newIdent.Username)
userGroups, err := c.getGroups(ctx, client, s.Groups, data.Username)
if err != nil {
return connector.Identity{}, fmt.Errorf("crowd: failed to query groups: %v", err)
}
@ -360,7 +361,7 @@ func (c *crowdConnector) groups(ctx context.Context, client *http.Client, userna
// identityFromCrowdUser converts crowdUser to Identity
func (c *crowdConnector) identityFromCrowdUser(user crowdUser) connector.Identity {
identity := connector.Identity{
Username: user.Name,
Username: user.DisplayName,
UserID: user.Key,
Email: user.Email,
EmailVerified: true,

11
connector/atlassiancrowd/atlassiancrowd_test.go

@ -101,10 +101,11 @@ func TestUserPassword(t *testing.T) {
func TestIdentityFromCrowdUser(t *testing.T) {
user := crowdUser{
Key: "12345",
Name: "testuser",
Active: true,
Email: "testuser@example.com",
Key: "12345",
Name: "testuser",
DisplayName: "Test User",
Active: true,
Email: "testuser@example.com",
}
c := newTestCrowdConnector("/")
@ -116,7 +117,7 @@ func TestIdentityFromCrowdUser(t *testing.T) {
// Test unconfigured behavior
i := c.identityFromCrowdUser(user)
expectEquals(t, i.UserID, "12345")
expectEquals(t, i.Username, "testuser")
expectEquals(t, i.Username, "Test User")
expectEquals(t, i.Email, "testuser@example.com")
expectEquals(t, i.EmailVerified, true)

Loading…
Cancel
Save