diff options
| -rw-r--r-- | src/mailman/docs/NEWS.rst | 2 | ||||
| -rw-r--r-- | src/mailman/rest/docs/basic.rst | 14 | ||||
| -rw-r--r-- | src/mailman/rest/root.py | 11 | ||||
| -rw-r--r-- | src/mailman/rest/tests/test_root.py | 20 |
4 files changed, 34 insertions, 13 deletions
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst index 9eb7c0832..a219038eb 100644 --- a/src/mailman/docs/NEWS.rst +++ b/src/mailman/docs/NEWS.rst @@ -74,6 +74,8 @@ REST optional 'auto_create' flag), and PUT to link the address to a different user. It also supports DELETE to unlink the address. (LP: #1312884) Given by Aurélien Bompard based on work by Nicolas Karageuzian. + * The ``/3.0/system`` path is deprecated; use ``/3.0/system/versions`` to get + the system version information. 3.0 beta 4 -- "Time and Motion" diff --git a/src/mailman/rest/docs/basic.rst b/src/mailman/rest/docs/basic.rst index 576aacc2c..7e013f598 100644 --- a/src/mailman/rest/docs/basic.rst +++ b/src/mailman/rest/docs/basic.rst @@ -29,23 +29,23 @@ succeeds. ... 'Content-Type': 'application/x-www-form-urlencode', ... 'Authorization': 'Basic cmVzdGFkbWluOnJlc3RwYXNz', ... } - >>> url = 'http://localhost:9001/3.0/system' + >>> url = 'http://localhost:9001/3.0/system/versions' >>> response, content = Http().request(url, 'GET', None, headers) >>> print(response.status) 200 -Basic information -================= +Version information +=================== -System information can be retrieved from the server, in the form of a JSON -encoded response. +System version information can be retrieved from the server, in the form of a +JSON encoded response. - >>> dump_json('http://localhost:9001/3.0/system') + >>> dump_json('http://localhost:9001/3.0/system/versions') http_etag: "..." mailman_version: GNU Mailman 3.0... (...) python_version: ... - self_link: http://localhost:9001/3.0/system + self_link: http://localhost:9001/3.0/system/versions .. _REST: http://en.wikipedia.org/wiki/REST diff --git a/src/mailman/rest/root.py b/src/mailman/rest/root.py index 654b230a3..8cbe4061a 100644 --- a/src/mailman/rest/root.py +++ b/src/mailman/rest/root.py @@ -77,13 +77,13 @@ class Root: return TopLevel() -class System: +class Versions: def on_get(self, request, response): - """/<api>/system""" + """/<api>/system/versions""" resource = dict( mailman_version=system.mailman_version, python_version=system.python_version, - self_link=path_to('system'), + self_link=path_to('system/versions'), ) okay(response, etag(resource)) @@ -95,11 +95,14 @@ class TopLevel: def system(self, request, segments): """/<api>/system""" if len(segments) == 0: - return System() + # This provides backward compatibility; see /system/versions. + return Versions() elif len(segments) > 1: return BadRequest(), [] elif segments[0] == 'preferences': return ReadOnlyPreferences(system_preferences, 'system'), [] + elif segments[0] == 'versions': + return Versions(), [] else: return NotFound(), [] diff --git a/src/mailman/rest/tests/test_root.py b/src/mailman/rest/tests/test_root.py index 5c134159d..7f3535496 100644 --- a/src/mailman/rest/tests/test_root.py +++ b/src/mailman/rest/tests/test_root.py @@ -19,6 +19,7 @@ __all__ = [ 'TestRoot', + 'TestSystemConfiguration', ] @@ -39,9 +40,19 @@ from six.moves.urllib_error import HTTPError class TestRoot(unittest.TestCase): layer = RESTLayer - def test_root_system(self): - # You can get the system preferences via the root path. + def test_root_system_backward_compatibility(self): + # The deprecated path for getting system version information points + # you to the new URL. url = 'http://localhost:9001/3.0/system' + new = '{}/versions'.format(url) + json, response = call_api(url) + self.assertEqual(json['mailman_version'], system.mailman_version) + self.assertEqual(json['python_version'], system.python_version) + self.assertEqual(json['self_link'], new) + + def test_system_versions(self): + # System version information is available via REST. + url = 'http://localhost:9001/3.0/system/versions' json, response = call_api(url) self.assertEqual(json['mailman_version'], system.mailman_version) self.assertEqual(json['python_version'], system.python_version) @@ -119,3 +130,8 @@ class TestRoot(unittest.TestCase): self.assertEqual(content['title'], '401 Unauthorized') self.assertEqual(content['description'], 'User is not authorized for the REST API') + + + +class TestSystemConfiguration(unittest.TestCase): + layer = RESTLayer |
