From 7f7d79b21fa0721b7b645c957c35c0f891bfe36d Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 3 Jun 2011 23:31:52 +0200 Subject: [PATCH] Return permission error on use of MPD command 'kill' --- mopidy/frontends/mpd/protocol/connection.py | 7 +++---- tests/frontends/mpd/connection_test.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/mopidy/frontends/mpd/protocol/connection.py b/mopidy/frontends/mpd/protocol/connection.py index 2b030eb0..5722a83c 100644 --- a/mopidy/frontends/mpd/protocol/connection.py +++ b/mopidy/frontends/mpd/protocol/connection.py @@ -1,6 +1,7 @@ from mopidy import settings from mopidy.frontends.mpd.protocol import handle_pattern -from mopidy.frontends.mpd.exceptions import MpdPasswordError +from mopidy.frontends.mpd.exceptions import (MpdPasswordError, + MpdPermissionError) @handle_pattern(r'^close$') def close(context): @@ -22,9 +23,7 @@ def kill(context): Kills MPD. """ - # TODO We do not want to allow remote killing of Mopidy. We should throw an - # MPD exception here. Maybe using ACK_ERROR_PERMISSION. - pass + raise MpdPermissionError(command=u'kill') @handle_pattern(r'^password "(?P[^"]+)"$') def password_(context, password): diff --git a/tests/frontends/mpd/connection_test.py b/tests/frontends/mpd/connection_test.py index 84794257..bc995a5e 100644 --- a/tests/frontends/mpd/connection_test.py +++ b/tests/frontends/mpd/connection_test.py @@ -31,7 +31,7 @@ class ConnectionHandlerTest(unittest.TestCase): def test_kill(self): result = self.dispatcher.handle_request(u'kill') - self.assert_(u'OK' in result) + self.assert_(u'ACK [4@0] {kill} you don\'t have permission for "kill"' in result) def test_valid_password_is_accepted(self): settings.MPD_SERVER_PASSWORD = u'topsecret'