forked from ParallelSSH/parallel-ssh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_host_config.py
104 lines (98 loc) · 4.84 KB
/
test_host_config.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
96
97
98
99
100
101
102
103
104
# This file is part of parallel-ssh.
#
# Copyright (C) 2014-2022 Panos Kittenis and contributors.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, version 2.1.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import unittest
from pssh.config import HostConfig
class TestHostConfig(unittest.TestCase):
def test_host_config_entries(self):
user = 'user'
port = 22
password = 'password'
alias = 'alias'
private_key = 'private key'
allow_agent = False
num_retries = 1
retry_delay = 1
timeout = 1
identity_auth = False
proxy_host = 'proxy_host'
keepalive_seconds = 1
ipv6_only = True
cert_file = 'file'
auth_thread_pool = True
forward_ssh_agent = False
gssapi_auth = True
gssapi_server_identity = 'some_id'
gssapi_client_identity = 'some_id'
gssapi_delegate_credentials = True
cfg = HostConfig(
user=user, port=port, password=password, alias=alias, private_key=private_key,
allow_agent=allow_agent, num_retries=num_retries, retry_delay=retry_delay,
timeout=timeout, identity_auth=identity_auth, proxy_host=proxy_host,
ipv6_only=ipv6_only,
keepalive_seconds=keepalive_seconds,
cert_file=cert_file,
auth_thread_pool=auth_thread_pool,
forward_ssh_agent=forward_ssh_agent,
gssapi_auth=gssapi_auth,
gssapi_server_identity=gssapi_server_identity,
gssapi_client_identity=gssapi_client_identity,
gssapi_delegate_credentials=gssapi_delegate_credentials,
)
self.assertEqual(cfg.user, user)
self.assertEqual(cfg.port, port)
self.assertEqual(cfg.password, password)
self.assertEqual(cfg.alias, alias)
self.assertEqual(cfg.private_key, private_key)
self.assertEqual(cfg.allow_agent, allow_agent)
self.assertEqual(cfg.num_retries, num_retries)
self.assertEqual(cfg.retry_delay, retry_delay)
self.assertEqual(cfg.timeout, timeout)
self.assertEqual(cfg.identity_auth, identity_auth)
self.assertEqual(cfg.proxy_host, proxy_host)
self.assertEqual(cfg.ipv6_only, ipv6_only)
self.assertEqual(cfg.keepalive_seconds, keepalive_seconds)
self.assertEqual(cfg.cert_file, cert_file)
self.assertEqual(cfg.forward_ssh_agent, forward_ssh_agent)
self.assertEqual(cfg.gssapi_auth, gssapi_auth)
self.assertEqual(cfg.gssapi_server_identity, gssapi_server_identity)
self.assertEqual(cfg.gssapi_client_identity, gssapi_client_identity)
self.assertEqual(cfg.gssapi_delegate_credentials, gssapi_delegate_credentials)
def test_host_config_bad_entries(self):
self.assertRaises(ValueError, HostConfig, user=22)
self.assertRaises(ValueError, HostConfig, password=22)
self.assertRaises(ValueError, HostConfig, port='22')
self.assertRaises(ValueError, HostConfig, alias=2)
self.assertRaises(ValueError, HostConfig, private_key=1)
self.assertRaises(ValueError, HostConfig, allow_agent=1)
self.assertRaises(ValueError, HostConfig, num_retries='')
self.assertRaises(ValueError, HostConfig, retry_delay='')
self.assertRaises(ValueError, HostConfig, timeout='')
self.assertRaises(ValueError, HostConfig, identity_auth='')
self.assertRaises(ValueError, HostConfig, proxy_host=1)
self.assertRaises(ValueError, HostConfig, proxy_port='')
self.assertRaises(ValueError, HostConfig, proxy_user=1)
self.assertRaises(ValueError, HostConfig, proxy_password=1)
self.assertRaises(ValueError, HostConfig, proxy_pkey=1)
self.assertRaises(ValueError, HostConfig, keepalive_seconds='')
self.assertRaises(ValueError, HostConfig, ipv6_only='')
self.assertRaises(ValueError, HostConfig, keepalive_seconds='')
self.assertRaises(ValueError, HostConfig, cert_file=1)
self.assertRaises(ValueError, HostConfig, forward_ssh_agent='')
self.assertRaises(ValueError, HostConfig, gssapi_auth='')
self.assertRaises(ValueError, HostConfig, gssapi_server_identity=1)
self.assertRaises(ValueError, HostConfig, gssapi_client_identity=1)
self.assertRaises(ValueError, HostConfig, gssapi_delegate_credentials='')