Merge lp:~raj-abhilash1/mailman/bugfix into lp:mailman

Proposed by Abhilash Raj
Status: Merged
Merged at revision: 7318
Proposed branch: lp:~raj-abhilash1/mailman/bugfix
Merge into: lp:mailman
Diff against target: 42 lines (+13/-1)
2 files modified
src/mailman/rest/domains.py (+4/-1)
src/mailman/rest/tests/test_domains.py (+9/-0)
To merge this branch: bzr merge lp:~raj-abhilash1/mailman/bugfix
Reviewer Review Type Date Requested Status
Mailman Coders Pending
Review via email: mp+256233@code.launchpad.net

Description of the change

When creating domain with single owner passed via json, InvalidEmailError was raise. Fixed that.

To post a comment you must log in.
lp:~raj-abhilash1/mailman/bugfix updated
7317. By Barry Warsaw

 * Mailing list subscription policy work flow has been completely rewritten.
   It now properly supports email verification and subscription confirmation
   by the user, and approval by the moderator using unique tokens.
   ``IMailingList`` objects now have a ``subscription_policy`` attribute.

7318. By Barry Warsaw

Abhilash's fix for allowing singleton strings in REST interfaces that also
accept lists of strings.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/mailman/rest/domains.py'
2--- src/mailman/rest/domains.py 2015-04-07 01:39:34 +0000
3+++ src/mailman/rest/domains.py 2015-04-14 21:33:34 +0000
4@@ -118,7 +118,10 @@
5 # but .add() requires an `owners` keyword. Match impedence.
6 owners = values.pop('owner', None)
7 if owners is not None:
8- values['owners'] = owners
9+ if isinstance(owners, str):
10+ values['owners'] = [owners]
11+ else:
12+ values['owners'] = owners
13 domain = domain_manager.add(**values)
14 except BadDomainSpecificationError as error:
15 bad_request(response, str(error))
16
17=== modified file 'src/mailman/rest/tests/test_domains.py'
18--- src/mailman/rest/tests/test_domains.py 2015-04-07 02:06:28 +0000
19+++ src/mailman/rest/tests/test_domains.py 2015-04-14 21:33:34 +0000
20@@ -54,6 +54,14 @@
21 'http://localhost:9001/3.0/domains', data, method="POST")
22 self.assertEqual(response.status, 201)
23
24+ def test_domain_create_with_single_owner(self):
25+ # Creating domain with single owner should not raise InvalidEmailError
26+ content, response = call_api('http://localhost:9001/3.0/domains',
27+ dict(mail_host='example.in',
28+ owner='someperson@example.com'),
29+ method='POST')
30+ self.assertEqual(response.status, 201)
31+
32 def test_bogus_endpoint_extension(self):
33 # /domains/<domain>/lists/<anything> is not a valid endpoint.
34 with self.assertRaises(HTTPError) as cm:
35@@ -102,6 +110,7 @@
36 self.assertEqual(cm.exception.code, 404)
37
38
39+
40
41
42 class TestDomainOwners(unittest.TestCase):
43 layer = RESTLayer