forked from TrueCloudLab/frostfs-api-go
[#302] pkg/token: Document default values set in NewBearerToken
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
00a0ea42a8
commit
245271bb65
2 changed files with 26 additions and 0 deletions
|
@ -99,6 +99,15 @@ func (b *BearerToken) Issuer() *owner.ID {
|
||||||
return owner.NewIDFromNeo3Wallet(wallet)
|
return owner.NewIDFromNeo3Wallet(wallet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewBearerToken creates and initializes blank BearerToken.
|
||||||
|
//
|
||||||
|
// Defaults:
|
||||||
|
// - signature: nil;
|
||||||
|
// - eacl: nil;
|
||||||
|
// - ownerID: nil;
|
||||||
|
// - exp: 0;
|
||||||
|
// - nbf: 0;
|
||||||
|
// - iat: 0.
|
||||||
func NewBearerToken() *BearerToken {
|
func NewBearerToken() *BearerToken {
|
||||||
b := new(BearerToken)
|
b := new(BearerToken)
|
||||||
b.token = acl.BearerToken{}
|
b.token = acl.BearerToken{}
|
||||||
|
|
|
@ -63,3 +63,20 @@ func TestBearerToken_ToV2(t *testing.T) {
|
||||||
require.Nil(t, x.ToV2())
|
require.Nil(t, x.ToV2())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewBearerToken(t *testing.T) {
|
||||||
|
t.Run("default values", func(t *testing.T) {
|
||||||
|
tkn := token.NewBearerToken()
|
||||||
|
|
||||||
|
// convert to v2 message
|
||||||
|
tknV2 := tkn.ToV2()
|
||||||
|
|
||||||
|
require.NotNil(t, tknV2.GetBody())
|
||||||
|
require.Zero(t, tknV2.GetBody().GetLifetime().GetExp())
|
||||||
|
require.Zero(t, tknV2.GetBody().GetLifetime().GetNbf())
|
||||||
|
require.Zero(t, tknV2.GetBody().GetLifetime().GetIat())
|
||||||
|
require.Nil(t, tknV2.GetBody().GetEACL())
|
||||||
|
require.Nil(t, tknV2.GetBody().GetOwnerID())
|
||||||
|
require.Nil(t, tknV2.GetSignature())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue