Python3 compat and add timeout for connect
This commit is contained in:
@@ -5,8 +5,9 @@ Tests for baresshd.py
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import pexpect
|
from mininet.util import pexpect
|
||||||
from mininet.clean import cleanup, sh
|
from mininet.clean import cleanup, sh
|
||||||
|
from sys import stdout
|
||||||
|
|
||||||
class testBareSSHD( unittest.TestCase ):
|
class testBareSSHD( unittest.TestCase ):
|
||||||
|
|
||||||
@@ -14,7 +15,9 @@ class testBareSSHD( unittest.TestCase ):
|
|||||||
|
|
||||||
def connected( self ):
|
def connected( self ):
|
||||||
"Log into ssh server, check banner, then exit"
|
"Log into ssh server, check banner, then exit"
|
||||||
p = pexpect.spawn( 'ssh 10.0.0.1 -o StrictHostKeyChecking=no -i /tmp/ssh/test_rsa exit' )
|
p = pexpect.spawn( 'ssh 10.0.0.1 -o ConnectTimeout=1 '
|
||||||
|
'-o StrictHostKeyChecking=no '
|
||||||
|
'-i /tmp/ssh/test_rsa exit' )
|
||||||
while True:
|
while True:
|
||||||
index = p.expect( self.opts )
|
index = p.expect( self.opts )
|
||||||
if index == 0:
|
if index == 0:
|
||||||
@@ -22,6 +25,7 @@ class testBareSSHD( unittest.TestCase ):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def setUp( self ):
|
def setUp( self ):
|
||||||
# verify that sshd is not running
|
# verify that sshd is not running
|
||||||
self.assertFalse( self.connected() )
|
self.assertFalse( self.connected() )
|
||||||
|
|||||||
Reference in New Issue
Block a user