diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListMembersOptionsTest.test_nonexistent_member_returns_404.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListMembersOptionsTest.test_nonexistent_member_returns_404.yaml new file mode 100644 index 0000000..8615ccd --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListMembersOptionsTest.test_nonexistent_member_returns_404.yaml @@ -0,0 +1,280 @@ +interactions: +- request: + body: !!python/unicode mail_host=example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/domains + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + content-type: [application/json; charset=UTF-8] + location: ['http://localhost:9001/3.0/domains/example.com'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode '{"description": null, "http_etag": "\"d150abd34fabbcef42a2c654bfac81aa04ea4d6f\"", + "mail_host": "example.com", "self_link": "http://localhost:9001/3.0/domains/example.com"}'} + headers: + content-length: ['172'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: !!python/unicode fqdn_listname=foo%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/lists + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + content-type: [application/json; charset=UTF-8] + location: ['http://localhost:9001/3.0/lists/foo.example.com'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo.example.com + response: + body: {string: !!python/unicode '{"display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"698a819bbb6b902096a8c5543cc7fac2328960d5\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/foo.example.com", "volume": 1}'} + headers: + content-length: ['294'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: !!python/unicode list_id=foo.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + content-type: [application/json; charset=UTF-8] + location: ['http://localhost:9001/3.0/members/5297'] + status: {code: 201, message: Created} +- request: + body: !!python/unicode list_id=foo.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + content-type: [application/json; charset=UTF-8] + location: ['http://localhost:9001/3.0/members/5298'] + status: {code: 201, message: Created} +- request: + body: !!python/unicode email=test%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/users + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + content-type: [application/json; charset=UTF-8] + location: ['http://localhost:9001/3.0/users/3378'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/users/3378 + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"80a3fa6684c3a200c2eb564d533d0245cfd79433\"", "is_server_owner": false, + "password": "$6$rounds=595162$OQPvrqO8zYHFrMid$ALz6dVgiaGtVw1pq.2tttseKje7Xlh3C0bz.DzsJWpsU7Sfjv/SoQB10SZ9km7V9mKQzpbByFxJ29VuDMJDJR/", + "self_link": "http://localhost:9001/3.0/users/3378", "user_id": 3378}'} + headers: + content-length: ['330'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/users/3378/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "test@example.com", "http_etag": + "\"7fc7f31d0d2208eb924b912bd7fddec5a34bb77f\"", "original_email": "test@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/test@example.com", + "user": "http://localhost:9001/3.0/users/3378"}], "http_etag": "\"ed96f967a3455978b62f5d0677825f274ebbdbff\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/addresses/test@example.com/verify + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: !!python/unicode display_name=None&list_id=foo.example.com&pre_approved=True&pre_confirmed=True&pre_verified=True&subscriber=test%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + content-type: [application/json; charset=UTF-8] + location: ['http://localhost:9001/3.0/members/5299'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo.example.com + response: + body: {string: !!python/unicode '{"display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"98cc998d4a30293ec17da639bce10617912a6e1e\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 1, "self_link": + "http://localhost:9001/3.0/lists/foo.example.com", "volume": 1}'} + headers: + content-length: ['294'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo.example.com + response: + body: {string: !!python/unicode '{"display_name": "Foo", "fqdn_listname": "foo@example.com", + "http_etag": "\"98cc998d4a30293ec17da639bce10617912a6e1e\"", "list_id": "foo.example.com", + "list_name": "foo", "mail_host": "example.com", "member_count": 1, "self_link": + "http://localhost:9001/3.0/lists/foo.example.com", "volume": 1}'} + headers: + content-length: ['294'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/foo.example.com/member/none@example.com + response: + body: {string: !!python/unicode '{}'} + headers: + content-length: ['2'] + content-type: [application/json; charset=UTF-8] + vary: [Accept] + status: {code: 404, message: Not Found} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/domains + response: + body: {string: !!python/unicode '{"entries": [{"description": null, "http_etag": + "\"d150abd34fabbcef42a2c654bfac81aa04ea4d6f\"", "mail_host": "example.com", + "self_link": "http://localhost:9001/3.0/domains/example.com"}], "http_etag": + "\"2ec9679269ad1f741705a62db0162f5585ae5c3c\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['277'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/users + response: + body: {string: !!python/unicode '{"entries": [{"created_on": "2005-08-01T07:49:23", + "http_etag": "\"7f7f58c6d00e58ff1ef3c0870649412a41e22392\"", "is_server_owner": + false, "self_link": "http://localhost:9001/3.0/users/3376", "user_id": 3376}, + {"created_on": "2005-08-01T07:49:23", "http_etag": "\"0498836bc12cba6ceb3299d6b097a07b900bff70\"", + "is_server_owner": false, "self_link": "http://localhost:9001/3.0/users/3377", + "user_id": 3377}, {"created_on": "2005-08-01T07:49:23", "http_etag": "\"80a3fa6684c3a200c2eb564d533d0245cfd79433\"", + "is_server_owner": false, "password": "$6$rounds=595162$OQPvrqO8zYHFrMid$ALz6dVgiaGtVw1pq.2tttseKje7Xlh3C0bz.DzsJWpsU7Sfjv/SoQB10SZ9km7V9mKQzpbByFxJ29VuDMJDJR/", + "self_link": "http://localhost:9001/3.0/users/3378", "user_id": 3378}], "http_etag": + "\"a68a3283df43ff0bd539578b6c933b29fd650e56\"", "start": 0, "total_size": + 3}'} + headers: + content-length: ['827'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode DELETE + uri: http://localhost:9001/3.0/users/3376 + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode DELETE + uri: http://localhost:9001/3.0/users/3377 + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode DELETE + uri: http://localhost:9001/3.0/users/3378 + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/mailman_api_tests/test_list_member_options.py b/src/postorius/tests/mailman_api_tests/test_list_member_options.py index 8e60af6..174b15d 100644 --- a/src/postorius/tests/mailman_api_tests/test_list_member_options.py +++ b/src/postorius/tests/mailman_api_tests/test_list_member_options.py @@ -91,6 +91,13 @@ self.assertIsInstance(response.context['preferences_form'], UserPreferences) + def test_nonexistent_member_returns_404(self): + self.client.login(username='testsu', password='testpass') + url = reverse('list_member_options', args=(self.foo_list.list_id, + 'none@example.com',)) + response = self.client.get(url) + self.assertEquals(response.status_code, 404) + def test_moderation_action(self): self.assertIsNone( self.foo_list.get_member('test@example.com').moderation_action)