Make gitosis-serve not fail with commands without arguments.
This commit is contained in:
parent
8a0654abe2
commit
82f5857759
2 changed files with 17 additions and 1 deletions
|
@ -54,7 +54,11 @@ def serve(
|
|||
if '\n' in command:
|
||||
raise CommandMayNotContainNewlineError()
|
||||
|
||||
verb, args = command.split(None, 1)
|
||||
try:
|
||||
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
|
||||
and verb not in COMMANDS_READONLY):
|
||||
|
|
|
@ -21,6 +21,18 @@ def test_bad_newLine():
|
|||
eq(str(e), 'Command may not contain newline')
|
||||
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():
|
||||
cfg = RawConfigParser()
|
||||
e = assert_raises(
|
||||
|
|
Loading…
Reference in a new issue