add unit tests for oidc.Userinfo

- Add get methods for Address fields to handle nil pointers as we used to
This commit is contained in:
Tim Möhlmann 2023-03-02 17:35:06 +02:00
parent 72a108a33b
commit d41f4b5d21
6 changed files with 52 additions and 5 deletions

View file

@ -18,6 +18,15 @@ func (u *UserInfo) AppendClaims(k string, v any) {
u.Claims[k] = v
}
// GetAddress is a safe getter that takes
// care of a possible nil value.
func (u *UserInfo) GetAddress() *UserInfoAddress {
if u.Address == nil {
return new(UserInfoAddress)
}
return u.Address
}
type uiAlias UserInfo
func (u *UserInfo) MarshalJSON() ([]byte, error) {