Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olaf Bergmann
mininet
Commits
48c49c54
Commit
48c49c54
authored
11 years ago
by
Brian O'Connor
Browse files
Options
Downloads
Patches
Plain Diff
cleaned up and commented test_sshd.py
parent
d4993c0b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/test/test_sshd.py
+12
-9
12 additions, 9 deletions
examples/test/test_sshd.py
with
12 additions
and
9 deletions
examples/test/test_sshd.py
+
12
−
9
View file @
48c49c54
#!/usr/bin/env python
"""
TEST
"""
"""
Test for sshd.py
"""
import
unittest
import
pexpect
from
time
import
sleep
from
mininet.log
import
setLogLevel
from
mininet.clean
import
cleanup
,
sh
from
mininet.clean
import
sh
class
testBareSSHD
(
unittest
.
TestCase
):
"
Test ping with single switch topology (common code).
"
class
testSSHD
(
unittest
.
TestCase
):
opts
=
[
'
\(yes/no\)\?
'
,
'
refused
'
,
'
Welcome
'
,
pexpect
.
EOF
,
pexpect
.
TIMEOUT
]
opts
=
[
'
\(yes/no\)\?
'
,
'
refused
'
,
'
Welcome
|\$|#
'
,
pexpect
.
EOF
,
pexpect
.
TIMEOUT
]
def
connected
(
self
,
ip
):
"
check connected
"
p
=
pexpect
.
spawn
(
'
ssh -i /tmp/ssh/test_rsa %s
'
%
ip
)
"
Log into ssh server, check banner, then exit
"
# Note: this test will fail if "Welcome" is not in the sshd banner
# and '#'' or '$'' are not in the prompt
p
=
pexpect
.
spawn
(
'
ssh -i /tmp/ssh/test_rsa %s
'
%
ip
,
timeout
=
10
)
while
True
:
index
=
p
.
expect
(
self
.
opts
)
if
index
==
0
:
...
...
@@ -38,10 +40,12 @@ def setUp( self ):
cmd
=
(
'
python -m mininet.examples.sshd -D
'
'
-o AuthorizedKeysFile=/tmp/ssh/authorized_keys
'
'
-o StrictModes=no
'
)
# run example with custom sshd args
self
.
net
=
pexpect
.
spawn
(
cmd
)
self
.
net
.
expect
(
'
mininet>
'
)
def
testSSH
(
self
):
"
Verify that we can ssh into all hosts (h1 to h4)
"
for
h
in
range
(
1
,
5
):
self
.
assertTrue
(
self
.
connected
(
'
10.0.0.%d
'
%
h
)
)
...
...
@@ -52,6 +56,5 @@ def tearDown( self ):
sh
(
'
rm -rf /tmp/ssh
'
)
if
__name__
==
'
__main__
'
:
setLogLevel
(
'
warning
'
)
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment