diff --git a/docs/changes.rst b/docs/changes.rst index 8de66e45..6f15ff20 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -12,6 +12,8 @@ v0.11.0 (in development) - Add support for ``seekcur`` command added in MPD 0.17. +- Add support for ``config`` command added in MPD 0.17. + v0.10.0 (2012-12-12) ==================== diff --git a/mopidy/frontends/mpd/protocol/reflection.py b/mopidy/frontends/mpd/protocol/reflection.py index d9c35743..cc1c7222 100644 --- a/mopidy/frontends/mpd/protocol/reflection.py +++ b/mopidy/frontends/mpd/protocol/reflection.py @@ -1,8 +1,23 @@ from __future__ import unicode_literals +from mopidy.frontends.mpd.exceptions import MpdPermissionError from mopidy.frontends.mpd.protocol import handle_request, mpd_commands +@handle_request(r'^config$', auth_required=False) +def config(context): + """ + *musicpd.org, reflection section:* + + ``config`` + + Dumps configuration values that may be interesting for the client. This + command is only permitted to "local" clients (connected via UNIX domain + socket). + """ + raise MpdPermissionError(command='config') + + @handle_request(r'^commands$', auth_required=False) def commands(context): """ @@ -19,10 +34,10 @@ def commands(context): command.name for command in mpd_commands if not command.auth_required]) - # No one is permited to use kill, rest of commands are not listed by MPD, - # so we shouldn't either. + # No one is permited to use 'config' or 'kill', rest of commands are not + # listed by MPD, so we shouldn't either. command_names = command_names - set([ - 'kill', 'command_list_begin', 'command_list_ok_begin', + 'config', 'kill', 'command_list_begin', 'command_list_ok_begin', 'command_list_ok_begin', 'command_list_end', 'idle', 'noidle', 'sticker']) @@ -73,6 +88,7 @@ def notcommands(context): command.name for command in mpd_commands if command.auth_required] # No permission to use + command_names.append('config') command_names.append('kill') return [ diff --git a/tests/frontends/mpd/protocol/reflection_test.py b/tests/frontends/mpd/protocol/reflection_test.py index 9c07f104..f2720473 100644 --- a/tests/frontends/mpd/protocol/reflection_test.py +++ b/tests/frontends/mpd/protocol/reflection_test.py @@ -6,6 +6,11 @@ from tests.frontends.mpd import protocol class ReflectionHandlerTest(protocol.BaseTestCase): + def test_config_is_not_allowed_across_the_network(self): + self.sendRequest('config') + self.assertEqualResponse( + 'ACK [4@0] {config} you don\'t have permission for "config"') + def test_commands_returns_list_of_all_commands(self): self.sendRequest('commands') # Check if some random commands are included @@ -13,6 +18,7 @@ class ReflectionHandlerTest(protocol.BaseTestCase): self.assertInResponse('command: play') self.assertInResponse('command: status') # Check if commands you do not have access to are not present + self.assertNotInResponse('command: config') self.assertNotInResponse('command: kill') # Check if the blacklisted commands are not present self.assertNotInResponse('command: command_list_begin') @@ -40,9 +46,10 @@ class ReflectionHandlerTest(protocol.BaseTestCase): self.sendRequest('decoders') self.assertInResponse('OK') - def test_notcommands_returns_only_kill_and_ok(self): + def test_notcommands_returns_only_config_and_kill_and_ok(self): response = self.sendRequest('notcommands') - self.assertEqual(2, len(response)) + self.assertEqual(3, len(response)) + self.assertInResponse('command: config') self.assertInResponse('command: kill') self.assertInResponse('OK')