def test01_test_SessionLogin(self):
        """ 
            Session.login test, one success and one failure
        """

        uname = pwd.getpwuid(os.getuid()).pw_name

        s = Session()
        s.login(['localhost', 'fakehost'], uname)
    def test04_exceptions(self, mock_stdout):
        """
        Test pxssh.login() exceptions
        """
        with mock.patch.object(pxssh.pxssh, "login", side_effect=pxssh.ExceptionPxssh("foo")) as mock_login:
            session1 = Session()
            session1.login(["localhost"], "gpadmin", 0.05, 1.0)
            self.assertEqual(mock_stdout.getvalue(), "[ERROR] unable to login to localhost\nfoo\n")
            mock_stdout.truncate(0)

        with mock.patch.object(pxssh.pxssh, "login", side_effect=pxssh.EOF("foo")) as mock_login:
            session2 = Session()
            session2.login(["localhost"], "gpadmin", 0.05, 1.0)
            self.assertEqual(
                mock_stdout.getvalue(), "[ERROR] unable to login to localhost\nCould not acquire connection.\n"
            )
            mock_stdout.truncate(0)

        with mock.patch.object(pxssh.pxssh, "login", side_effect=Exception("foo")) as mock_login:
            session2 = Session()
            session2.login(["localhost"], "gpadmin", 0.05, 1.0)
            self.assertEqual(
                mock_stdout.getvalue(),
                "[ERROR] unable to login to localhost\nhint: use gpssh-exkeys to setup public-key authentication between hosts\n",
            )
            mock_stdout.truncate(0)
Beispiel #3
0
    def test01_test_SessionLogin(self):
        """ 
            Session.login test, one success and one failure
        """

        uname = pwd.getpwuid(os.getuid()).pw_name

        s = Session()
        s.login(['localhost', 'fakehost'], uname)
        pxssh_hosts = [pxssh_session.x_peer for pxssh_session in s.pxssh_list]
        self.assertEqual(pxssh_hosts, ['localhost'])
Beispiel #4
0
    def test01_test_SessionLogin(self):
        """ 
            Session.login test, one success and one failure
        """

        uname = pwd.getpwuid(os.getuid()).pw_name

        s = Session()
        s.login(['localhost', 'fakehost'], uname)
        pxssh_hosts = [pxssh_session.x_peer for pxssh_session in s.pxssh_list]
        self.assertEqual(pxssh_hosts, ['localhost'])
Beispiel #5
0
    def test03_pxssh_sync_multiplier(self):
        '''
        test that sync_multiplier is changed properly
        '''
        with mock.patch.object(pxssh.pxssh, 'login', return_value=None) as mock_login:
            session1 = Session()
            session1.login(['localhost'], 'gpadmin', 0.05, 1.0)
            mock_login.assert_called_with('localhost', 'gpadmin', sync_multiplier=1.0)

            session2 = Session()
            session2.login(['localhost'], 'gpadmin', 1.0, 4.0)
            mock_login.assert_called_with('localhost', 'gpadmin', sync_multiplier=4.0)
Beispiel #6
0
    def test03_pxssh_sync_multiplier(self):
        '''
        test that sync_multiplier is changed properly
        '''
        with mock.patch.object(pxssh.pxssh, 'login', return_value=None) as mock_login:
            session1 = Session()
            session1.login(['localhost'], 'gpadmin', 0.05, 1.0)
            mock_login.assert_called_with('localhost', 'gpadmin', sync_multiplier=1.0)

            session2 = Session()
            session2.login(['localhost'], 'gpadmin', 1.0, 4.0)
            mock_login.assert_called_with('localhost', 'gpadmin', sync_multiplier=4.0)
    def test03_pxssh_sync_multiplier(self):
        """
        test that sync_multiplier is changed properly
        """
        with mock.patch.object(pxssh.pxssh, "login", return_value=None) as mock_login:
            session1 = Session()
            session1.login(["localhost"], "gpadmin", 0.05, 1.0)
            mock_login.assert_called_with("localhost", "gpadmin", sync_multiplier=1.0)

            session2 = Session()
            session2.login(["localhost"], "gpadmin", 1.0, 4.0)
            mock_login.assert_called_with("localhost", "gpadmin", sync_multiplier=4.0)
Beispiel #8
0
    def test04_exceptions(self, mock_stdout):
        '''
        Test pxssh.login() exceptions
        '''
        with mock.patch.object(
                pxssh.pxssh, 'login',
                side_effect=pxssh.ExceptionPxssh('foo')) as mock_login:
            session1 = Session()
            session1.login(['localhost'], 'gpadmin', 0.05, 1.0)
            self.assertEqual(mock_stdout.getvalue(),
                             '[ERROR] unable to login to localhost\nfoo\n')
            mock_stdout.truncate(0)

        with mock.patch.object(pxssh.pxssh,
                               'login',
                               side_effect=pxssh.EOF('foo')) as mock_login:
            session2 = Session()
            session2.login(['localhost'], 'gpadmin', 0.05, 1.0)
            self.assertEqual(
                mock_stdout.getvalue(),
                '[ERROR] unable to login to localhost\nCould not acquire connection.\n'
            )
            mock_stdout.truncate(0)

        with mock.patch.object(pxssh.pxssh,
                               'login',
                               side_effect=Exception('foo')) as mock_login:
            session2 = Session()
            session2.login(['localhost'], 'gpadmin', 0.05, 1.0)
            self.assertEqual(
                mock_stdout.getvalue(),
                '[ERROR] unable to login to localhost\nhint: use gpssh-exkeys to setup public-key authentication between hosts\n'
            )
            mock_stdout.truncate(0)