From 01a540e574f695b17d03bd7651bffc766277f6d9 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Fri, 6 Sep 2019 14:39:16 -0700 Subject: [PATCH] new: make NormalizeAuth public --- client/client.go | 2 +- client/utils.go | 8 ++++---- client/utils_test.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/client.go b/client/client.go index b955089..1318417 100644 --- a/client/client.go +++ b/client/client.go @@ -107,7 +107,7 @@ func (a *Client) Authentify(ctx context.Context, token string) ([]string, error) return nil, err } - return normalizeAuth(auth.Claims), nil + return NormalizeAuth(auth.Claims), nil } // IssueFromGoogle issues a Midgard jwt from a Google JWT for the given validity duration. diff --git a/client/utils.go b/client/utils.go index 32f6955..f17bcf3 100644 --- a/client/utils.go +++ b/client/utils.go @@ -128,7 +128,7 @@ func VerifyTokenSignature(tokenString string, cert *x509.Certificate) ([]string, return nil, err } - return normalizeAuth(token.Claims.(*types.MidgardClaims)), nil + return NormalizeAuth(token.Claims.(*types.MidgardClaims)), nil } // UnsecureClaimsFromToken gets a token and returns the Aporeto @@ -144,11 +144,11 @@ func UnsecureClaimsFromToken(token string) ([]string, error) { return nil, err } - return normalizeAuth(c), nil + return NormalizeAuth(c), nil } -// normalizeAuth normalizes the response to a simple structure. -func normalizeAuth(c *types.MidgardClaims) (claims []string) { +// NormalizeAuth normalizes the response to a simple structure. +func NormalizeAuth(c *types.MidgardClaims) (claims []string) { if c.Subject != "" { claims = append(claims, "@auth:subject="+c.Subject) diff --git a/client/utils_test.go b/client/utils_test.go index b90dba6..7910298 100644 --- a/client/utils_test.go +++ b/client/utils_test.go @@ -95,7 +95,7 @@ func TestUtils_extractJWT(t *testing.T) { }) } -func TestUtils_normalizeAuth(t *testing.T) { +func TestUtils_NormalizeAuth(t *testing.T) { Convey("Given I have a Auth object", t, func() { @@ -107,7 +107,7 @@ func TestUtils_normalizeAuth(t *testing.T) { Convey("When I normalize it", func() { - v := normalizeAuth(auth.Claims) + v := NormalizeAuth(auth.Claims) Convey("Then the subject should be correct", func() { So(v, ShouldContain, "@auth:subject=subject")