You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
794 B
40 lines
794 B
package salty
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestKeys(t *testing.T) {
|
|
assert := assert.New(t)
|
|
require := require.New(t)
|
|
|
|
t.Run("WithPassword", func(t *testing.T) {
|
|
buf := &bytes.Buffer{}
|
|
pwd := "password123"
|
|
key, pub := GenerateKeys(pwd, buf)
|
|
assert.NotEmpty(pub)
|
|
|
|
parsedKey, err := ParseIdentity(pwd, buf)
|
|
require.NoError(err)
|
|
|
|
assert.Equal(key, parsedKey)
|
|
assert.Equal(pub, key.PublicKey().String())
|
|
})
|
|
|
|
t.Run("WithoutPassword", func(t *testing.T) {
|
|
buf := &bytes.Buffer{}
|
|
key, pub := GenerateKeys("", buf)
|
|
assert.NotEmpty(pub)
|
|
|
|
parsedKey, err := ParseIdentity("", buf)
|
|
require.NoError(err)
|
|
|
|
assert.Equal(key, parsedKey)
|
|
assert.Equal(pub, key.PublicKey().String())
|
|
})
|
|
|
|
}
|
|
|