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 index 1cc54b2..a019608 100644 --- a/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner.yaml +++ b/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner.yaml @@ -45,6 +45,34 @@ 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/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 response: body: {string: !!python/unicode '{"display_name": "Foo", "fqdn_listname": "foo@example.com", @@ -127,6 +155,144 @@ 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/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 + 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: 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/6'] + 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", 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 index 1cfbbf7..5071c60 100644 --- 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 @@ -21,11 +21,44 @@ method: !!python/unicode 'GET' uri: http://localhost:9001/3.0/users/su@example.com response: - body: {string: !!python/unicode '404 Not Found'} + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"eb591d9720aa0ac944b49315b6af1c950410b54c\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/1", "user_id": 1}'} headers: - content-length: ['13'] + content-length: ['188'] content-type: [application/json; charset=utf-8] - status: {code: 404, message: Not Found} + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode 'GET' + uri: http://localhost:9001/3.0/users/1/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "su@example.com", "http_etag": + "\"639f603b44bc4e3f588ffb045be45e858421b98e\"", "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/1"}], "http_etag": "\"a6e81d562465e6007ef87e1a4af8366feac12d19\"", + "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": "\"639f603b44bc4e3f588ffb045be45e858421b98e\"", + "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/1"}'} + headers: + content-length: ['276'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} - request: body: null headers: @@ -33,10 +66,14 @@ 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}'} + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"72e5bacea555ad25032c9d529b12ac9404eadf57\"", + "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": "\"412a6358fd93e549c57c67c316f6fd823329ff99\"", "start": 0, "total_size": + 1}'} headers: - content-length: ['90'] + content-length: ['446'] content-type: [application/json; charset=utf-8] status: {code: 200, message: OK} - request: @@ -63,7 +100,7 @@ body: {string: !!python/unicode ''} headers: content-length: ['0'] - location: ['http://localhost:9001/3.0/members/1'] + location: ['http://localhost:9001/3.0/members/2'] status: {code: 201, message: Created} - request: body: null @@ -100,12 +137,16 @@ 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}'} + "\"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"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"72e5bacea555ad25032c9d529b12ac9404eadf57\"", + "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": "\"c8683b1fae7a2ad2c5fa0b1e4bdadbf5e94fb1e4\"", "start": 0, "total_size": + 2}'} headers: - content-length: ['458'] + content-length: ['801'] content-type: [application/json; charset=utf-8] status: {code: 200, message: OK} - request: @@ -130,12 +171,16 @@ 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}'} + "\"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"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"72e5bacea555ad25032c9d529b12ac9404eadf57\"", + "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": "\"c8683b1fae7a2ad2c5fa0b1e4bdadbf5e94fb1e4\"", "start": 0, "total_size": + 2}'} headers: - content-length: ['458'] + content-length: ['801'] content-type: [application/json; charset=utf-8] status: {code: 200, message: OK} - request: @@ -162,12 +207,16 @@ 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}'} + "\"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"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"72e5bacea555ad25032c9d529b12ac9404eadf57\"", + "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": "\"c8683b1fae7a2ad2c5fa0b1e4bdadbf5e94fb1e4\"", "start": 0, "total_size": + 2}'} headers: - content-length: ['458'] + content-length: ['801'] content-type: [application/json; charset=utf-8] status: {code: 200, message: OK} - request: @@ -188,10 +237,14 @@ 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}'} + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"72e5bacea555ad25032c9d529b12ac9404eadf57\"", + "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": "\"412a6358fd93e549c57c67c316f6fd823329ff99\"", "start": 0, "total_size": + 1}'} headers: - content-length: ['90'] + content-length: ['446'] 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 index 8dbe3c0..4a5f1ac 100644 --- 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 @@ -4,41 +4,13 @@ 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": + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"f570d93af485c52ddf371499a144c1c1b556b29e\"", + "list_id": "foo.example.com", "member_id": 6, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/6", "user": "http://localhost:9001/3.0/users/1"}], + "http_etag": "\"1daaff607f9263f3a6c60227c18dc27553b3db81\"", "start": 0, "total_size": 1}'} headers: content-length: ['446'] @@ -67,8 +39,8 @@ 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}'} + "\"eb591d9720aa0ac944b49315b6af1c950410b54c\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/1", "user_id": 1}'} headers: content-length: ['188'] content-type: [application/json; charset=utf-8] @@ -78,12 +50,12 @@ headers: accept-encoding: ['gzip, deflate'] method: !!python/unicode 'GET' - uri: http://localhost:9001/3.0/users/2/addresses + uri: http://localhost:9001/3.0/users/1/addresses response: body: {string: !!python/unicode '{"entries": [{"email": "su@example.com", "http_etag": - "\"a8988d233ad4b9e8641ad5d75553912565efec83\"", "original_email": "su@example.com", + "\"639f603b44bc4e3f588ffb045be45e858421b98e\"", "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\"", + "user": "http://localhost:9001/3.0/users/1"}], "http_etag": "\"a6e81d562465e6007ef87e1a4af8366feac12d19\"", "start": 0, "total_size": 1}'} headers: content-length: ['381'] @@ -96,10 +68,10 @@ 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\"", + body: {string: !!python/unicode '{"email": "su@example.com", "http_etag": "\"639f603b44bc4e3f588ffb045be45e858421b98e\"", "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://localhost:9001/3.0/users/1"}'} headers: content-length: ['276'] content-type: [application/json; charset=utf-8] @@ -112,10 +84,10 @@ 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": + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"f570d93af485c52ddf371499a144c1c1b556b29e\"", + "list_id": "foo.example.com", "member_id": 6, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/6", "user": "http://localhost:9001/3.0/users/1"}], + "http_etag": "\"1daaff607f9263f3a6c60227c18dc27553b3db81\"", "start": 0, "total_size": 1}'} headers: content-length: ['446'] @@ -145,7 +117,7 @@ body: {string: !!python/unicode ''} headers: content-length: ['0'] - location: ['http://localhost:9001/3.0/members/3'] + location: ['http://localhost:9001/3.0/members/7'] status: {code: 201, message: Created} - request: body: null @@ -182,13 +154,13 @@ 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": + "\"93a70792332bdd5f8d27604b168494b7c74308da\"", "list_id": "foo.example.com", + "member_id": 7, "role": "owner", "self_link": "http://localhost:9001/3.0/members/7", + "user": "http://localhost:9001/3.0/users/2"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"f570d93af485c52ddf371499a144c1c1b556b29e\"", + "list_id": "foo.example.com", "member_id": 6, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/6", "user": "http://localhost:9001/3.0/users/1"}], + "http_etag": "\"e602be4824c6dfd69e52a03609210db4b2295ed6\"", "start": 0, "total_size": 2}'} headers: content-length: ['801'] @@ -216,13 +188,13 @@ 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": + "\"93a70792332bdd5f8d27604b168494b7c74308da\"", "list_id": "foo.example.com", + "member_id": 7, "role": "owner", "self_link": "http://localhost:9001/3.0/members/7", + "user": "http://localhost:9001/3.0/users/2"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"f570d93af485c52ddf371499a144c1c1b556b29e\"", + "list_id": "foo.example.com", "member_id": 6, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/6", "user": "http://localhost:9001/3.0/users/1"}], + "http_etag": "\"e602be4824c6dfd69e52a03609210db4b2295ed6\"", "start": 0, "total_size": 2}'} headers: content-length: ['801'] @@ -251,8 +223,8 @@ 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}'} + "\"eb591d9720aa0ac944b49315b6af1c950410b54c\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/1", "user_id": 1}'} headers: content-length: ['188'] content-type: [application/json; charset=utf-8] @@ -262,12 +234,12 @@ headers: accept-encoding: ['gzip, deflate'] method: !!python/unicode 'GET' - uri: http://localhost:9001/3.0/users/2/addresses + uri: http://localhost:9001/3.0/users/1/addresses response: body: {string: !!python/unicode '{"entries": [{"email": "su@example.com", "http_etag": - "\"a8988d233ad4b9e8641ad5d75553912565efec83\"", "original_email": "su@example.com", + "\"639f603b44bc4e3f588ffb045be45e858421b98e\"", "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\"", + "user": "http://localhost:9001/3.0/users/1"}], "http_etag": "\"a6e81d562465e6007ef87e1a4af8366feac12d19\"", "start": 0, "total_size": 1}'} headers: content-length: ['381'] @@ -280,10 +252,10 @@ 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\"", + body: {string: !!python/unicode '{"email": "su@example.com", "http_etag": "\"639f603b44bc4e3f588ffb045be45e858421b98e\"", "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://localhost:9001/3.0/users/1"}'} headers: content-length: ['276'] content-type: [application/json; charset=utf-8] @@ -297,13 +269,13 @@ 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": + "\"93a70792332bdd5f8d27604b168494b7c74308da\"", "list_id": "foo.example.com", + "member_id": 7, "role": "owner", "self_link": "http://localhost:9001/3.0/members/7", + "user": "http://localhost:9001/3.0/users/2"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"f570d93af485c52ddf371499a144c1c1b556b29e\"", + "list_id": "foo.example.com", "member_id": 6, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/6", "user": "http://localhost:9001/3.0/users/1"}], + "http_etag": "\"e602be4824c6dfd69e52a03609210db4b2295ed6\"", "start": 0, "total_size": 2}'} headers: content-length: ['801'] @@ -333,13 +305,13 @@ 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": + "\"93a70792332bdd5f8d27604b168494b7c74308da\"", "list_id": "foo.example.com", + "member_id": 7, "role": "owner", "self_link": "http://localhost:9001/3.0/members/7", + "user": "http://localhost:9001/3.0/users/2"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"f570d93af485c52ddf371499a144c1c1b556b29e\"", + "list_id": "foo.example.com", "member_id": 6, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/6", "user": "http://localhost:9001/3.0/users/1"}], + "http_etag": "\"e602be4824c6dfd69e52a03609210db4b2295ed6\"", "start": 0, "total_size": 2}'} headers: content-length: ['801'] @@ -364,136 +336,10 @@ 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": + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"f570d93af485c52ddf371499a144c1c1b556b29e\"", + "list_id": "foo.example.com", "member_id": 6, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/6", "user": "http://localhost:9001/3.0/users/1"}], + "http_etag": "\"1daaff607f9263f3a6c60227c18dc27553b3db81\"", "start": 0, "total_size": 1}'} headers: content-length: ['446'] diff --git a/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner_self_last.yaml b/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner_self_last.yaml new file mode 100644 index 0000000..3083e25 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/test_list_members_owner_self_last.yaml @@ -0,0 +1,243 @@ +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=otherowner%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/4'] + 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/otherowner@example.com", + "delivery_mode": "regular", "email": "otherowner@example.com", "http_etag": + "\"a15e19b1dcc07084d19912891fd589f133600fed\"", "list_id": "foo.example.com", + "member_id": 4, "role": "owner", "self_link": "http://localhost:9001/3.0/members/4", + "user": "http://localhost:9001/3.0/users/3"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"b723c1cd6f1b1eed1df6410474e5968bc3fdd6d9\"", + "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"}], + "http_etag": "\"ea6a45e2a044b02a945b6d89d3d016c6ac64f780\"", "start": 0, "total_size": + 2}'} + headers: + content-length: ['805'] + 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/otherowner@example.com", + "delivery_mode": "regular", "email": "otherowner@example.com", "http_etag": + "\"a15e19b1dcc07084d19912891fd589f133600fed\"", "list_id": "foo.example.com", + "member_id": 4, "role": "owner", "self_link": "http://localhost:9001/3.0/members/4", + "user": "http://localhost:9001/3.0/users/3"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"b723c1cd6f1b1eed1df6410474e5968bc3fdd6d9\"", + "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"}], + "http_etag": "\"ea6a45e2a044b02a945b6d89d3d016c6ac64f780\"", "start": 0, "total_size": + 2}'} + headers: + content-length: ['805'] + 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/otherowner@example.com", + "delivery_mode": "regular", "email": "otherowner@example.com", "http_etag": + "\"a15e19b1dcc07084d19912891fd589f133600fed\"", "list_id": "foo.example.com", + "member_id": 4, "role": "owner", "self_link": "http://localhost:9001/3.0/members/4", + "user": "http://localhost:9001/3.0/users/3"}, {"address": "http://localhost:9001/3.0/addresses/su@example.com", + "delivery_mode": "regular", "email": "su@example.com", "http_etag": "\"b723c1cd6f1b1eed1df6410474e5968bc3fdd6d9\"", + "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"}], + "http_etag": "\"ea6a45e2a044b02a945b6d89d3d016c6ac64f780\"", "start": 0, "total_size": + 2}'} + headers: + content-length: ['805'] + 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/su@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/otherowner@example.com", + "delivery_mode": "regular", "email": "otherowner@example.com", "http_etag": + "\"a15e19b1dcc07084d19912891fd589f133600fed\"", "list_id": "foo.example.com", + "member_id": 4, "role": "owner", "self_link": "http://localhost:9001/3.0/members/4", + "user": "http://localhost:9001/3.0/users/3"}], "http_etag": "\"59f61bd554b0f44923fec3f7828f86cfd0918450\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['462'] + 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/5'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode 'DELETE' + uri: http://localhost:9001/3.0/lists/foo@example.com/owner/otherowner@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": "\"132c238a15f75daef82541cd9ed0bca29cd10fb9\"", + "list_id": "foo.example.com", "member_id": 5, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/5", "user": "http://localhost:9001/3.0/users/1"}], + "http_etag": "\"f503aaf599ea1f0cc6f71f8cbdef68a3cc1bee89\"", "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": "\"132c238a15f75daef82541cd9ed0bca29cd10fb9\"", + "list_id": "foo.example.com", "member_id": 5, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/5", "user": "http://localhost:9001/3.0/users/1"}], + "http_etag": "\"f503aaf599ea1f0cc6f71f8cbdef68a3cc1bee89\"", "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": "\"132c238a15f75daef82541cd9ed0bca29cd10fb9\"", + "list_id": "foo.example.com", "member_id": 5, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/5", "user": "http://localhost:9001/3.0/users/1"}], + "http_etag": "\"f503aaf599ea1f0cc6f71f8cbdef68a3cc1bee89\"", "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": "\"132c238a15f75daef82541cd9ed0bca29cd10fb9\"", + "list_id": "foo.example.com", "member_id": 5, "role": "owner", "self_link": + "http://localhost:9001/3.0/members/5", "user": "http://localhost:9001/3.0/users/1"}], + "http_etag": "\"f503aaf599ea1f0cc6f71f8cbdef68a3cc1bee89\"", "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 d7a6f97..3da46a2 100644 --- a/src/postorius/tests/mailman_api_tests/test_list_members.py +++ b/src/postorius/tests/mailman_api_tests/test_list_members.py @@ -133,6 +133,7 @@ self.su = User.objects.create_superuser( 'su', 'su@example.com', 'pwd') self.client.login(username='su', password='pwd') + self.mm_client.get_list('foo@example.com').add_owner('su@example.com') @MM_VCR.use_cassette('test_list_members_owner.yaml') def tearDown(self): @@ -151,8 +152,7 @@ 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') + def test_remove_owner_by_owner(self): self.assertTrue('su@example.com' in self.foo_list.owners) # Make the logged in user a simple list owner self.su.is_superuser = False @@ -169,7 +169,28 @@ 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 + + @MM_VCR.use_cassette('test_list_members_owner_self_last.yaml') + def test_remove_owner_as_owner_self_last(self): + # It is allowed to remove itself, but only if there's another owner + # left. + mm_list = self.mm_client.get_list('foo@example.com') + mm_list.add_owner('otherowner@example.com') + self.assertTrue('su@example.com' in self.foo_list.owners) + self.assertTrue('otherowner@example.com' in self.foo_list.owners) + response = self.client.post( + reverse('remove_role', args=('foo@example.com', 'owner', + 'su@example.com'))) + self.assertFalse('su@example.com' in self.foo_list.owners) + self.assertEqual(response.status_code, 302) + msgs = get_flash_messages(response) + self.assertEqual(len(msgs), 1) + self.assertEqual(msgs[0].level, messages.SUCCESS, msgs[0].message) + # But not to remove the last owner + mm_list.add_owner('su@example.com') + mm_list.remove_owner('otherowner@example.com') + self.assertTrue('su@example.com' in self.foo_list.owners) + self.assertFalse('otherowner@example.com' in self.foo_list.owners) response = self.client.post( reverse('remove_role', args=('foo@example.com', 'owner', 'su@example.com'))) diff --git a/src/postorius/views/list.py b/src/postorius/views/list.py index 303562a..7be8d0f 100644 --- a/src/postorius/views/list.py +++ b/src/postorius/views/list.py @@ -747,22 +747,29 @@ except MailmanApiError: return utils.render_api_error(request) + redirect_on_success = redirect('list_members', the_list.list_id) + if role == 'owner': - if address not in the_list.owners: + owners = the_list.owners + if address not in owners: messages.error(request, _('The user {} is not an owner'.format(address))) - return redirect("list_members", the_list.list_id) + return redirect('list_members', the_list.list_id) + if len(owners) == 1: + messages.error(request, _('Removing the last owner is impossible')) + 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) + # The user is removing themselves, redirect to the list info page + # because they won't have access to the members page anyway. + redirect_on_success = redirect('list_summary', the_list.list_id) elif role == 'moderator': if address not in the_list.moderators: messages.error(request, _('The user {} is not a moderator'.format(address))) - return redirect("list_members", the_list.list_id) + return redirect('list_members', the_list.list_id) if request.method == 'POST': try: @@ -772,11 +779,11 @@ except HTTPError as e: messages.error(request, _('The {0} could not be removed:' ' {1}'.format(role, e.msg))) - return redirect("list_members", the_list.list_id) + return redirect('list_members', the_list.list_id) messages.success(request, _('The user {0} has been removed as {1}.' .format(address, role))) - return redirect("list_members", the_list.list_id) + return redirect_on_success return render_to_response(template, {'role': role, 'address': address,