-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_orthrus_ssh_key_manager.rb
77 lines (56 loc) · 1.23 KB
/
test_orthrus_ssh_key_manager.rb
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
70
71
72
73
74
75
76
77
require 'minitest/unit'
require 'minitest/autorun'
require 'orthrus/ssh/key_manager'
require 'orthrus_case'
class TestOrthrusSSHKeyManager < OrthrusTestCase
def setup
super
@kg = Orthrus::SSH::KeyManager.new
end
def test_add_key
@kg.add_key @rsa
assert_equal @rsa, @kg.keys.first
end
def test_load_key
@kg.load_key @id_rsa
assert_equal @rsa, @kg.keys.first
end
def test_agent_identities
kg = @kg.agent_identities.first
assert_kind_of Orthrus::SSH::Key, kg
end
def test_each_key
@kg.add_key @rsa
keys = []
@kg.each_key { |x| keys << x }
assert keys.include?(@rsa)
end
def test_each_keys_with_agent
keys = []
added_to_agent @id_rsa do
@kg.each_key { |x| keys << x }
end
assert keys.include?(@rsa_pub)
end
def test_sign
@kg.add_key @rsa
data = "hello"
sign = @kg.sign @rsa, data
assert @rsa_pub.verify(sign, data)
end
def test_sign_with_agent
added_to_agent @id_rsa do
data = "hello"
id = nil
@kg.each_key do |k|
if k == @rsa_pub
id = k
break
end
end
assert id
sign = @kg.sign id, data
assert @rsa_pub.verify(sign, data)
end
end
end