saltyim is the Go library and reference client and broker implementation for Salty IM it contains a command-line client (cli), a terminal user interface (tui), builtin server/broker and a Mobile / Desktop App PWA (progressive web app) https://salty.im/
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.
 
 
 
 
 
saltyim/identity_test.go

39 lines
876 B

package saltyim
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const (
testAddr = "alice@example.com"
testIdentityPath = "alice.key"
)
func TestIdentity(t *testing.T) {
assert := assert.New(t)
require := require.New(t)
dir, err := ioutil.TempDir("", "salty")
require.NoError(err)
defer os.RemoveAll(dir)
addr, err := ParseAddr(testAddr)
require.NoError(err)
fn := filepath.Join(dir, testIdentityPath)
ident1, err := CreateIdentity(WithIdentityAddr(addr), WithIdentityPath(fn))
require.NoError(err)
assert.NotNil(ident1.Key())
assert.Equal(addr.String(), ident1.Addr().String())
ident2, err := GetIdentity(WithIdentityAddr(addr), WithIdentityPath(fn))
require.NoError(err)
assert.NotNil(ident2.Key())
assert.Equal(addr.String(), ident2.Addr().String())
}