forked from TrueCloudLab/frostfs-api-go
service: prevent NPE in VerifyTokenSignature function
This commit adds next changes to VerifyTokenSignature: * returns ErrEmptyToken on nil token argument; * returns ErrEmptyPublicKey on nil public key argument.
This commit is contained in:
parent
82ffde253b
commit
cce6566f1e
2 changed files with 19 additions and 0 deletions
|
@ -96,6 +96,11 @@ func TestSignToken(t *testing.T) {
|
|||
ErrEmptyToken.Error(),
|
||||
)
|
||||
|
||||
require.EqualError(t,
|
||||
VerifyTokenSignature(nil, nil),
|
||||
ErrEmptyToken.Error(),
|
||||
)
|
||||
|
||||
var token SessionToken = new(Token)
|
||||
|
||||
// nil key
|
||||
|
@ -104,6 +109,11 @@ func TestSignToken(t *testing.T) {
|
|||
crypto.ErrEmptyPrivateKey.Error(),
|
||||
)
|
||||
|
||||
require.EqualError(t,
|
||||
VerifyTokenSignature(token, nil),
|
||||
crypto.ErrEmptyPublicKey.Error(),
|
||||
)
|
||||
|
||||
// create private key for signing
|
||||
sk := test.DecodeKey(0)
|
||||
pk := &sk.PublicKey
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue