Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
af6812b4
Commit
af6812b4
authored
Sep 29, 2017
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix context naming for sudo and via=.
parent
976c643f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
1 deletion
+52
-1
mitogen/master.py
mitogen/master.py
+1
-1
mitogen/sudo.py
mitogen/sudo.py
+3
-0
tests/local_test.py
tests/local_test.py
+23
-0
tests/ssh_test.py
tests/ssh_test.py
+25
-0
No files found.
mitogen/master.py
View file @
af6812b4
...
...
@@ -977,8 +977,8 @@ class Router(mitogen.core.Router):
name
=
via_context
.
call
(
_proxy_connect
,
name
,
context_id
,
method_name
,
kwargs
)
name
=
'%s.%s'
%
(
via_context
.
name
,
name
)
# name = '%s.%s' % (via_context.name, name)
context
=
Context
(
self
,
context_id
,
name
=
name
)
context
.
via
=
via_context
self
.
_context_by_id
[
context
.
context_id
]
=
context
...
...
mitogen/sudo.py
View file @
af6812b4
...
...
@@ -51,6 +51,9 @@ class Stream(mitogen.master.Stream):
self
.
sudo_path
=
sudo_path
if
password
:
self
.
password
=
password
def
connect
(
self
):
super
(
Stream
,
self
).
connect
()
self
.
name
=
'sudo.'
+
self
.
username
def
get_boot_command
(
self
):
...
...
tests/local_test.py
0 → 100644
View file @
af6812b4
import
os
import
unittest
import
mitogen
import
mitogen.ssh
import
mitogen.utils
import
testlib
import
plain_old_module
class
LocalTest
(
testlib
.
RouterMixin
,
unittest
.
TestCase
):
stream_class
=
mitogen
.
ssh
.
Stream
def
test_stream_name
(
self
):
context
=
self
.
router
.
local
()
pid
=
context
.
call
(
os
.
getpid
)
self
.
assertEquals
(
'local.%d'
%
(
pid
,),
context
.
name
)
if
__name__
==
'__main__'
:
unittest
.
main
()
tests/ssh_test.py
View file @
af6812b4
...
...
@@ -24,6 +24,27 @@ class FakeSshTest(testlib.RouterMixin, unittest.TestCase):
class
SshTest
(
testlib
.
DockerMixin
,
unittest
.
TestCase
):
stream_class
=
mitogen
.
ssh
.
Stream
def
test_stream_name
(
self
):
context
=
self
.
docker_ssh
(
username
=
'has-sudo'
,
password
=
'y'
,
)
self
.
assertEquals
(
'ssh.u1704:%s'
%
(
self
.
dockerized_ssh
.
port
,),
context
.
name
)
def
test_via_stream_name
(
self
):
context
=
self
.
docker_ssh
(
username
=
'has-sudo-nopw'
,
password
=
'y'
,
)
sudo
=
self
.
router
.
sudo
(
via
=
context
)
name
=
'ssh.%s:%s.sudo.root'
%
(
self
.
dockerized_ssh
.
host
,
self
.
dockerized_ssh
.
port
,
)
self
.
assertEquals
(
name
,
sudo
.
name
)
def
test_password_required
(
self
):
try
:
context
=
self
.
docker_ssh
(
...
...
@@ -74,3 +95,7 @@ class SshTest(testlib.DockerMixin, unittest.TestCase):
)
sentinel
=
'i-am-mitogen-test-docker-image
\
n
'
assert
sentinel
==
context
.
call
(
plain_old_module
.
get_sentinel_value
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment