aboutsummaryrefslogtreecommitdiff
path: root/client/keys_test.go
blob: d98a98211413bf1efec0430b5698539a71f2fdde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package client

import (
	"reflect"
	"testing"
)

func TestGenerateKeys(t *testing.T) {
	var tests = []struct {
		key  string
		size int
		want string
	}{
		{"ecdsa", 256, "*ecdsa.PrivateKey"},
		{"rsa", 1024, "*rsa.PrivateKey"},
		{"ed25519", 256, "*ed25519.PrivateKey"},
	}

	for _, tst := range tests {
		k, _, err := GenerateKey(tst.key, tst.size)
		if err != nil {
			t.Error(err)
		}
		if reflect.TypeOf(k).String() != tst.want {
			t.Errorf("Wrong key type returned. Got %T, wanted %s", k, tst.want)
		}
	}
}