fix: nil pointer dereference on UserInfoAddress
When the Address field in userinfo is nil, an empty instance of userInfoAddress is now returned. This allows for safe chaining of Get methods. All of an empty userInfoAddress' Get methods will return empty strings.
Fixes #203
Codecov Report
Merging #207 (9b63a93) into main (1535ea4) will increase coverage by
0.08%. The diff coverage is100.00%.
@@ Coverage Diff @@
## main #207 +/- ##
==========================================
+ Coverage 39.49% 39.58% +0.08%
==========================================
Files 74 74
Lines 5907 5912 +5
==========================================
+ Hits 2333 2340 +7
+ Misses 3323 3321 -2
Partials 251 251
| Impacted Files | Coverage Δ | |
|---|---|---|
| pkg/oidc/userinfo.go | 53.65% <100.00%> (+2.71%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
I've updated this PR to catch the nil in userinfo.UnmarshalJSON and set a new empty value to the userinfo.Address field. The original change in userinfo.GetAddress() is reverted. And the tests now use actual json.
@livio-a I've rebased, because the test were failing with my old branch. Comments are resolved.