diff --git a/client/utils.go b/client/utils.go index f17bcf3..c0af6d8 100644 --- a/client/utils.go +++ b/client/utils.go @@ -150,6 +150,10 @@ func UnsecureClaimsFromToken(token string) ([]string, error) { // NormalizeAuth normalizes the response to a simple structure. func NormalizeAuth(c *types.MidgardClaims) (claims []string) { + if c == nil { + return + } + if c.Subject != "" { claims = append(claims, "@auth:subject="+c.Subject) } diff --git a/client/utils_test.go b/client/utils_test.go index 7910298..b43db02 100644 --- a/client/utils_test.go +++ b/client/utils_test.go @@ -121,6 +121,15 @@ func TestUtils_NormalizeAuth(t *testing.T) { So(v, ShouldContain, "@auth:d2=v2") }) }) + + Convey("When I normalize nil claims", func() { + + v := NormalizeAuth(nil) + + Convey("Then the subject should be correct", func() { + So(len(v), ShouldEqual, 0) + }) + }) }) }