예제 #1
0
 def __init__(self, host, port, username, password):
     self.device = SSHArchDevice(host, port, username,
                                 password)  # Unbridged
     self.connection = None
     self.responder = None
     self.result = None
     self.stdout = ""
     self.stderr = ""
예제 #2
0
    def test_connect_ssh(self):
        """Tests the main function of connecting through SSH."""
        TEST_LOG.info("SSH connection")
        test_dev = SSHArchDevice(host, port, username, password)

        test_dev._connect_ssh()

        self.assertIsNotNone(test_dev.ssh)
예제 #3
0
    def test_execute_list(self):
        """Test send a command."""
        test_dev = SSHArchDevice(host, port, username, password)
        res = test_dev.execute(["uname -a", "whoami", "free -hg"])
        self.assertIn("GNU/Linux", res)

        test_dev.add_root_password('root')
        res = test_dev.execute(["uname -a", "whoami", "free -hg"], su=True)
        self.assertIn("GNU/Linux", res)
예제 #4
0
    def test_execute(self):
        """Test send a command."""
        test_dev = SSHArchDevice(host, port, username, password)
        res = test_dev.execute("whoami")
        self.assertIn("alarm", res)

        test_dev.add_root_password('root')
        res = test_dev.execute("whoami", su=True)
        self.assertIn("root", res)
예제 #5
0
    def test_bind_unbind(self):
        """Tests the main function of connecting through SSH."""
        TEST_LOG.info("SSH channel close connection")
        test_dev = SSHArchDevice(host, port, username, password)

        self.assertIsNone(test_dev.ssh)
        self.assertIsNone(test_dev.channel)

        test_dev.bind()
        self.assertIsNotNone(test_dev.ssh)
        self.assertIsNotNone(test_dev.channel)

        test_dev.unbind()
        self.assertIsNone(test_dev.ssh)
        self.assertIsNone(test_dev.channel)