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
01c0ef00
Commit
01c0ef00
authored
11 years ago
by
Brian O'Connor
Browse files
Options
Downloads
Patches
Plain Diff
added comments to test_baresshd.py
parent
a46fae06
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_baresshd.py
+9
-6
9 additions, 6 deletions
examples/test/test_baresshd.py
with
9 additions
and
6 deletions
examples/test/test_baresshd.py
+
9
−
6
View file @
01c0ef00
#!/usr/bin/env python
"""
TEST
"""
"""
Tests for baresshd.py
"""
import
unittest
import
pexpect
...
...
@@ -9,13 +11,12 @@
from
mininet.clean
import
cleanup
,
sh
class
testBareSSHD
(
unittest
.
TestCase
):
"
Test ping with single switch topology (common code).
"
opts
=
[
'
\(yes/no\)\?
'
,
'
Welcome to h1
'
,
'
refused
'
,
pexpect
.
EOF
,
pexpect
.
TIMEOUT
]
def
connected
(
self
):
"
check
co
nne
cted
"
p
=
pexpect
.
spawn
(
'
ssh 10.0.0.1 -i /tmp/ssh/test_rsa
'
)
"
Log into ssh server,
check
ba
nne
r, then exit
"
p
=
pexpect
.
spawn
(
'
ssh 10.0.0.1 -i /tmp/ssh/test_rsa
exit
'
)
while
True
:
index
=
p
.
expect
(
self
.
opts
)
if
index
==
0
:
...
...
@@ -26,19 +27,22 @@ def connected( self ):
return
False
def
setUp
(
self
):
# verify that sshd is not running
self
.
assertFalse
(
self
.
connected
()
)
# create public key pair for testing
sh
(
'
mkdir /tmp/ssh
'
)
sh
(
"
ssh-keygen -t rsa -P
''
-f /tmp/ssh/test_rsa
"
)
sh
(
'
cat /tmp/ssh/test_rsa.pub >> /tmp/ssh/authorized_keys
'
)
# run example with custom sshd args
cmd
=
(
'
python -m mininet.examples.baresshd
'
'
-o AuthorizedKeysFile=/tmp/ssh/authorized_keys
'
'
-o StrictModes=no
'
)
sh
(
cmd
)
def
testSSH
(
self
):
"
Simple test to verify that we can ssh into h1
"
result
=
False
# try to connect up to 3 times
# try to connect up to 3 times
; sshd can take a while to start
for
_
in
range
(
3
):
result
=
self
.
connected
()
if
result
:
...
...
@@ -54,7 +58,6 @@ def tearDown( self ):
# remove public key pair
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