mpd: Add 'config' command
This commit is contained in:
parent
ac537a63c7
commit
49d585a97c
@ -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)
|
||||
====================
|
||||
|
||||
@ -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 [
|
||||
|
||||
@ -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')
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user