Skip to content

Commit

Permalink
new: make NormalizeAuth public
Browse files Browse the repository at this point in the history
  • Loading branch information
primalmotion committed Sep 6, 2019
1 parent 7c4d8d1 commit 01a540e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions client/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions client/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -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")
Expand Down

0 comments on commit 01a540e

Please sign in to comment.