forked from TrueCloudLab/frostfs-node
[#840] adm: Update FrostFS ID deploy arguments
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
b2c63e57ba
commit
f1db468d48
3 changed files with 47 additions and 48 deletions
|
@ -6,8 +6,6 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -20,30 +18,36 @@ func TestFrostfsIDConfig(t *testing.T) {
|
|||
pks[i] = pk
|
||||
}
|
||||
|
||||
v := viper.New()
|
||||
v.Set("frostfsid.authorized_keys", []string{
|
||||
fmts := []string{
|
||||
pks[0].GetScriptHash().StringLE(),
|
||||
address.Uint160ToString(pks[1].GetScriptHash()),
|
||||
hex.EncodeToString(pks[2].PublicKey().UncompressedBytes()),
|
||||
hex.EncodeToString(pks[3].PublicKey().Bytes()),
|
||||
})
|
||||
}
|
||||
|
||||
comm := util.Uint160{1, 2, 3}
|
||||
actual, err := getFrostfsIDAuthorizedKeys(v, comm)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(pks)+1, len(actual))
|
||||
require.Equal(t, smartcontract.Hash160Type, actual[0].Type)
|
||||
require.Equal(t, comm, actual[0].Value)
|
||||
for i := range pks {
|
||||
require.Equal(t, smartcontract.Hash160Type, actual[i+1].Type)
|
||||
require.Equal(t, pks[i].GetScriptHash(), actual[i+1].Value)
|
||||
for i := range fmts {
|
||||
v := viper.New()
|
||||
v.Set("frostfsid.admin", fmts[i])
|
||||
|
||||
actual, found, err := getFrostfsIDAdmin(v)
|
||||
require.NoError(t, err)
|
||||
require.True(t, found)
|
||||
require.Equal(t, pks[i].GetScriptHash(), actual)
|
||||
}
|
||||
|
||||
t.Run("bad key", func(t *testing.T) {
|
||||
v := viper.New()
|
||||
v.Set("frostfsid.authorized_keys", []string{"abc"})
|
||||
v.Set("frostfsid.admin", "abc")
|
||||
|
||||
_, err := getFrostfsIDAuthorizedKeys(v, comm)
|
||||
_, found, err := getFrostfsIDAdmin(v)
|
||||
require.Error(t, err)
|
||||
require.True(t, found)
|
||||
})
|
||||
t.Run("missing key", func(t *testing.T) {
|
||||
v := viper.New()
|
||||
|
||||
_, found, err := getFrostfsIDAdmin(v)
|
||||
require.NoError(t, err)
|
||||
require.False(t, found)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue