implement (and test) --output-file for receive-file
This commit is contained in:
parent
143d6dbc74
commit
5b46df133f
|
@ -9,6 +9,9 @@ def accept_file(args, them_d, w):
|
||||||
from .progress import start_progress, update_progress, finish_progress
|
from .progress import start_progress, update_progress, finish_progress
|
||||||
|
|
||||||
file_data = them_d["file"]
|
file_data = them_d["file"]
|
||||||
|
if args.output_file:
|
||||||
|
filename = args.output_file
|
||||||
|
else:
|
||||||
# the basename() is intended to protect us against
|
# the basename() is intended to protect us against
|
||||||
# "~/.ssh/authorized_keys" and other attacks
|
# "~/.ssh/authorized_keys" and other attacks
|
||||||
filename = os.path.basename(file_data["filename"]) # unicode
|
filename = os.path.basename(file_data["filename"]) # unicode
|
||||||
|
|
|
@ -119,6 +119,11 @@ class Scripts(ServerBase, ScriptsBase, unittest.TestCase):
|
||||||
return d1
|
return d1
|
||||||
|
|
||||||
def test_send_file_pre_generated_code(self):
|
def test_send_file_pre_generated_code(self):
|
||||||
|
return self._do_test_send_file_pre_generated_code(False)
|
||||||
|
def test_send_file_pre_generated_code_override(self):
|
||||||
|
return self._do_test_send_file_pre_generated_code(True)
|
||||||
|
|
||||||
|
def _do_test_send_file_pre_generated_code(self, override_filename):
|
||||||
self.maxDiff=None
|
self.maxDiff=None
|
||||||
code = u"1-abc"
|
code = u"1-abc"
|
||||||
filename = "testfile"
|
filename = "testfile"
|
||||||
|
@ -136,22 +141,26 @@ class Scripts(ServerBase, ScriptsBase, unittest.TestCase):
|
||||||
"--code", code,
|
"--code", code,
|
||||||
filename,
|
filename,
|
||||||
]
|
]
|
||||||
d1 = getProcessOutputAndValue(wormhole, send_args, path=send_dir)
|
|
||||||
|
|
||||||
receive_dir = self.mktemp()
|
receive_dir = self.mktemp()
|
||||||
os.mkdir(receive_dir)
|
os.mkdir(receive_dir)
|
||||||
receive_args = server_args + [
|
receive_args = server_args + [
|
||||||
"receive", "--accept-file",
|
"receive", "--accept-file",
|
||||||
code,
|
|
||||||
]
|
]
|
||||||
|
if override_filename:
|
||||||
|
receive_args.extend(["-o", "outfile"])
|
||||||
|
filename = "outfile"
|
||||||
|
receive_args.append(code)
|
||||||
|
|
||||||
|
d1 = getProcessOutputAndValue(wormhole, send_args, path=send_dir)
|
||||||
d2 = getProcessOutputAndValue(wormhole, receive_args, path=receive_dir)
|
d2 = getProcessOutputAndValue(wormhole, receive_args, path=receive_dir)
|
||||||
def _check_sender(res):
|
def _check_sender(res):
|
||||||
out, err, rc = res
|
out, err, rc = res
|
||||||
out = out.decode("utf-8")
|
out = out.decode("utf-8")
|
||||||
err = err.decode("utf-8")
|
err = err.decode("utf-8")
|
||||||
self.failUnlessEqual(err, "")
|
self.failUnlessEqual(err, "")
|
||||||
self.failUnlessIn("Sending %d byte file named '%s'\n" %
|
self.failUnlessIn("Sending %d byte file named 'testfile'\n" %
|
||||||
(len(message), filename), out)
|
len(message), out)
|
||||||
self.failUnlessIn("On the other computer, please run: "
|
self.failUnlessIn("On the other computer, please run: "
|
||||||
"wormhole receive\n"
|
"wormhole receive\n"
|
||||||
"Wormhole code is: %s\n\n" % code,
|
"Wormhole code is: %s\n\n" % code,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user