summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mailman/docs/NEWS.rst2
-rw-r--r--src/mailman/rest/tests/test_users.py27
-rw-r--r--src/mailman/rest/users.py2
3 files changed, 30 insertions, 1 deletions
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst
index 64d0ee3f2..5f8056e20 100644
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -58,6 +58,8 @@ Other
* Improvements in importing Mailman 2.1 lists, given by Aurélien Bompard.
* The ``prototype`` archiver is not web accessible so it does not have a
``list_url`` or permalink. Given by Aurélien Bompard.
+ * The REST API incorrectly parsed `is_server_owner` values when given
+ explicitly in the POST that creates a user. (Closes #136)
3.0.0 -- "Show Don't Tell"
diff --git a/src/mailman/rest/tests/test_users.py b/src/mailman/rest/tests/test_users.py
index d58d7f9c3..6caaad401 100644
--- a/src/mailman/rest/tests/test_users.py
+++ b/src/mailman/rest/tests/test_users.py
@@ -245,6 +245,33 @@ class TestUsers(unittest.TestCase):
content, response = call_api('http://localhost:9001/3.0/users')
self.assertEqual(content['total_size'], 1)
+ def test_create_server_owner_false(self):
+ # Issue #136: Creating a user with is_server_owner=no should create
+ # user who is not a server owner.
+ content, response = call_api('http://localhost:9001/3.0/users', dict(
+ email='anne@example.com',
+ is_server_owner='no'))
+ anne = getUtility(IUserManager).get_user('anne@example.com')
+ self.assertFalse(anne.is_server_owner)
+
+ def test_create_server_owner_true(self):
+ # Issue #136: Creating a user with is_server_owner=yes should create a
+ # new server owner user.
+ content, response = call_api('http://localhost:9001/3.0/users', dict(
+ email='anne@example.com',
+ is_server_owner='yes'))
+ anne = getUtility(IUserManager).get_user('anne@example.com')
+ self.assertTrue(anne.is_server_owner)
+
+ def test_create_server_owner_bogus(self):
+ # Issue #136: Creating a user with is_server_owner=bogus should throw
+ # an exception.
+ with self.assertRaises(HTTPError) as cm:
+ call_api('http://localhost:9001/3.0/users', dict(
+ email='anne@example.com',
+ is_server_owner='bogus'))
+ self.assertEqual(cm.exception.code, 400)
+
def test_preferences_deletion_on_user_deletion(self):
# LP: #1418276 - deleting a user did not delete their preferences.
with transaction():
diff --git a/src/mailman/rest/users.py b/src/mailman/rest/users.py
index 4521593d4..da18d2ab3 100644
--- a/src/mailman/rest/users.py
+++ b/src/mailman/rest/users.py
@@ -82,7 +82,7 @@ ATTRIBUTES = dict(
CREATION_FIELDS = dict(
display_name=str,
email=str,
- is_server_owner=bool,
+ is_server_owner=as_boolean,
password=str,
_optional=('display_name', 'password', 'is_server_owner'),
)