diff --git a/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_add_owner.yaml b/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_add_owner.yaml deleted file mode 100644 index 3241650..0000000 --- a/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_add_owner.yaml +++ /dev/null @@ -1,223 +0,0 @@ -interactions: -- request: - body: 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 'Duplicate email host: example.com'} - headers: - content-length: ['33'] - content-type: [application/json; charset=utf-8] - status: {code: 400, message: Bad Request} -- 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 '{"base_url": "http://example.com", "description": - null, "http_etag": "\"e736411818ff1815ca83575e0958c38c5188f0a4\"", "mail_host": - "example.com", "self_link": "http://localhost:9001/3.0/domains/example.com", - "url_host": "example.com"}'} - headers: - content-length: ['233'] - 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/domains/example.com - response: - body: {string: !!python/unicode '{"base_url": "http://example.com", "description": - null, "http_etag": "\"e736411818ff1815ca83575e0958c38c5188f0a4\"", "mail_host": - "example.com", "self_link": "http://localhost:9001/3.0/domains/example.com", - "url_host": "example.com"}'} - headers: - content-length: ['233'] - content-type: [application/json; charset=utf-8] - status: {code: 200, message: OK} -- request: - body: 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'] - 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: null - headers: - accept-encoding: ['gzip, deflate'] - method: !!python/unicode 'GET' - uri: http://localhost:9001/3.0/users/su@example.com - response: - body: {string: !!python/unicode '404 Not Found'} - headers: - content-length: ['13'] - content-type: [application/json; charset=utf-8] - status: {code: 404, message: Not Found} -- request: - body: null - headers: - accept-encoding: ['gzip, deflate'] - method: !!python/unicode 'GET' - uri: http://localhost:9001/3.0/lists/foo.example.com/roster/owner - response: - body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", - "start": 0, "total_size": 0}'} - headers: - content-length: ['90'] - 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/roster/moderator - response: - body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", - "start": 0, "total_size": 0}'} - headers: - content-length: ['90'] - content-type: [application/json; charset=utf-8] - status: {code: 200, message: OK} -- request: - body: role=owner&list_id=foo.example.com&subscriber=newowner%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'] - location: ['http://localhost:9001/3.0/members/2'] - 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/roster/member?count=1&page=1 - response: - body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", - "start": 0, "total_size": 0}'} - headers: - content-length: ['90'] - 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/roster/member?count=25&page=1 - response: - body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", - "start": 0, "total_size": 0}'} - headers: - content-length: ['90'] - 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/roster/owner - response: - body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/newowner@example.com", - "delivery_mode": "regular", "email": "newowner@example.com", "http_etag": - "\"3cd95533f48bade9cf7cd736dc8610586e170db5\"", "list_id": "foo.example.com", - "member_id": 2, "role": "owner", "self_link": "http://localhost:9001/3.0/members/2", - "user": "http://localhost:9001/3.0/users/2"}], "http_etag": "\"3f55a6e8ce307f1b4eb9244a084bf49b7759e0ef\"", - "start": 0, "total_size": 1}'} - headers: - content-length: ['458'] - 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/roster/moderator - response: - body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", - "start": 0, "total_size": 0}'} - headers: - content-length: ['90'] - 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/roster/owner - response: - body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/newowner@example.com", - "delivery_mode": "regular", "email": "newowner@example.com", "http_etag": - "\"3cd95533f48bade9cf7cd736dc8610586e170db5\"", "list_id": "foo.example.com", - "member_id": 2, "role": "owner", "self_link": "http://localhost:9001/3.0/members/2", - "user": "http://localhost:9001/3.0/users/2"}], "http_etag": "\"3f55a6e8ce307f1b4eb9244a084bf49b7759e0ef\"", - "start": 0, "total_size": 1}'} - headers: - content-length: ['458'] - 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": "\"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: null - headers: - accept-encoding: ['gzip, deflate'] - method: !!python/unicode 'DELETE' - uri: http://localhost:9001/3.0/lists/foo@example.com - response: - body: {string: !!python/unicode ''} - headers: - content-length: ['0'] - status: {code: 204, message: No Content} -version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_add_owner_new_owner_added.yaml b/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_add_owner_new_owner_added.yaml deleted file mode 100644 index abf1f66..0000000 --- a/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_add_owner_new_owner_added.yaml +++ /dev/null @@ -1,19 +0,0 @@ -interactions: -- request: - body: null - headers: - accept-encoding: ['gzip, deflate'] - method: !!python/unicode 'GET' - uri: http://localhost:9001/3.0/lists/foo.example.com/roster/owner - response: - body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/newowner@example.com", - "delivery_mode": "regular", "email": "newowner@example.com", "http_etag": - "\"3cd95533f48bade9cf7cd736dc8610586e170db5\"", "list_id": "foo.example.com", - "member_id": 2, "role": "owner", "self_link": "http://localhost:9001/3.0/members/2", - "user": "http://localhost:9001/3.0/users/2"}], "http_etag": "\"3f55a6e8ce307f1b4eb9244a084bf49b7759e0ef\"", - "start": 0, "total_size": 1}'} - headers: - content-length: ['458'] - content-type: [application/json; charset=utf-8] - status: {code: 200, message: OK} -version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner.yaml b/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner.yaml new file mode 100644 index 0000000..1cc54b2 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner.yaml @@ -0,0 +1,151 @@ +interactions: +- request: + body: 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'] + 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 '{"base_url": "http://example.com", "description": + null, "http_etag": "\"e736411818ff1815ca83575e0958c38c5188f0a4\"", "mail_host": + "example.com", "self_link": "http://localhost:9001/3.0/domains/example.com", + "url_host": "example.com"}'} + headers: + content-length: ['233'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: 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'] + 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: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode 'DELETE' + uri: http://localhost:9001/3.0/lists/foo@example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: 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 'Duplicate email host: example.com'} + headers: + content-length: ['33'] + content-type: [application/json; charset=utf-8] + status: {code: 400, message: Bad Request} +- 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 '{"base_url": "http://example.com", "description": + null, "http_etag": "\"e736411818ff1815ca83575e0958c38c5188f0a4\"", "mail_host": + "example.com", "self_link": "http://localhost:9001/3.0/domains/example.com", + "url_host": "example.com"}'} + headers: + content-length: ['233'] + 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/domains/example.com + response: + body: {string: !!python/unicode '{"base_url": "http://example.com", "description": + null, "http_etag": "\"e736411818ff1815ca83575e0958c38c5188f0a4\"", "mail_host": + "example.com", "self_link": "http://localhost:9001/3.0/domains/example.com", + "url_host": "example.com"}'} + headers: + content-length: ['233'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: 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'] + 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: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode 'DELETE' + uri: http://localhost:9001/3.0/lists/foo@example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner_add_remove.yaml b/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner_add_remove.yaml new file mode 100644 index 0000000..1cfbbf7 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner_add_remove.yaml @@ -0,0 +1,197 @@ +interactions: +- 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: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode 'GET' + uri: http://localhost:9001/3.0/users/su@example.com + response: + body: {string: !!python/unicode '404 Not Found'} + headers: + content-length: ['13'] + content-type: [application/json; charset=utf-8] + status: {code: 404, message: Not Found} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode 'GET' + uri: http://localhost:9001/3.0/lists/foo.example.com/roster/owner + response: + body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", + "start": 0, "total_size": 0}'} + headers: + content-length: ['90'] + 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/roster/moderator + response: + body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", + "start": 0, "total_size": 0}'} + headers: + content-length: ['90'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: subscriber=newowner%40example.com&role=owner&list_id=foo.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/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/1'] + 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/roster/member?count=1&page=1 + response: + body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", + "start": 0, "total_size": 0}'} + headers: + content-length: ['90'] + 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/roster/member?count=25&page=1 + response: + body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", + "start": 0, "total_size": 0}'} + headers: + content-length: ['90'] + 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/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/newowner@example.com", + "delivery_mode": "regular", "email": "newowner@example.com", "http_etag": + "\"1e656e8469afe5acc1725ce34ba2d64c95d401bb\"", "list_id": "foo.example.com", + "member_id": 1, "role": "owner", "self_link": "http://localhost:9001/3.0/members/1", + "user": "http://localhost:9001/3.0/users/1"}], "http_etag": "\"6d8e08bc7a0c4c26e574f282f7c140254cc57531\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['458'] + 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/roster/moderator + response: + body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", + "start": 0, "total_size": 0}'} + headers: + content-length: ['90'] + 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/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/newowner@example.com", + "delivery_mode": "regular", "email": "newowner@example.com", "http_etag": + "\"1e656e8469afe5acc1725ce34ba2d64c95d401bb\"", "list_id": "foo.example.com", + "member_id": 1, "role": "owner", "self_link": "http://localhost:9001/3.0/members/1", + "user": "http://localhost:9001/3.0/users/1"}], "http_etag": "\"6d8e08bc7a0c4c26e574f282f7c140254cc57531\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['458'] + 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": "\"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: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode 'GET' + uri: http://localhost:9001/3.0/lists/foo.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/newowner@example.com", + "delivery_mode": "regular", "email": "newowner@example.com", "http_etag": + "\"1e656e8469afe5acc1725ce34ba2d64c95d401bb\"", "list_id": "foo.example.com", + "member_id": 1, "role": "owner", "self_link": "http://localhost:9001/3.0/members/1", + "user": "http://localhost:9001/3.0/users/1"}], "http_etag": "\"6d8e08bc7a0c4c26e574f282f7c140254cc57531\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['458'] + 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/lists/foo@example.com/owner/newowner@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/lists/foo.example.com/roster/owner + response: + body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", + "start": 0, "total_size": 0}'} + headers: + content-length: ['90'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner_by_owner.yaml b/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner_by_owner.yaml new file mode 100644 index 0000000..8dbe3c0 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner_by_owner.yaml @@ -0,0 +1,502 @@ +interactions: +- 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: subscriber=su%40example.com&role=owner&list_id=foo.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/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/2'] + 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/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"50eebd88044b56c4a2073d93c0bf5c5da54f9b3c\"", + "list_id": "foo.example.com", "member_id": 2, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/2", "user": "http://localhost:9001/3.0/users/2"}], + "http_etag": "\"902cfc083f243f174e2457cc0b5ef0e669c1cae3\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['446'] + 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": "\"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: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode 'GET' + uri: http://localhost:9001/3.0/users/su@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b36f8ca1d91d583901c768dc116815282d469c66\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/2", "user_id": 2}'} + headers: + content-length: ['188'] + 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/2/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "su@example.com", "http_etag": + "\"a8988d233ad4b9e8641ad5d75553912565efec83\"", "original_email": "su@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/su@example.com", + "user": "http://localhost:9001/3.0/users/2"}], "http_etag": "\"7cc723891821fbf8b0974c2ec407cca11fbb6726\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['381'] + 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/addresses/su@example.com + response: + body: {string: !!python/unicode '{"email": "su@example.com", "http_etag": "\"a8988d233ad4b9e8641ad5d75553912565efec83\"", + "original_email": "su@example.com", "registered_on": "2005-08-01T07:49:23", + "self_link": "http://localhost:9001/3.0/addresses/su@example.com", "user": + "http://localhost:9001/3.0/users/2"}'} + headers: + content-length: ['276'] + 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/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"50eebd88044b56c4a2073d93c0bf5c5da54f9b3c\"", + "list_id": "foo.example.com", "member_id": 2, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/2", "user": "http://localhost:9001/3.0/users/2"}], + "http_etag": "\"902cfc083f243f174e2457cc0b5ef0e669c1cae3\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['446'] + 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/roster/moderator + response: + body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", + "start": 0, "total_size": 0}'} + headers: + content-length: ['90'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: subscriber=newowner%40example.com&role=owner&list_id=foo.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/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/3'] + 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/roster/member?count=1&page=1 + response: + body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", + "start": 0, "total_size": 0}'} + headers: + content-length: ['90'] + 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/roster/member?count=25&page=1 + response: + body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", + "start": 0, "total_size": 0}'} + headers: + content-length: ['90'] + 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/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/newowner@example.com", + "delivery_mode": "regular", "email": "newowner@example.com", "http_etag": + "\"0a19a1b74530e9a6e79d0164fd3504f7b06cd5bd\"", "list_id": "foo.example.com", + "member_id": 3, "role": "owner", "self_link": "http://localhost:9001/3.0/members/3", + "user": "http://localhost:9001/3.0/users/1"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"50eebd88044b56c4a2073d93c0bf5c5da54f9b3c\"", + "list_id": "foo.example.com", "member_id": 2, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/2", "user": "http://localhost:9001/3.0/users/2"}], + "http_etag": "\"c0fdf1ee97951fabb09248a5b663efb29ead01cf\"", "start": 0, "total_size": + 2}'} + headers: + content-length: ['801'] + 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/roster/moderator + response: + body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"", + "start": 0, "total_size": 0}'} + headers: + content-length: ['90'] + 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/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/newowner@example.com", + "delivery_mode": "regular", "email": "newowner@example.com", "http_etag": + "\"0a19a1b74530e9a6e79d0164fd3504f7b06cd5bd\"", "list_id": "foo.example.com", + "member_id": 3, "role": "owner", "self_link": "http://localhost:9001/3.0/members/3", + "user": "http://localhost:9001/3.0/users/1"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"50eebd88044b56c4a2073d93c0bf5c5da54f9b3c\"", + "list_id": "foo.example.com", "member_id": 2, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/2", "user": "http://localhost:9001/3.0/users/2"}], + "http_etag": "\"c0fdf1ee97951fabb09248a5b663efb29ead01cf\"", "start": 0, "total_size": + 2}'} + headers: + content-length: ['801'] + 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": "\"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: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode 'GET' + uri: http://localhost:9001/3.0/users/su@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b36f8ca1d91d583901c768dc116815282d469c66\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/2", "user_id": 2}'} + headers: + content-length: ['188'] + 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/2/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "su@example.com", "http_etag": + "\"a8988d233ad4b9e8641ad5d75553912565efec83\"", "original_email": "su@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/su@example.com", + "user": "http://localhost:9001/3.0/users/2"}], "http_etag": "\"7cc723891821fbf8b0974c2ec407cca11fbb6726\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['381'] + 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/addresses/su@example.com + response: + body: {string: !!python/unicode '{"email": "su@example.com", "http_etag": "\"a8988d233ad4b9e8641ad5d75553912565efec83\"", + "original_email": "su@example.com", "registered_on": "2005-08-01T07:49:23", + "self_link": "http://localhost:9001/3.0/addresses/su@example.com", "user": + "http://localhost:9001/3.0/users/2"}'} + headers: + content-length: ['276'] + 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/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/newowner@example.com", + "delivery_mode": "regular", "email": "newowner@example.com", "http_etag": + "\"0a19a1b74530e9a6e79d0164fd3504f7b06cd5bd\"", "list_id": "foo.example.com", + "member_id": 3, "role": "owner", "self_link": "http://localhost:9001/3.0/members/3", + "user": "http://localhost:9001/3.0/users/1"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"50eebd88044b56c4a2073d93c0bf5c5da54f9b3c\"", + "list_id": "foo.example.com", "member_id": 2, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/2", "user": "http://localhost:9001/3.0/users/2"}], + "http_etag": "\"c0fdf1ee97951fabb09248a5b663efb29ead01cf\"", "start": 0, "total_size": + 2}'} + headers: + content-length: ['801'] + 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": "\"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: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode 'GET' + uri: http://localhost:9001/3.0/lists/foo.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/newowner@example.com", + "delivery_mode": "regular", "email": "newowner@example.com", "http_etag": + "\"0a19a1b74530e9a6e79d0164fd3504f7b06cd5bd\"", "list_id": "foo.example.com", + "member_id": 3, "role": "owner", "self_link": "http://localhost:9001/3.0/members/3", + "user": "http://localhost:9001/3.0/users/1"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"50eebd88044b56c4a2073d93c0bf5c5da54f9b3c\"", + "list_id": "foo.example.com", "member_id": 2, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/2", "user": "http://localhost:9001/3.0/users/2"}], + "http_etag": "\"c0fdf1ee97951fabb09248a5b663efb29ead01cf\"", "start": 0, "total_size": + 2}'} + headers: + content-length: ['801'] + 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/lists/foo@example.com/owner/newowner@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/lists/foo.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"50eebd88044b56c4a2073d93c0bf5c5da54f9b3c\"", + "list_id": "foo.example.com", "member_id": 2, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/2", "user": "http://localhost:9001/3.0/users/2"}], + "http_etag": "\"902cfc083f243f174e2457cc0b5ef0e669c1cae3\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['446'] + 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": "\"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: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode 'GET' + uri: http://localhost:9001/3.0/users/su@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b36f8ca1d91d583901c768dc116815282d469c66\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/2", "user_id": 2}'} + headers: + content-length: ['188'] + 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/2/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "su@example.com", "http_etag": + "\"a8988d233ad4b9e8641ad5d75553912565efec83\"", "original_email": "su@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/su@example.com", + "user": "http://localhost:9001/3.0/users/2"}], "http_etag": "\"7cc723891821fbf8b0974c2ec407cca11fbb6726\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['381'] + 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/addresses/su@example.com + response: + body: {string: !!python/unicode '{"email": "su@example.com", "http_etag": "\"a8988d233ad4b9e8641ad5d75553912565efec83\"", + "original_email": "su@example.com", "registered_on": "2005-08-01T07:49:23", + "self_link": "http://localhost:9001/3.0/addresses/su@example.com", "user": + "http://localhost:9001/3.0/users/2"}'} + headers: + content-length: ['276'] + 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/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"50eebd88044b56c4a2073d93c0bf5c5da54f9b3c\"", + "list_id": "foo.example.com", "member_id": 2, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/2", "user": "http://localhost:9001/3.0/users/2"}], + "http_etag": "\"902cfc083f243f174e2457cc0b5ef0e669c1cae3\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['446'] + 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": "\"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: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode 'GET' + uri: http://localhost:9001/3.0/lists/foo.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"50eebd88044b56c4a2073d93c0bf5c5da54f9b3c\"", + "list_id": "foo.example.com", "member_id": 2, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/2", "user": "http://localhost:9001/3.0/users/2"}], + "http_etag": "\"902cfc083f243f174e2457cc0b5ef0e669c1cae3\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['446'] + 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/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"50eebd88044b56c4a2073d93c0bf5c5da54f9b3c\"", + "list_id": "foo.example.com", "member_id": 2, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/2", "user": "http://localhost:9001/3.0/users/2"}], + "http_etag": "\"902cfc083f243f174e2457cc0b5ef0e669c1cae3\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['446'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +version: 1 diff --git a/src/postorius/tests/mailman_api_tests/test_list_members.py b/src/postorius/tests/mailman_api_tests/test_list_members.py index 054071c..d7a6f97 100644 --- a/src/postorius/tests/mailman_api_tests/test_list_members.py +++ b/src/postorius/tests/mailman_api_tests/test_list_members.py @@ -17,14 +17,18 @@ import logging from django.conf import settings +from django.contrib import messages from django.contrib.auth.models import User from django.core.urlresolvers import reverse +from django.utils.timezone import now from django.test import Client, TestCase from django.test.utils import override_settings from six.moves.urllib_error import HTTPError from six.moves.urllib_parse import quote +from postorius.models import MailmanUser, Mailman404Error from postorius.tests import MM_VCR, API_CREDENTIALS +from postorius.tests.utils import get_flash_messages from postorius.utils import get_client @@ -77,7 +81,7 @@ if "%40" not in url: # Django < 1.8 url = quote(url) expected_redirect = "http://testserver%s?next=%s" % ( - settings.LOGIN_URL, url) + reverse(settings.LOGIN_URL), url) self.assertEqual(response.status_code, 302) self.assertEqual(response["location"], expected_redirect) @@ -111,37 +115,70 @@ @override_settings(**API_CREDENTIALS) -class AddOwnerTest(TestCase): +class AddRemoveOwnerTest(TestCase): """Tests for the list members page. Tests creation of list owners. """ - @MM_VCR.use_cassette('test_list_members_add_owner.yaml') + @MM_VCR.use_cassette('test_list_members_owner.yaml') def setUp(self): self.client = Client() + self.mm_client = get_client() try: - self.domain = get_client().create_domain('example.com') + self.domain = self.mm_client.create_domain('example.com') except HTTPError: - self.domain = get_client().get_domain('example.com') + self.domain = self.mm_client.get_domain('example.com') self.foo_list = self.domain.create_list('foo') self.su = User.objects.create_superuser( 'su', 'su@example.com', 'pwd') - # login and post new owner data to url self.client.login(username='su', password='pwd') - self.client.post( - reverse('list_members', args=('foo@example.com', )), - {'owner_email': 'newowner@example.com'}) - owners = self.foo_list.owners - @MM_VCR.use_cassette('test_list_members_add_owner.yaml') + @MM_VCR.use_cassette('test_list_members_owner.yaml') def tearDown(self): self.foo_list.delete() self.su.delete() - @MM_VCR.use_cassette('test_list_members_add_owner_new_owner_added.yaml') - def test_new_owner_added(self): - self.assertTrue(u'newowner@example.com' in self.foo_list.owners) + @MM_VCR.use_cassette('test_list_members_owner_add_remove.yaml') + def test_add_remove_owner(self): + self.client.post( + reverse('list_members', args=('foo@example.com', )), + {'owner_email': 'newowner@example.com'}) + self.assertTrue('newowner@example.com' in self.foo_list.owners) + self.client.post( + reverse('remove_role', args=('foo@example.com', 'owner', + 'newowner@example.com'))) + self.assertFalse('newowner@example.com' in self.foo_list.owners) + + @MM_VCR.use_cassette('test_list_members_owner_by_owner.yaml') + def test_remove_owner_as_owner(self): + self.mm_client.get_list('foo@example.com').add_owner('su@example.com') + self.assertTrue('su@example.com' in self.foo_list.owners) + # Make the logged in user a simple list owner + self.su.is_superuser = False + self.su.save() + # It must still be allowed to create and remove owners + self.client.post( + reverse('list_members', args=('foo@example.com', )), + {'owner_email': 'newowner@example.com'}) + self.assertTrue('newowner@example.com' in self.foo_list.owners) + response = self.client.post( + reverse('remove_role', args=('foo@example.com', 'owner', + 'newowner@example.com'))) + self.assertFalse('newowner@example.com' in self.foo_list.owners) + msgs = get_flash_messages(response) + self.assertEqual(len(msgs), 1) + self.assertEqual(msgs[0].level, messages.SUCCESS, msgs[0].message) + # But not to remove itself + response = self.client.post( + reverse('remove_role', args=('foo@example.com', 'owner', + 'su@example.com'))) + self.assertTrue('su@example.com' in self.foo_list.owners) + self.assertEqual(response.status_code, 302) + msgs = get_flash_messages(response) + self.assertEqual(len(msgs), 2) + self.assertEqual(msgs[1].level, messages.ERROR, msgs[1].message) + @override_settings(**API_CREDENTIALS) diff --git a/src/postorius/tests/mailman_api_tests/test_list_metrics.py b/src/postorius/tests/mailman_api_tests/test_list_metrics.py index 4c12968..6015391 100644 --- a/src/postorius/tests/mailman_api_tests/test_list_metrics.py +++ b/src/postorius/tests/mailman_api_tests/test_list_metrics.py @@ -48,7 +48,7 @@ if "%40" not in url: # Django < 1.8 url = quote(url) expected_redirect = "http://testserver%s?next=%s" % ( - settings.LOGIN_URL, url) + reverse(settings.LOGIN_URL), url) self.assertEqual(response.status_code, 302) self.assertEqual(response["location"], expected_redirect) diff --git a/src/postorius/views/list.py b/src/postorius/views/list.py index 76197e2..769f9f5 100644 --- a/src/postorius/views/list.py +++ b/src/postorius/views/list.py @@ -837,7 +837,8 @@ context_instance=RequestContext(request)) -@user_passes_test(lambda u: u.is_superuser) +@login_required +@list_owner_required def remove_role(request, list_id=None, role=None, address=None, template='postorius/lists/confirm_remove_role.html'): """Removes a list moderator or owner. @@ -852,6 +853,12 @@ messages.error(request, _('The user {} is not an owner'.format(address))) return redirect("list_members", the_list.list_id) + # the user may not have a other_emails property if it's a superuser + user_addresses = set([request.user.email]) | \ + set(getattr(request.user, 'other_emails', [])) + if address in user_addresses: + messages.error(request, _('You cannot remove yourself.')) + return redirect("list_members", the_list.list_id) elif role == 'moderator': if address not in the_list.moderators: messages.error(request, diff --git a/testing/test_settings.py b/testing/test_settings.py index 5ca0be5..ff86e57 100755 --- a/testing/test_settings.py +++ b/testing/test_settings.py @@ -141,9 +141,8 @@ # These are only used for development # 'debug_toolbar', ) -LOGIN_URL = '/postorius/accounts/login/' -LOGIN_REDIRECT_URL = '/postorius/' -LOGIN_ERROR_URL = '/postorius/accounts/login/' +LOGIN_URL = 'user_login' +LOGIN_REDIRECT_URL = 'list_index' def username(email): return email.rsplit('@', 1)[0]