root / test / ganeti.ssh_unittest.py @ d357f531
History | View | Annotate | Download (1.4 kB)
1 | 75a5f456 | Michael Hanselmann | #!/usr/bin/python
|
---|---|---|---|
2 | 75a5f456 | Michael Hanselmann | #
|
3 | 75a5f456 | Michael Hanselmann | |
4 | 75a5f456 | Michael Hanselmann | # Copyright (C) 2006, 2007, 2008 Google Inc.
|
5 | 75a5f456 | Michael Hanselmann | #
|
6 | 75a5f456 | Michael Hanselmann | # This program is free software; you can redistribute it and/or modify
|
7 | 75a5f456 | Michael Hanselmann | # it under the terms of the GNU General Public License as published by
|
8 | 75a5f456 | Michael Hanselmann | # the Free Software Foundation; either version 2 of the License, or
|
9 | 75a5f456 | Michael Hanselmann | # (at your option) any later version.
|
10 | 75a5f456 | Michael Hanselmann | #
|
11 | 75a5f456 | Michael Hanselmann | # This program is distributed in the hope that it will be useful, but
|
12 | 75a5f456 | Michael Hanselmann | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 75a5f456 | Michael Hanselmann | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 75a5f456 | Michael Hanselmann | # General Public License for more details.
|
15 | 75a5f456 | Michael Hanselmann | #
|
16 | 75a5f456 | Michael Hanselmann | # You should have received a copy of the GNU General Public License
|
17 | 75a5f456 | Michael Hanselmann | # along with this program; if not, write to the Free Software
|
18 | 75a5f456 | Michael Hanselmann | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 | 75a5f456 | Michael Hanselmann | # 02110-1301, USA.
|
20 | 75a5f456 | Michael Hanselmann | |
21 | 75a5f456 | Michael Hanselmann | |
22 | 75a5f456 | Michael Hanselmann | """Script for unittesting the ssh module"""
|
23 | 75a5f456 | Michael Hanselmann | |
24 | 75a5f456 | Michael Hanselmann | import os |
25 | 75a5f456 | Michael Hanselmann | import tempfile |
26 | 75a5f456 | Michael Hanselmann | import unittest |
27 | 75a5f456 | Michael Hanselmann | |
28 | 75a5f456 | Michael Hanselmann | import testutils |
29 | 75a5f456 | Michael Hanselmann | import mocks |
30 | 75a5f456 | Michael Hanselmann | |
31 | 75a5f456 | Michael Hanselmann | from ganeti import constants |
32 | 75a5f456 | Michael Hanselmann | from ganeti import utils |
33 | 75a5f456 | Michael Hanselmann | from ganeti import ssh |
34 | 75a5f456 | Michael Hanselmann | |
35 | 75a5f456 | Michael Hanselmann | |
36 | 75a5f456 | Michael Hanselmann | class TestKnownHosts(testutils.GanetiTestCase): |
37 | 75a5f456 | Michael Hanselmann | """Test case for function writing the known_hosts file"""
|
38 | 75a5f456 | Michael Hanselmann | |
39 | 75a5f456 | Michael Hanselmann | def setUp(self): |
40 | 51596eb2 | Iustin Pop | testutils.GanetiTestCase.setUp(self)
|
41 | 51596eb2 | Iustin Pop | self.tmpfile = self._CreateTempFile() |
42 | 75a5f456 | Michael Hanselmann | |
43 | 75a5f456 | Michael Hanselmann | def test(self): |
44 | 75a5f456 | Michael Hanselmann | cfg = mocks.FakeConfig() |
45 | 51596eb2 | Iustin Pop | ssh.WriteKnownHostsFile(cfg, self.tmpfile)
|
46 | 51596eb2 | Iustin Pop | self.assertFileContent(self.tmpfile, |
47 | 7688d0d3 | Michael Hanselmann | "%s ssh-rsa %s\n" % (cfg.GetClusterName(),
|
48 | 75a5f456 | Michael Hanselmann | mocks.FAKE_CLUSTER_KEY)) |
49 | 75a5f456 | Michael Hanselmann | |
50 | 75a5f456 | Michael Hanselmann | |
51 | 75a5f456 | Michael Hanselmann | if __name__ == '__main__': |
52 | 75a5f456 | Michael Hanselmann | unittest.main() |