-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssh-keygen_test.go
69 lines (49 loc) · 1.35 KB
/
ssh-keygen_test.go
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSSHKeygenRsaWoPassword(t *testing.T) {
privBytes, pubBytes, err := sshKeygenRsa(2048, "")
assert.Nil(t, err)
agent, err := newSSHAgent()
assert.Nil(t, err)
err = agent.add(privBytes, "", "test ssh key", 30)
assert.Nil(t, err)
err = agent.delete(pubBytes)
assert.Nil(t, err)
}
func TestSSHKeygenRsa(t *testing.T) {
passwd, err := genPassword(32, true)
assert.Nil(t, err)
privBytes, pubBytes, err := sshKeygenRsa(2048, passwd)
assert.Nil(t, err)
agent, err := newSSHAgent()
assert.Nil(t, err)
err = agent.add(privBytes, passwd, "test ssh key", 30)
assert.Nil(t, err)
err = agent.delete(pubBytes)
assert.Nil(t, err)
}
func TestSSHKeygenEd25519WoPassword(t *testing.T) {
privBytes, pubBytes, err := sshKeygenEd25519("")
assert.Nil(t, err)
agent, err := newSSHAgent()
assert.Nil(t, err)
err = agent.add(privBytes, "", "test ssh key", 30)
assert.Nil(t, err)
err = agent.delete(pubBytes)
assert.Nil(t, err)
}
func TestSSHKeygenEd25519(t *testing.T) {
passwd, err := genPassword(32, true)
assert.Nil(t, err)
privBytes, pubBytes, err := sshKeygenEd25519(passwd)
assert.Nil(t, err)
agent, err := newSSHAgent()
assert.Nil(t, err)
err = agent.add(privBytes, passwd, "test ssh key", 30)
assert.Nil(t, err)
err = agent.delete(pubBytes)
assert.Nil(t, err)
}