Skip to content

Commit

Permalink
bearer: Move ResolveIssuer from package to struct
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
  • Loading branch information
smallhive committed Jul 26, 2023
1 parent 7e7ba51 commit ecef897
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions bearer/bearer.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ func (b Token) SigningKeyBytes() []byte {
// Returns zero user.ID if Token is unsigned or key has incorrect format.
//
// See also SigningKeyBytes.
func ResolveIssuer(b Token) (usr user.ID) {
func (b Token) ResolveIssuer() user.ID {
var usr user.ID
binKey := b.SigningKeyBytes()

if len(binKey) != 0 {
Expand All @@ -363,5 +364,5 @@ func ResolveIssuer(b Token) (usr user.ID) {
}
}

return
return usr
}
6 changes: 3 additions & 3 deletions bearer/bearer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func TestResolveIssuer(t *testing.T) {

var val bearer.Token

require.Zero(t, bearer.ResolveIssuer(val))
require.Zero(t, val.ResolveIssuer())

var m acl.BearerToken

Expand All @@ -371,11 +371,11 @@ func TestResolveIssuer(t *testing.T) {

require.NoError(t, val.Unmarshal(m.StableMarshal(nil)))

require.Zero(t, bearer.ResolveIssuer(val))
require.Zero(t, val.ResolveIssuer())

require.NoError(t, val.Sign(signer))

usr := signer.UserID()

require.Equal(t, usr, bearer.ResolveIssuer(val))
require.Equal(t, usr, val.ResolveIssuer())
}

0 comments on commit ecef897

Please sign in to comment.