summaryrefslogtreecommitdiff
path: root/src/mailman/rest
diff options
context:
space:
mode:
authorBarry Warsaw2015-02-05 22:04:45 -0500
committerBarry Warsaw2015-02-05 22:04:45 -0500
commit4d7c57bcf50654b7306f132e241e9fdcdec75865 (patch)
tree44c4f18f67b34bcff2c98f7e8621466f690ce5e9 /src/mailman/rest
parentdde8977c8b67cac8bc5fa626d0a62c81b1b28389 (diff)
downloadmailman-4d7c57bcf50654b7306f132e241e9fdcdec75865.tar.gz
mailman-4d7c57bcf50654b7306f132e241e9fdcdec75865.tar.zst
mailman-4d7c57bcf50654b7306f132e241e9fdcdec75865.zip
* When creating a user with an email address, do not create the user record
if the email address already exists. Given by Andrew Stuart. (LP: #1418280)
Diffstat (limited to 'src/mailman/rest')
-rw-r--r--src/mailman/rest/tests/test_users.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mailman/rest/tests/test_users.py b/src/mailman/rest/tests/test_users.py
index e009f63c1..2c729711f 100644
--- a/src/mailman/rest/tests/test_users.py
+++ b/src/mailman/rest/tests/test_users.py
@@ -188,6 +188,28 @@ class TestUsers(unittest.TestCase):
})
self.assertEqual(cm.exception.code, 404)
+ def test_create_user_twice(self):
+ # LP: #1418280. No additional users should be created when an address
+ # that already exists is given.
+ content, response = call_api('http://localhost:9001/3.0/users')
+ self.assertEqual(content['total_size'], 0)
+ # Create the user.
+ call_api('http://localhost:9001/3.0/users', dict(
+ email='anne@example.com'))
+ # There is now one user.
+ content, response = call_api('http://localhost:9001/3.0/users')
+ self.assertEqual(content['total_size'], 1)
+ # Trying to create the user with the same address results in an error.
+ with self.assertRaises(HTTPError) as cm:
+ call_api('http://localhost:9001/3.0/users', dict(
+ email='anne@example.com'))
+ self.assertEqual(cm.exception.code, 400)
+ self.assertEqual(cm.exception.reason,
+ b'Address already exists: anne@example.com')
+ # But at least no new users was created.
+ content, response = call_api('http://localhost:9001/3.0/users')
+ self.assertEqual(content['total_size'], 1)
+
class TestLP1074374(unittest.TestCase):