Make gitosis-serve not fail with commands without arguments.

This commit is contained in:
Tommi Virtanen 2007-09-03 17:06:49 -07:00
parent 8a0654abe2
commit 82f5857759
2 changed files with 17 additions and 1 deletions

View file

@ -54,7 +54,11 @@ def serve(
if '\n' in command: if '\n' in command:
raise CommandMayNotContainNewlineError() raise CommandMayNotContainNewlineError()
try:
verb, args = command.split(None, 1) verb, args = command.split(None, 1)
except ValueError:
# all known commands take one argument; improve if/when needed
raise UnknownCommandError()
if (verb not in COMMANDS_WRITE if (verb not in COMMANDS_WRITE
and verb not in COMMANDS_READONLY): and verb not in COMMANDS_READONLY):

View file

@ -21,6 +21,18 @@ def test_bad_newLine():
eq(str(e), 'Command may not contain newline') eq(str(e), 'Command may not contain newline')
assert isinstance(e, serve.ServingError) assert isinstance(e, serve.ServingError)
def test_bad_nospace():
cfg = RawConfigParser()
e = assert_raises(
serve.UnknownCommandError,
serve.serve,
cfg=cfg,
user='jdoe',
command='git-upload-pack',
)
eq(str(e), 'Unknown command denied')
assert isinstance(e, serve.ServingError)
def test_bad_command(): def test_bad_command():
cfg = RawConfigParser() cfg = RawConfigParser()
e = assert_raises( e = assert_raises(