-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_KeeAgent.py
executable file
·95 lines (70 loc) · 3.09 KB
/
test_KeeAgent.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/env python
# -*- coding: utf-8 -*-
import os
import unittest
from SshAgent import SshAgentClient
from KeeAgent import SshEntry
from pykeepass import PyKeePass
os.chdir('./testdata/')
class TestSshEntries(unittest.TestCase):
def setUp(self):
self.kdb = PyKeePass('./keys.kdbx','1234')
self.agent = SshAgentClient()
def tearDown(self):
self.agent.close()
def test_embedded_rsa(self):
entry = self.kdb.find_entries_by_path('embedded_keys/id_rsa')[0]
ssh_entry = SshEntry(self.kdb,entry)
private_key = ssh_entry.private_key
self.agent.add_key(private_key)
self.assertTrue(self.agent.is_key_active(private_key))
def test_embedded_dsa(self):
entry = self.kdb.find_entries_by_path('embedded_keys/id_dsa')[0]
ssh_entry = SshEntry(self.kdb,entry)
private_key = ssh_entry.private_key
self.agent.add_key(private_key)
self.assertTrue(self.agent.is_key_active(private_key))
def test_embedded_ecdsa(self):
entry = self.kdb.find_entries_by_path('embedded_keys/id_ecdsa')[0]
ssh_entry = SshEntry(self.kdb,entry)
private_key = ssh_entry.private_key
self.agent.add_key(private_key)
self.assertTrue(self.agent.is_key_active(private_key))
def test_file_rsa(self):
entry = self.kdb.find_entries_by_path('file_keys/id_rsa')[0]
ssh_entry = SshEntry(self.kdb,entry)
private_key = ssh_entry.private_key
self.agent.add_key(private_key)
self.assertTrue(self.agent.is_key_active(private_key))
def test_file_dsa(self):
entry = self.kdb.find_entries_by_path('file_keys/id_dsa')[0]
ssh_entry = SshEntry(self.kdb,entry)
private_key = ssh_entry.private_key
self.agent.add_key(private_key)
self.assertTrue(self.agent.is_key_active(private_key))
def test_file_ecdsa(self):
entry = self.kdb.find_entries_by_path('file_keys/id_ecdsa')[0]
ssh_entry = SshEntry(self.kdb,entry)
private_key = ssh_entry.private_key
self.agent.add_key(private_key)
self.assertTrue(self.agent.is_key_active(private_key))
def test_passwordless_rsa(self):
entry = self.kdb.find_entries_by_path('without_passphrase/id_rsa')[0]
ssh_entry = SshEntry(self.kdb,entry)
private_key = ssh_entry.private_key
self.agent.add_key(private_key)
self.assertTrue(self.agent.is_key_active(private_key))
def test_passwordless_dsa(self):
entry = self.kdb.find_entries_by_path('without_passphrase/id_dsa')[0]
ssh_entry = SshEntry(self.kdb,entry)
private_key = ssh_entry.private_key
self.agent.add_key(private_key)
self.assertTrue(self.agent.is_key_active(private_key))
def test_passwordless_ecdsa(self):
entry = self.kdb.find_entries_by_path('without_passphrase/id_ecdsa')[0]
ssh_entry = SshEntry(self.kdb,entry)
private_key = ssh_entry.private_key
self.agent.add_key(private_key)
self.assertTrue(self.agent.is_key_active(private_key))
if __name__ == '__main__':
unittest.main()