diff options
| author | Barry Warsaw | 2015-04-07 15:21:08 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2015-04-07 15:21:08 -0400 |
| commit | 89f8cd6c2bc7d38c2478d87d81b4b729169b3d80 (patch) | |
| tree | 41ceebd7697d0673b9c91592c75c4ba85a8e432c /src/mailman/rest/tests/test_domains.py | |
| parent | bf00467f633ae6a8523189c1b922ca6dcd6636b8 (diff) | |
| parent | 7317b94a0b746f0287ecbc5654ec544ce0112adb (diff) | |
| download | mailman-89f8cd6c2bc7d38c2478d87d81b4b729169b3d80.tar.gz mailman-89f8cd6c2bc7d38c2478d87d81b4b729169b3d80.tar.zst mailman-89f8cd6c2bc7d38c2478d87d81b4b729169b3d80.zip | |
Diffstat (limited to 'src/mailman/rest/tests/test_domains.py')
| -rw-r--r-- | src/mailman/rest/tests/test_domains.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/mailman/rest/tests/test_domains.py b/src/mailman/rest/tests/test_domains.py index bf53c8e70..716ded580 100644 --- a/src/mailman/rest/tests/test_domains.py +++ b/src/mailman/rest/tests/test_domains.py @@ -18,6 +18,7 @@ """REST domain tests.""" __all__ = [ + 'TestDomainOwners', 'TestDomains', ] @@ -41,6 +42,18 @@ class TestDomains(unittest.TestCase): with transaction(): self._mlist = create_list('test@example.com') + def test_create_domains(self): + # Create a domain with owners. + data = dict( + mail_host='example.org', + description='Example domain', + base_url='http://example.org', + owner=['someone@example.com', 'secondowner@example.com'], + ) + content, response = call_api( + 'http://localhost:9001/3.0/domains', data, method="POST") + self.assertEqual(response.status, 201) + def test_bogus_endpoint_extension(self): # /domains/<domain>/lists/<anything> is not a valid endpoint. with self.assertRaises(HTTPError) as cm: @@ -87,3 +100,45 @@ class TestDomains(unittest.TestCase): call_api('http://localhost:9001/3.0/domains/example.com', method='DELETE') self.assertEqual(cm.exception.code, 404) + + + +class TestDomainOwners(unittest.TestCase): + layer = RESTLayer + + def test_get_missing_domain_owners(self): + # Try to get the owners of a missing domain. + with self.assertRaises(HTTPError) as cm: + call_api('http://localhost:9001/3.0/domains/example.net/owners') + self.assertEqual(cm.exception.code, 404) + + def test_post_to_missing_domain_owners(self): + # Try to add owners to a missing domain. + with self.assertRaises(HTTPError) as cm: + call_api('http://localhost:9001/3.0/domains/example.net/owners', ( + ('owner', 'dave@example.com'), ('owner', 'elle@example.com'), + )) + self.assertEqual(cm.exception.code, 404) + + def test_delete_missing_domain_owners(self): + # Try to delete the owners of a missing domain. + with self.assertRaises(HTTPError) as cm: + call_api('http://localhost:9001/3.0/domains/example.net/owners', + method='DELETE') + self.assertEqual(cm.exception.code, 404) + + def test_bad_post(self): + # Send POST data with an invalid attribute. + with self.assertRaises(HTTPError) as cm: + call_api('http://localhost:9001/3.0/domains/example.com/owners', ( + ('guy', 'dave@example.com'), ('gal', 'elle@example.com'), + )) + self.assertEqual(cm.exception.code, 400) + + def test_bad_delete(self): + # Send DELETE with any data. + with self.assertRaises(HTTPError) as cm: + call_api('http://localhost:9001/3.0/domains/example.com/owners', { + 'owner': 'dave@example.com', + }, method='DELETE') + self.assertEqual(cm.exception.code, 400) |
