Skip to content

Commit

Permalink
[entraid] parse user's given name and surname (#49496)
Browse files Browse the repository at this point in the history
To populate the given name and surname traits, we must parse them from
Entra ID responses. This PR parses the given name and surname artifacts
from the json response.

Signed-off-by: Tiago Silva <[email protected]>
  • Loading branch information
tigrato authored Nov 27, 2024
1 parent e4378be commit a1cdc9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/msgraph/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,13 @@ func TestIterateUsers(t *testing.T) {
require.Equal(t, "[email protected]", *users[0].Mail)
require.Equal(t, "Alice Alison", *users[0].DisplayName)
require.Equal(t, "[email protected]", *users[0].UserPrincipalName)
require.Nil(t, users[0].Surname)
require.Nil(t, users[0].GivenName)

require.Equal(t, "[email protected]", *users[1].Mail)
require.Equal(t, "[email protected]", *users[1].UserPrincipalName)
require.Equal(t, "Bobert", *users[1].Surname)
require.Equal(t, "Bob", *users[1].GivenName)

require.Equal(t, "[email protected]", *users[2].Mail)
require.Equal(t, "[email protected]", *users[2].UserPrincipalName)
Expand Down
2 changes: 2 additions & 0 deletions lib/msgraph/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type User struct {
Mail *string `json:"mail,omitempty"`
OnPremisesSAMAccountName *string `json:"onPremisesSamAccountName,omitempty"`
UserPrincipalName *string `json:"userPrincipalName,omitempty"`
Surname *string `json:"surname,omitempty"`
GivenName *string `json:"givenName,omitempty"`
}

func (g *User) isGroupMember() {}
Expand Down

0 comments on commit a1cdc9a

Please sign in to comment.