diff --git a/src/postorius/forms.py b/src/postorius/forms.py index b25458e..4eaf396 100644 --- a/src/postorius/forms.py +++ b/src/postorius/forms.py @@ -41,6 +41,9 @@ ) +# Fields + + class ListOfStringsField(forms.Field): widget = forms.widgets.Textarea @@ -62,6 +65,10 @@ return result + +# Forms + + class DomainNew(FieldsetForm): """ @@ -653,6 +660,53 @@ 'invalid': _('Please enter a valid email adddress.')}) +class ListHeaderMatchForm(forms.Form): + """Edit a list's header match.""" + + HM_ACTION_CHOICES = [ + (None, _("Default antispam action")) ] + [ + a for a in ACTION_CHOICES if a[0] != 'defer' + ] + + header = forms.CharField( + label=_('Header'), + help_text=_('Email header to filter on (case-insensitive).'), + error_messages={ + 'required': _('Please enter a header.'), + 'invalid': _('Please enter a valid header.')}) + pattern = forms.CharField( + label=_('Pattern'), + help_text=_('Regular expression matching the header\'s value.'), + error_messages={ + 'required': _('Please enter a pattern.'), + 'invalid': _('Please enter a valid pattern.')}) + action = forms.ChoiceField( + label=_('Action'), + error_messages={'invalid': _('Please enter a valid action.')}, + #widget=forms.RadioSelect(), + required=False, + choices=HM_ACTION_CHOICES, + help_text=_('Action to take when a header matches') + ) + +class ListHeaderMatchFormset(forms.BaseFormSet): + def clean(self): + """Checks that no two header matches have the same order.""" + if any(self.errors): + # Don't bother validating the formset unless each form is valid on its own + return + orders = [] + for form in self.forms: + try: + order = form.cleaned_data['ORDER'] + except KeyError: + continue + if order in orders: + raise forms.ValidationError("Header matches must have distinct orders.") + orders.append(order) + + + class UserPreferences(FieldsetForm): """ diff --git a/src/postorius/static/postorius/css/style.css b/src/postorius/static/postorius/css/style.css index 894097c..5606d23 100644 --- a/src/postorius/static/postorius/css/style.css +++ b/src/postorius/static/postorius/css/style.css @@ -31,3 +31,20 @@ table.bans-current { width: auto; } + + +/* Header matches */ + +table.header-matches th .text-muted { + font-weight: normal; + font-size: small; +} +table.header-matches td .errorlist { + list-style-type: none; + padding: 0; + margin: 0; +} +.header-matches-pending-changes { + display: none; + margin-left: 1em; +} diff --git a/src/postorius/templates/postorius/lists/header_matches.html b/src/postorius/templates/postorius/lists/header_matches.html new file mode 100644 index 0000000..ee85979 --- /dev/null +++ b/src/postorius/templates/postorius/lists/header_matches.html @@ -0,0 +1,107 @@ +{% extends postorius_base_template %} +{% load i18n %} +{% load bootstrap_tags %} +{% load nav_helpers %} + +{% block subtitle %} +{% trans 'Header filters' %} | {{ list.fqdn_listname}} +{% endblock %} + +{% block main %} + + {% list_nav 'list_header_matches' 'Header filters' %} + + {% for error in formset.non_form_errors %} +
{{ error }}
+ {% endfor %} + +
+ {% csrf_token %} + {{ formset.management_form }} + + + + {% for field in formset.forms.0 %} + + {% endfor %} + + + + {% for form in formset %} + + {% for field in form %} + {% if field.name == 'ORDER' %} + + {% endfor %} + {% if forloop.last %} + {# This is the new header match form, it has no order or delete fields #} + + {% endif %} + + {% endfor %} + +
+ {{ field.label }} +
{{ field.help_text }}
+
+ {{ field|add_form_control }} + + + {% else %} + + {{ field|add_form_control }} + {% endif %} +
{{ field.errors }}
+
+ +

+ + + {% trans 'Changes pending, click on the button to save them.' %} + +

+
+ +{% endblock %} + +{% block additionaljs %} + +{% endblock %} diff --git a/src/postorius/templates/postorius/menu/list_nav.html b/src/postorius/templates/postorius/menu/list_nav.html index 53f82e0..3608999 100644 --- a/src/postorius/templates/postorius/menu/list_nav.html +++ b/src/postorius/templates/postorius/menu/list_nav.html @@ -24,6 +24,7 @@ + {% endif %} diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add.yaml new file mode 100644 index 0000000..9b4f2f8 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add.yaml @@ -0,0 +1,381 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/23'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/24'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"b3085c455c20a7bbfd074cc9acc703c2445551d6\"", + "list_id": "list.example.com", "member_id": 23, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/23", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"9c0c4a0f646d8c4feaca4a03f4761abce6ecfc95\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"431455e0d7a45e45f64df20af82bec50ce4cabcf\"", "list_id": "list.example.com", + "member_id": 24, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/24", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"e2f8afe35cd0a0dd80ad3ab96b936747274eeda4\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + 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 DELETE + uri: http://localhost:9001/3.0/lists/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: action=discard&header=testheader&pattern=testpattern + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"b3085c455c20a7bbfd074cc9acc703c2445551d6\"", + "list_id": "list.example.com", "member_id": 23, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/23", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"9c0c4a0f646d8c4feaca4a03f4761abce6ecfc95\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"431455e0d7a45e45f64df20af82bec50ce4cabcf\"", "list_id": "list.example.com", + "member_id": 24, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/24", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"e2f8afe35cd0a0dd80ad3ab96b936747274eeda4\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader", "http_etag": "\"b55a407e5664a07b70919a16f2df3fc50350c6b5\"", + "pattern": "testpattern", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"671170868231c1a4e4c35632e3b136acd18c2872\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['334'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader", "http_etag": "\"b55a407e5664a07b70919a16f2df3fc50350c6b5\"", + "pattern": "testpattern", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"671170868231c1a4e4c35632e3b136acd18c2872\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['334'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader", "http_etag": "\"b55a407e5664a07b70919a16f2df3fc50350c6b5\"", + "pattern": "testpattern", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"671170868231c1a4e4c35632e3b136acd18c2872\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['334'] + 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/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add_empty.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add_empty.yaml new file mode 100644 index 0000000..13b0eba --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add_empty.yaml @@ -0,0 +1,335 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/25'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/26'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"0cbc6534c2b8a970da97fa245970cf08710a72b7\"", + "list_id": "list.example.com", "member_id": 25, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/25", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"b176259e59f8c6c36b66520f448ea29b803b265b\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"a724316fbf4f74b99a11e03a92f109b77f049862\"", "list_id": "list.example.com", + "member_id": 26, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/26", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"535da6121a7839b2653cb337c9de8c091a4cc204\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"0cbc6534c2b8a970da97fa245970cf08710a72b7\"", + "list_id": "list.example.com", "member_id": 25, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/25", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"b176259e59f8c6c36b66520f448ea29b803b265b\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"a724316fbf4f74b99a11e03a92f109b77f049862\"", "list_id": "list.example.com", + "member_id": 26, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/26", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"535da6121a7839b2653cb337c9de8c091a4cc204\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + 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/list.example.com/header-matches + 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 DELETE + uri: http://localhost:9001/3.0/lists/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add_empty_header.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add_empty_header.yaml new file mode 100644 index 0000000..a07c026 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add_empty_header.yaml @@ -0,0 +1,227 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/27'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/28'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"8aa913ebcd4ae349810d8f0d487b49dd7dbeec38\"", + "list_id": "list.example.com", "member_id": 27, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/27", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"90610974fb8724e3b3efed29902135fd7e272811\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"fac749cc246ee63345bed81458f06b813044a2e2\"", "list_id": "list.example.com", + "member_id": 28, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/28", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"a960b3b29f92c025f52fb431d9682849eecfd454\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + 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/list.example.com/header-matches + 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 DELETE + uri: http://localhost:9001/3.0/lists/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add_empty_pattern.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add_empty_pattern.yaml new file mode 100644 index 0000000..7dc4fdd --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add_empty_pattern.yaml @@ -0,0 +1,227 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/29'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/30'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"0e4d79a043dc939a16f53f44f4bd1ea675f77ba7\"", + "list_id": "list.example.com", "member_id": 29, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/29", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"0f5121e7ee4c51226674440871ae2e7fa6fc48e8\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"b227c995ebf21adb51cd9107fd7d06f2c1b3185d\"", "list_id": "list.example.com", + "member_id": 30, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/30", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"989cf950a7c53671b23c990ed59f4a8dfeebd03b\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + 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/list.example.com/header-matches + 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 DELETE + uri: http://localhost:9001/3.0/lists/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add_existing.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add_existing.yaml new file mode 100644 index 0000000..2b0ccd9 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_add_existing.yaml @@ -0,0 +1,410 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/31'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/32'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader&pattern=testpattern + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"24aa6e0438131bd5ab07fd5dd7e4326e8268cef5\"", + "list_id": "list.example.com", "member_id": 31, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/31", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"3d5198105c25da87e47d7bb33360be2db35a94fd\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"cb188332b647676c84b3ae9c91430d55d462f504\"", "list_id": "list.example.com", + "member_id": 32, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/32", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"ddab9f7d9f4a65518db5d644425cb3bf63eda468\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader", "http_etag": "\"b55a407e5664a07b70919a16f2df3fc50350c6b5\"", + "pattern": "testpattern", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"671170868231c1a4e4c35632e3b136acd18c2872\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['334'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: action=discard&header=testheader&pattern=testpattern + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: action=hold&header=testheader&pattern=testpattern + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode This header match already exists} + headers: + content-length: ['32'] + 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/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"24aa6e0438131bd5ab07fd5dd7e4326e8268cef5\"", + "list_id": "list.example.com", "member_id": 31, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/31", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"3d5198105c25da87e47d7bb33360be2db35a94fd\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"cb188332b647676c84b3ae9c91430d55d462f504\"", "list_id": "list.example.com", + "member_id": 32, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/32", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"ddab9f7d9f4a65518db5d644425cb3bf63eda468\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader", "http_etag": "\"b55a407e5664a07b70919a16f2df3fc50350c6b5\"", + "pattern": "testpattern", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"671170868231c1a4e4c35632e3b136acd18c2872\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['334'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader", "http_etag": "\"b55a407e5664a07b70919a16f2df3fc50350c6b5\"", + "pattern": "testpattern", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"671170868231c1a4e4c35632e3b136acd18c2872\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['334'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader", "http_etag": "\"b55a407e5664a07b70919a16f2df3fc50350c6b5\"", + "pattern": "testpattern", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"671170868231c1a4e4c35632e3b136acd18c2872\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['334'] + 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/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_delete.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_delete.yaml new file mode 100644 index 0000000..e709f1b --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_delete.yaml @@ -0,0 +1,412 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/33'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/34'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-1&pattern=testpattern-1 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-2&pattern=testpattern-2 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"10fbbb6fcd377277ad5981c151c7a25ced155d78\"", + "list_id": "list.example.com", "member_id": 33, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/33", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"4e2558f66257a9ba350f31812923b5fdfb3c50bf\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"76af7122d166660b40d1d25caee6686a6253732d\"", "list_id": "list.example.com", + "member_id": 34, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/34", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"c5ecb6493075f81740245a5cc8cebfdbc36b91bf\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-1", "http_etag": "\"c3a486a9676bc129986b609d6c416a969869ee26\"", + "pattern": "testpattern-1", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}, + {"action": "discard", "header": "testheader-2", "http_etag": "\"bba2ea72c8931ba99fe39fff8a8a60eed535364c\"", + "pattern": "testpattern-2", "position": 1, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/1"}], + "http_etag": "\"bec4c23ce2239b4c92a78e937618e23381e05436\"", "start": 0, "total_size": + 2}'} + headers: + content-length: ['573'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: action=discard&header=testheader-2&pattern=testpattern-2 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"10fbbb6fcd377277ad5981c151c7a25ced155d78\"", + "list_id": "list.example.com", "member_id": 33, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/33", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"4e2558f66257a9ba350f31812923b5fdfb3c50bf\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"76af7122d166660b40d1d25caee6686a6253732d\"", "list_id": "list.example.com", + "member_id": 34, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/34", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"c5ecb6493075f81740245a5cc8cebfdbc36b91bf\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-2", "http_etag": "\"2cd8d8437154c9cae2c36e33a26cba2f3d28a4ba\"", + "pattern": "testpattern-2", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"2d1630fc20c566905d06499b6a828f16937c25f7\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['338'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-2", "http_etag": "\"2cd8d8437154c9cae2c36e33a26cba2f3d28a4ba\"", + "pattern": "testpattern-2", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"2d1630fc20c566905d06499b6a828f16937c25f7\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['338'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-2", "http_etag": "\"2cd8d8437154c9cae2c36e33a26cba2f3d28a4ba\"", + "pattern": "testpattern-2", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"2d1630fc20c566905d06499b6a828f16937c25f7\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['338'] + 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/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_edit.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_edit.yaml new file mode 100644 index 0000000..b3ecf59 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_edit.yaml @@ -0,0 +1,397 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/35'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/36'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader&pattern=testpattern + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"14ae019a8cfb05cd12df31fc108305b557b35218\"", + "list_id": "list.example.com", "member_id": 35, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/35", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"63675f32453eb2cc497eb888104dc096dc002b35\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"22e2e8b1fe1232879f0e77c8cee8d4e00aabacaa\"", "list_id": "list.example.com", + "member_id": 36, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/36", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"2e0d99d79c5d3bd00bf2f953b35196d5d9c782e6\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader", "http_etag": "\"b55a407e5664a07b70919a16f2df3fc50350c6b5\"", + "pattern": "testpattern", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"671170868231c1a4e4c35632e3b136acd18c2872\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['334'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: action=hold&header=testheader-changed&pattern=testpattern-changed + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"14ae019a8cfb05cd12df31fc108305b557b35218\"", + "list_id": "list.example.com", "member_id": 35, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/35", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"63675f32453eb2cc497eb888104dc096dc002b35\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"22e2e8b1fe1232879f0e77c8cee8d4e00aabacaa\"", "list_id": "list.example.com", + "member_id": 36, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/36", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"2e0d99d79c5d3bd00bf2f953b35196d5d9c782e6\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "hold", "header": "testheader-changed", + "http_etag": "\"c25c7c17bcf5a4e72c8a4dac10c1e368c980e7f4\"", "pattern": "testpattern-changed", + "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"74c71806004b45fd5ef4dd67b5c0f1327e67e9b3\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['347'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "hold", "header": "testheader-changed", + "http_etag": "\"c25c7c17bcf5a4e72c8a4dac10c1e368c980e7f4\"", "pattern": "testpattern-changed", + "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"74c71806004b45fd5ef4dd67b5c0f1327e67e9b3\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['347'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "hold", "header": "testheader-changed", + "http_etag": "\"c25c7c17bcf5a4e72c8a4dac10c1e368c980e7f4\"", "pattern": "testpattern-changed", + "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"74c71806004b45fd5ef4dd67b5c0f1327e67e9b3\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['347'] + 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/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_edit_empty.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_edit_empty.yaml new file mode 100644 index 0000000..6403f16 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_edit_empty.yaml @@ -0,0 +1,262 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/37'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/38'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader&pattern=testpattern + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"252a421b550eda91cf5824541ee433093f4b3652\"", + "list_id": "list.example.com", "member_id": 37, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/37", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"75b4ed79add9779446559c01fd805c3e8e0eb701\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"d5eb3c63d3a73a73205ba4c5de2762d29743e781\"", "list_id": "list.example.com", + "member_id": 38, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/38", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"44a80b69d4cde0a5d2a1dbe88a213bfbbf15e321\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader", "http_etag": "\"b55a407e5664a07b70919a16f2df3fc50350c6b5\"", + "pattern": "testpattern", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"671170868231c1a4e4c35632e3b136acd18c2872\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['334'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader", "http_etag": "\"b55a407e5664a07b70919a16f2df3fc50350c6b5\"", + "pattern": "testpattern", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"671170868231c1a4e4c35632e3b136acd18c2872\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['334'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader", "http_etag": "\"b55a407e5664a07b70919a16f2df3fc50350c6b5\"", + "pattern": "testpattern", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"671170868231c1a4e4c35632e3b136acd18c2872\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['334'] + 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/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_move_down.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_move_down.yaml new file mode 100644 index 0000000..a69135c --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_move_down.yaml @@ -0,0 +1,465 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/39'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/40'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-1&pattern=testpattern-1 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-2&pattern=testpattern-2 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/1'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-3&pattern=testpattern-3 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"dc50cb3ce5de9f03dece5facc59175ec612de2c6\"", + "list_id": "list.example.com", "member_id": 39, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/39", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"83542615dedb3a18452d39fbdf2eed77376de2e2\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"1ebb6cc4a571ac1938020a5f9bee871e03f964e2\"", "list_id": "list.example.com", + "member_id": 40, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/40", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"f53af8d8492c7abdb01e092584e058dfb2212929\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-1", "http_etag": "\"c3a486a9676bc129986b609d6c416a969869ee26\"", + "pattern": "testpattern-1", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}, + {"action": "discard", "header": "testheader-2", "http_etag": "\"bba2ea72c8931ba99fe39fff8a8a60eed535364c\"", + "pattern": "testpattern-2", "position": 1, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/1"}, + {"action": "discard", "header": "testheader-3", "http_etag": "\"2df581da0369aa38136522ba8d8344889bb25ad6\"", + "pattern": "testpattern-3", "position": 2, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/2"}], + "http_etag": "\"ba3ceee3baa41a8f8c736f1aeafdb3e6e47ba738\"", "start": 0, "total_size": + 3}'} + headers: + content-length: ['808'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: action=discard&header=testheader-2&pattern=testpattern-2 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-1&pattern=testpattern-1 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/1'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-3&pattern=testpattern-3 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"dc50cb3ce5de9f03dece5facc59175ec612de2c6\"", + "list_id": "list.example.com", "member_id": 39, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/39", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"83542615dedb3a18452d39fbdf2eed77376de2e2\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"1ebb6cc4a571ac1938020a5f9bee871e03f964e2\"", "list_id": "list.example.com", + "member_id": 40, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/40", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"f53af8d8492c7abdb01e092584e058dfb2212929\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-2", "http_etag": "\"2cd8d8437154c9cae2c36e33a26cba2f3d28a4ba\"", + "pattern": "testpattern-2", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}, + {"action": "discard", "header": "testheader-1", "http_etag": "\"4c6772504a53d084d2df4fc3d5b40d6a8ecdbfa8\"", + "pattern": "testpattern-1", "position": 1, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/1"}, + {"action": "discard", "header": "testheader-3", "http_etag": "\"2df581da0369aa38136522ba8d8344889bb25ad6\"", + "pattern": "testpattern-3", "position": 2, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/2"}], + "http_etag": "\"c57c9047e344d922a13f9b7f836c2e323adc74aa\"", "start": 0, "total_size": + 3}'} + headers: + content-length: ['808'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-2", "http_etag": "\"2cd8d8437154c9cae2c36e33a26cba2f3d28a4ba\"", + "pattern": "testpattern-2", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}, + {"action": "discard", "header": "testheader-1", "http_etag": "\"4c6772504a53d084d2df4fc3d5b40d6a8ecdbfa8\"", + "pattern": "testpattern-1", "position": 1, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/1"}, + {"action": "discard", "header": "testheader-3", "http_etag": "\"2df581da0369aa38136522ba8d8344889bb25ad6\"", + "pattern": "testpattern-3", "position": 2, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/2"}], + "http_etag": "\"c57c9047e344d922a13f9b7f836c2e323adc74aa\"", "start": 0, "total_size": + 3}'} + headers: + content-length: ['808'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-2", "http_etag": "\"2cd8d8437154c9cae2c36e33a26cba2f3d28a4ba\"", + "pattern": "testpattern-2", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}, + {"action": "discard", "header": "testheader-1", "http_etag": "\"4c6772504a53d084d2df4fc3d5b40d6a8ecdbfa8\"", + "pattern": "testpattern-1", "position": 1, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/1"}, + {"action": "discard", "header": "testheader-3", "http_etag": "\"2df581da0369aa38136522ba8d8344889bb25ad6\"", + "pattern": "testpattern-3", "position": 2, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/2"}], + "http_etag": "\"c57c9047e344d922a13f9b7f836c2e323adc74aa\"", "start": 0, "total_size": + 3}'} + headers: + content-length: ['808'] + 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/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_move_up.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_move_up.yaml new file mode 100644 index 0000000..574b823 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_move_up.yaml @@ -0,0 +1,465 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/41'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/42'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-1&pattern=testpattern-1 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-2&pattern=testpattern-2 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/1'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-3&pattern=testpattern-3 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"92b61a0ee84f80a7f4c676d473ffb124d9df53a4\"", + "list_id": "list.example.com", "member_id": 41, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/41", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"b8df021395e3259776c0d9d79f95713c3b898de0\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"592cf4e14d8eb96c825f2e9b008665edd020bad7\"", "list_id": "list.example.com", + "member_id": 42, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/42", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"9f0773a57c53447b61d6067bb9901272da4a0d7c\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-1", "http_etag": "\"c3a486a9676bc129986b609d6c416a969869ee26\"", + "pattern": "testpattern-1", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}, + {"action": "discard", "header": "testheader-2", "http_etag": "\"bba2ea72c8931ba99fe39fff8a8a60eed535364c\"", + "pattern": "testpattern-2", "position": 1, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/1"}, + {"action": "discard", "header": "testheader-3", "http_etag": "\"2df581da0369aa38136522ba8d8344889bb25ad6\"", + "pattern": "testpattern-3", "position": 2, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/2"}], + "http_etag": "\"ba3ceee3baa41a8f8c736f1aeafdb3e6e47ba738\"", "start": 0, "total_size": + 3}'} + headers: + content-length: ['808'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: action=discard&header=testheader-1&pattern=testpattern-1 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-3&pattern=testpattern-3 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/1'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-2&pattern=testpattern-2 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"92b61a0ee84f80a7f4c676d473ffb124d9df53a4\"", + "list_id": "list.example.com", "member_id": 41, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/41", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"b8df021395e3259776c0d9d79f95713c3b898de0\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"592cf4e14d8eb96c825f2e9b008665edd020bad7\"", "list_id": "list.example.com", + "member_id": 42, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/42", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"9f0773a57c53447b61d6067bb9901272da4a0d7c\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-1", "http_etag": "\"c3a486a9676bc129986b609d6c416a969869ee26\"", + "pattern": "testpattern-1", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}, + {"action": "discard", "header": "testheader-3", "http_etag": "\"ea5d60499e0a3914cf5cc1ee755daffad389da7e\"", + "pattern": "testpattern-3", "position": 1, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/1"}, + {"action": "discard", "header": "testheader-2", "http_etag": "\"5997adfad58ca254055719309c024387d8f86389\"", + "pattern": "testpattern-2", "position": 2, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/2"}], + "http_etag": "\"98b27062bded2565f8eb290234dd691db36f06b5\"", "start": 0, "total_size": + 3}'} + headers: + content-length: ['808'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-1", "http_etag": "\"c3a486a9676bc129986b609d6c416a969869ee26\"", + "pattern": "testpattern-1", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}, + {"action": "discard", "header": "testheader-3", "http_etag": "\"ea5d60499e0a3914cf5cc1ee755daffad389da7e\"", + "pattern": "testpattern-3", "position": 1, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/1"}, + {"action": "discard", "header": "testheader-2", "http_etag": "\"5997adfad58ca254055719309c024387d8f86389\"", + "pattern": "testpattern-2", "position": 2, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/2"}], + "http_etag": "\"98b27062bded2565f8eb290234dd691db36f06b5\"", "start": 0, "total_size": + 3}'} + headers: + content-length: ['808'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-1", "http_etag": "\"c3a486a9676bc129986b609d6c416a969869ee26\"", + "pattern": "testpattern-1", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}, + {"action": "discard", "header": "testheader-3", "http_etag": "\"ea5d60499e0a3914cf5cc1ee755daffad389da7e\"", + "pattern": "testpattern-3", "position": 1, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/1"}, + {"action": "discard", "header": "testheader-2", "http_etag": "\"5997adfad58ca254055719309c024387d8f86389\"", + "pattern": "testpattern-2", "position": 2, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/2"}], + "http_etag": "\"98b27062bded2565f8eb290234dd691db36f06b5\"", "start": 0, "total_size": + 3}'} + headers: + content-length: ['808'] + 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/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_not_accessible_for_moderator.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_not_accessible_for_moderator.yaml new file mode 100644 index 0000000..d8b57bd --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_not_accessible_for_moderator.yaml @@ -0,0 +1,187 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/43'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/44'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/moderator@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"c7360c029a83c97672ca38dd8b008d48e05949a6\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/7", "user_id": 7}'} + 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/7/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "moderator@example.com", + "http_etag": "\"dc9e6ab7f685df3bdee82a1b48abcc345c24c317\"", "original_email": + "moderator@example.com", "registered_on": "2005-08-01T07:49:23", "self_link": + "http://localhost:9001/3.0/addresses/moderator@example.com", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"61e6b2b734fab9e85bac3022e2728ddca6d73b95\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['402'] + 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/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"c9f6c0d587e4143610eeb960cb412de154275c92\"", + "list_id": "list.example.com", "member_id": 43, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/43", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"154cf2b68807d6472e0cb8c3591f6254761f67c4\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"8c3456470fb93b6d3c15197902b2f4a708b52a54\"", "list_id": "list.example.com", + "member_id": 44, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/44", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"803b725ac7063bb6a16fe45ed318ed5d22cb92d1\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_page_accessible_for_owner.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_page_accessible_for_owner.yaml new file mode 100644 index 0000000..50f4d17 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_page_accessible_for_owner.yaml @@ -0,0 +1,214 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/45'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/46'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"8f7fc3a67de52fc8d1e2d49c1bb3e03865c4db34\"", + "list_id": "list.example.com", "member_id": 45, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/45", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"55f57eddd9af2d55ccbf134c81919642eb11458b\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"d78a43f13bb30795f544ebc72cfe44d3d13fc859\"", "list_id": "list.example.com", + "member_id": 46, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/46", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"f3465fb200ee45cc8210495679d764339ef216d2\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + 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 DELETE + uri: http://localhost:9001/3.0/lists/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_page_accessible_for_superuser.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_page_accessible_for_superuser.yaml new file mode 100644 index 0000000..27a7355 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_page_accessible_for_superuser.yaml @@ -0,0 +1,134 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/47'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/48'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + 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 DELETE + uri: http://localhost:9001/3.0/lists/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_page_not_accessible_for_unprivileged_users.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_page_not_accessible_for_unprivileged_users.yaml new file mode 100644 index 0000000..7be9e1b --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_page_not_accessible_for_unprivileged_users.yaml @@ -0,0 +1,168 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/49'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/50'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/test@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/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"f9fd342fceee59923e68847bca8b082069bbb410\"", + "list_id": "list.example.com", "member_id": 49, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/49", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"accce8d55e0b6b611dedfc7e51af055f1879701e\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"44774439cb4a8c773729c867bd17defcefd63ddd\"", "list_id": "list.example.com", + "member_id": 50, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/50", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"8419ff2e40e8a68aa07ffaaa3fe3d5be0ff636e9\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_page_not_accessible_if_not_logged_in.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_page_not_accessible_if_not_logged_in.yaml new file mode 100644 index 0000000..7a69912 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_page_not_accessible_if_not_logged_in.yaml @@ -0,0 +1,106 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/51'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/52'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode DELETE + uri: http://localhost:9001/3.0/lists/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_same_order.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_same_order.yaml new file mode 100644 index 0000000..9d23707 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_same_order.yaml @@ -0,0 +1,281 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/53'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/54'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-1&pattern=testpattern-1 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader-2&pattern=testpattern-2 + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"5539713a0257fa9391b364f09fa8d9ed4f01a02e\"", + "list_id": "list.example.com", "member_id": 53, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/53", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"725d292c971893d17e0b86fa0e154e3ab97e3ed1\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"ffaa34a2dc22f6a5074d9e423c5c3982eb8bbeba\"", "list_id": "list.example.com", + "member_id": 54, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/54", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"5c4526ab4a817ab9d98d5d5a8c0e08603131bbcb\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-1", "http_etag": "\"c3a486a9676bc129986b609d6c416a969869ee26\"", + "pattern": "testpattern-1", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}, + {"action": "discard", "header": "testheader-2", "http_etag": "\"bba2ea72c8931ba99fe39fff8a8a60eed535364c\"", + "pattern": "testpattern-2", "position": 1, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/1"}], + "http_etag": "\"bec4c23ce2239b4c92a78e937618e23381e05436\"", "start": 0, "total_size": + 2}'} + headers: + content-length: ['573'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-1", "http_etag": "\"c3a486a9676bc129986b609d6c416a969869ee26\"", + "pattern": "testpattern-1", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}, + {"action": "discard", "header": "testheader-2", "http_etag": "\"bba2ea72c8931ba99fe39fff8a8a60eed535364c\"", + "pattern": "testpattern-2", "position": 1, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/1"}], + "http_etag": "\"bec4c23ce2239b4c92a78e937618e23381e05436\"", "start": 0, "total_size": + 2}'} + headers: + content-length: ['573'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader-1", "http_etag": "\"c3a486a9676bc129986b609d6c416a969869ee26\"", + "pattern": "testpattern-1", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}, + {"action": "discard", "header": "testheader-2", "http_etag": "\"bba2ea72c8931ba99fe39fff8a8a60eed535364c\"", + "pattern": "testpattern-2", "position": 1, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/1"}], + "http_etag": "\"bec4c23ce2239b4c92a78e937618e23381e05436\"", "start": 0, "total_size": + 2}'} + headers: + content-length: ['573'] + 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/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_show_existing.yaml b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_show_existing.yaml new file mode 100644 index 0000000..42630a1 --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/ListHeaderMatchesTest.test_show_existing.yaml @@ -0,0 +1,230 @@ +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=list%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/list.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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: list_id=list.example.com&role=owner&subscriber=owner%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/55'] + status: {code: 201, message: Created} +- request: + body: list_id=list.example.com&role=moderator&subscriber=moderator%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/members + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/members/56'] + status: {code: 201, message: Created} +- request: + body: action=discard&header=testheader&pattern=testpattern + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + location: ['http://localhost:9001/3.0/lists/list.example.com/header-matches/0'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/owner@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"b774d488fd2356b7bedf0e6fa4a26dc70dc2b02b\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/6", "user_id": 6}'} + 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/6/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "owner@example.com", "http_etag": + "\"7efeccdd4edd0bed02cd2141365a115239f83be4\"", "original_email": "owner@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/owner@example.com", + "user": "http://localhost:9001/3.0/users/6"}], "http_etag": "\"a565f7d323e0a6ca5da35f6d965148fe4fe03fbb\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['390'] + content-type: [application/json; charset=utf-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/lists/list.example.com/roster/owner + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/owner@example.com", + "delivery_mode": "regular", "email": "owner@example.com", "http_etag": "\"626ae3b3f35f453a431550641696ee185aadedc4\"", + "list_id": "list.example.com", "member_id": 55, "moderation_action": "accept", + "role": "owner", "self_link": "http://localhost:9001/3.0/members/55", "user": + "http://localhost:9001/3.0/users/6"}], "http_etag": "\"2dd277919ea20b22a41e6b84ea110360efb41fd6\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['486'] + 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/list.example.com/roster/moderator + response: + body: {string: !!python/unicode '{"entries": [{"address": "http://localhost:9001/3.0/addresses/moderator@example.com", + "delivery_mode": "regular", "email": "moderator@example.com", "http_etag": + "\"6b39ff26b36070746b0e2e9f0f908739218c80c4\"", "list_id": "list.example.com", + "member_id": 56, "moderation_action": "accept", "role": "moderator", "self_link": + "http://localhost:9001/3.0/members/56", "user": "http://localhost:9001/3.0/users/7"}], + "http_etag": "\"28e96e21e091145c3b09eb82685e725bc632eedd\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['498'] + 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/list.example.com + response: + body: {string: !!python/unicode '{"display_name": "List", "fqdn_listname": "list@example.com", + "http_etag": "\"e6a4f3c403f35e4c9a30c19f07bf0e36fa03e45b\"", "list_id": "list.example.com", + "list_name": "list", "mail_host": "example.com", "member_count": 0, "self_link": + "http://localhost:9001/3.0/lists/list.example.com", "volume": 1}'} + headers: + content-length: ['299'] + 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/list.example.com/header-matches + response: + body: {string: !!python/unicode '{"entries": [{"action": "discard", "header": + "testheader", "http_etag": "\"b55a407e5664a07b70919a16f2df3fc50350c6b5\"", + "pattern": "testpattern", "position": 0, "self_link": "http://localhost:9001/3.0/lists/list.example.com/header-matches/0"}], + "http_etag": "\"671170868231c1a4e4c35632e3b136acd18c2872\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['334'] + 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/list@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 DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/mailman_api_tests/test_list_header_matches.py b/src/postorius/tests/mailman_api_tests/test_list_header_matches.py new file mode 100644 index 0000000..1e2975e --- /dev/null +++ b/src/postorius/tests/mailman_api_tests/test_list_header_matches.py @@ -0,0 +1,472 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2016 by the Free Software Foundation, Inc. +# +# This file is part of Postorius. +# +# Postorius is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# Postorius is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# Postorius. If not, see . + +"""Tests for list header matches""" + +from __future__ import absolute_import, print_function, unicode_literals + +from django.contrib.auth.models import User +from django.core.urlresolvers import reverse +from django.utils.timezone import now +from six.moves.urllib_error import HTTPError +from six.moves.urllib_parse import quote + +from postorius.models import MailmanUser, Mailman404Error, List +from postorius.tests.utils import ViewTestCase + + + +class ListHeaderMatchesTest(ViewTestCase): + """ + Tests for the list settings page. + """ + + def setUp(self): + super(ListHeaderMatchesTest, self).setUp() + self.domain = self.mm_client.create_domain('example.com') + self.mlist = self.domain.create_list('list') + self.user = User.objects.create_user( + 'testuser', 'test@example.com', 'testpass') + self.superuser = User.objects.create_superuser( + 'testsu', 'su@example.com', 'testpass') + self.owner = User.objects.create_user( + 'testowner', 'owner@example.com', 'testpass') + self.moderator = User.objects.create_user( + 'testmoderator', 'moderator@example.com', 'testpass') + self.mlist.add_owner('owner@example.com') + self.mlist.add_moderator('moderator@example.com') + + def tearDown(self): + self.user.delete() + self.superuser.delete() + self.owner.delete() + self.moderator.delete() + self.mlist.delete() + self.domain.delete() + + def test_page_not_accessible_if_not_logged_in(self): + url = reverse('list_header_matches', args=['list.example.com']) + self.assertRedirectsToLogin(url) + + def test_page_not_accessible_for_unprivileged_users(self): + self.client.login(username='testuser', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + response = self.client.get(url) + self.assertEqual(response.status_code, 403) + + def test_not_accessible_for_moderator(self): + self.client.login(username='testmoderator', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + response = self.client.get(url) + self.assertEqual(response.status_code, 403) + + def test_page_accessible_for_owner(self): + self.client.login(username='testowner', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + + def test_page_accessible_for_superuser(self): + self.client.login(username='testsu', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + + def test_show_existing(self): + self.mlist.header_matches.add( + header='testheader', pattern='testpattern', action='discard') + self.client.login(username='testowner', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + self.assertEqual(len(response.context["formset"]), 2) + self.assertEqual( + response.context["formset"].initial, + [{'header': u'testheader', 'pattern': u'testpattern', + 'action': u'discard'}]) + self.assertContains(response, 'testheader') + self.assertContains(response, 'testpattern') + self.assertContains(response, 'value="discard" selected="selected"') + # the new header match subform should not have ORDER or DELETE fields + self.assertNotContains(response, 'form-1-ORDER') + self.assertNotContains(response, 'form-1-DELETE') + + def test_add(self): + self.client.login(username='testowner', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + data = { + # Management form + 'form-TOTAL_FORMS': '1', + 'form-INITIAL_FORMS': '0', + 'form-MIN_NUM_FORMS': '0', + 'form-MAX_NUM_FORMS': '1000', + # New form + 'form-0-header': 'testheader', + 'form-0-pattern': 'testpattern', + 'form-0-action': 'discard', + } + response = self.client.post(url, data) + self.assertRedirects(response, url) + self.assertHasSuccessMessage(response) + self.assertEqual(len(self.mlist.header_matches), 1) + hm = self.mlist.header_matches[0] + self.assertEqual(hm.header, 'testheader') + self.assertEqual(hm.pattern, 'testpattern') + self.assertEqual(hm.action, 'discard') + + def test_add_empty(self): + self.client.login(username='testowner', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + data = { + # Management form + 'form-TOTAL_FORMS': '1', + 'form-INITIAL_FORMS': '0', + 'form-MIN_NUM_FORMS': '0', + 'form-MAX_NUM_FORMS': '1000', + # New form + 'form-0-header': '', + 'form-0-pattern': '', + 'form-0-action': '', + } + response = self.client.post(url, data) + self.assertRedirects(response, url) + #from postorius.tests.utils import get_flash_messages + #msgs = get_flash_messages(response) + #print([m.message for m in msgs]) + self.assertHasNoMessage(response) + self.assertEqual(len(self.mlist.header_matches), 0) + + def test_add_empty_header(self): + self.client.login(username='testowner', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + data = { + # Management form + 'form-TOTAL_FORMS': '1', + 'form-INITIAL_FORMS': '0', + 'form-MIN_NUM_FORMS': '0', + 'form-MAX_NUM_FORMS': '1000', + # New form + 'form-0-header': '', + 'form-0-pattern': 'testpattern', + 'form-0-action': '', + } + response = self.client.post(url, data) + self.assertEqual(response.status_code, 200) + self.assertHasNoMessage(response) + self.assertEqual( + response.context["formset"].errors, + [{'header': [u'Please enter a header.']}]) + self.assertEqual(len(self.mlist.header_matches), 0) + + def test_add_empty_pattern(self): + self.client.login(username='testowner', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + data = { + # Management form + 'form-TOTAL_FORMS': '1', + 'form-INITIAL_FORMS': '0', + 'form-MIN_NUM_FORMS': '0', + 'form-MAX_NUM_FORMS': '1000', + # New form + 'form-0-header': 'testheader', + 'form-0-pattern': '', + 'form-0-action': '', + } + response = self.client.post(url, data) + self.assertEqual(response.status_code, 200) + self.assertHasNoMessage(response) + self.assertEqual( + response.context["formset"].errors, + [{'pattern': [u'Please enter a pattern.']}]) + self.assertEqual(len(self.mlist.header_matches), 0) + + def test_edit(self): + self.mlist.header_matches.add( + header='testheader', pattern='testpattern', action='discard') + self.client.login(username='testowner', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + data = { + # Management form + 'form-TOTAL_FORMS': '2', + 'form-INITIAL_FORMS': '1', + 'form-MIN_NUM_FORMS': '0', + 'form-MAX_NUM_FORMS': '1000', + # Existing pattern + 'form-0-header': 'testheader-changed', + 'form-0-pattern': 'testpattern-changed', + 'form-0-action': 'hold', + 'form-0-ORDER': '1', + 'form-0-DELETE': '', + # New form + 'form-1-header': '', + 'form-1-pattern': '', + 'form-1-action': '', + } + response = self.client.post(url, data) + self.assertRedirects(response, url) + self.assertHasSuccessMessage(response) + self.assertEqual(len(self.mlist.header_matches), 1) + hm = self.mlist.header_matches[0] + self.assertEqual(hm.header, 'testheader-changed') + self.assertEqual(hm.pattern, 'testpattern-changed') + self.assertEqual(hm.action, 'hold') + + def test_edit_empty(self): + self.mlist.header_matches.add( + header='testheader', pattern='testpattern', action='discard') + self.client.login(username='testowner', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + data = { + # Management form + 'form-TOTAL_FORMS': '2', + 'form-INITIAL_FORMS': '1', + 'form-MIN_NUM_FORMS': '0', + 'form-MAX_NUM_FORMS': '1000', + # Existing pattern + 'form-0-header': '', + 'form-0-pattern': '', + 'form-0-action': '', + 'form-0-ORDER': '1', + 'form-0-DELETE': '', + # New form + 'form-1-header': '', + 'form-1-pattern': '', + 'form-1-action': '', + } + response = self.client.post(url, data) + self.assertEqual(response.status_code, 200) + self.assertHasNoMessage(response) + self.assertEqual( + response.context["formset"].errors, + [{'header': [u'Please enter a header.'], + 'pattern': [u'Please enter a pattern.'], + }, {}]) + self.assertEqual(len(self.mlist.header_matches), 1) + hm = self.mlist.header_matches[0] + self.assertEqual(hm.header, 'testheader') + self.assertEqual(hm.pattern, 'testpattern') + self.assertEqual(hm.action, 'discard') + + def test_delete(self): + self.mlist.header_matches.add( + header='testheader-1', pattern='testpattern-1', action='discard') + self.mlist.header_matches.add( + header='testheader-2', pattern='testpattern-2', action='discard') + self.client.login(username='testowner', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + data = { + # Management form + 'form-TOTAL_FORMS': '3', + 'form-INITIAL_FORMS': '2', + 'form-MIN_NUM_FORMS': '0', + 'form-MAX_NUM_FORMS': '1000', + # Existing pattern + 'form-0-header': 'testheader-1', + 'form-0-pattern': 'testpattern-1', + 'form-0-action': 'hold', + 'form-0-ORDER': '1', + 'form-0-DELETE': '1', + 'form-1-header': 'testheader-2', + 'form-1-pattern': 'testpattern-2', + 'form-1-action': 'discard', + 'form-1-ORDER': '2', + 'form-1-DELETE': '', + # New form + 'form-2-header': '', + 'form-2-pattern': '', + 'form-2-action': '', + } + response = self.client.post(url, data) + self.assertRedirects(response, url) + self.assertHasSuccessMessage(response) + self.assertEqual(len(self.mlist.header_matches), 1) + hm = self.mlist.header_matches[0] + self.assertEqual(hm.header, 'testheader-2') + self.assertEqual(hm.pattern, 'testpattern-2') + self.assertEqual(hm.action, 'discard') + + def test_move_up(self): + self.mlist.header_matches.add( + header='testheader-1', pattern='testpattern-1', action='discard') + self.mlist.header_matches.add( + header='testheader-2', pattern='testpattern-2', action='discard') + self.mlist.header_matches.add( + header='testheader-3', pattern='testpattern-3', action='discard') + self.client.login(username='testowner', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + data = { + # Management form + 'form-TOTAL_FORMS': '4', + 'form-INITIAL_FORMS': '3', + 'form-MIN_NUM_FORMS': '0', + 'form-MAX_NUM_FORMS': '1000', + # Existing patterns + 'form-0-header': 'testheader-1', + 'form-0-pattern': 'testpattern-1', + 'form-0-action': 'discard', + 'form-0-ORDER': '1', + 'form-0-DELETE': '', + 'form-1-header': 'testheader-2', + 'form-1-pattern': 'testpattern-2', + 'form-1-action': 'discard', + 'form-1-ORDER': '3', + 'form-1-DELETE': '', + 'form-2-header': 'testheader-3', + 'form-2-pattern': 'testpattern-3', + 'form-2-action': 'discard', + 'form-2-ORDER': '2', + 'form-2-DELETE': '', + # New form + 'form-3-header': '', + 'form-3-pattern': '', + 'form-3-action': '', + } + response = self.client.post(url, data) + self.assertRedirects(response, url) + self.assertHasSuccessMessage(response) + self.assertEqual(len(self.mlist.header_matches), 3) + self.assertEqual( + [(hm.header, hm.pattern, hm.action) + for hm in self.mlist.header_matches], + [('testheader-1', 'testpattern-1', 'discard'), + ('testheader-3', 'testpattern-3', 'discard'), + ('testheader-2', 'testpattern-2', 'discard')] + ) + + def test_move_down(self): + self.mlist.header_matches.add( + header='testheader-1', pattern='testpattern-1', action='discard') + self.mlist.header_matches.add( + header='testheader-2', pattern='testpattern-2', action='discard') + self.mlist.header_matches.add( + header='testheader-3', pattern='testpattern-3', action='discard') + self.client.login(username='testowner', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + data = { + # Management form + 'form-TOTAL_FORMS': '4', + 'form-INITIAL_FORMS': '3', + 'form-MIN_NUM_FORMS': '0', + 'form-MAX_NUM_FORMS': '1000', + # Existing patterns + 'form-0-header': 'testheader-1', + 'form-0-pattern': 'testpattern-1', + 'form-0-action': 'discard', + 'form-0-ORDER': '2', + 'form-0-DELETE': '', + 'form-1-header': 'testheader-2', + 'form-1-pattern': 'testpattern-2', + 'form-1-action': 'discard', + 'form-1-ORDER': '1', + 'form-1-DELETE': '', + 'form-2-header': 'testheader-3', + 'form-2-pattern': 'testpattern-3', + 'form-2-action': 'discard', + 'form-2-ORDER': '3', + 'form-2-DELETE': '', + # New form + 'form-3-header': '', + 'form-3-pattern': '', + 'form-3-action': '', + } + response = self.client.post(url, data) + self.assertRedirects(response, url) + self.assertHasSuccessMessage(response) + self.assertEqual(len(self.mlist.header_matches), 3) + self.assertEqual( + [(hm.header, hm.pattern, hm.action) + for hm in self.mlist.header_matches], + [('testheader-2', 'testpattern-2', 'discard'), + ('testheader-1', 'testpattern-1', 'discard'), + ('testheader-3', 'testpattern-3', 'discard')] + ) + + def test_same_order(self): + self.mlist.header_matches.add( + header='testheader-1', pattern='testpattern-1', action='discard') + self.mlist.header_matches.add( + header='testheader-2', pattern='testpattern-2', action='discard') + self.client.login(username='testowner', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + data = { + # Management form + 'form-TOTAL_FORMS': '3', + 'form-INITIAL_FORMS': '2', + 'form-MIN_NUM_FORMS': '0', + 'form-MAX_NUM_FORMS': '1000', + # Existing patterns + 'form-0-header': 'testheader-1', + 'form-0-pattern': 'testpattern-1', + 'form-0-action': 'discard', + 'form-0-ORDER': '1', + 'form-0-DELETE': '', + 'form-1-header': 'testheader-2', + 'form-1-pattern': 'testpattern-2', + 'form-1-action': 'discard', + 'form-1-ORDER': '1', + 'form-1-DELETE': '', + # New form + 'form-2-header': '', + 'form-2-pattern': '', + 'form-2-action': '', + } + response = self.client.post(url, data) + self.assertEqual(response.status_code, 200) + self.assertHasNoMessage(response) + for form_errors in response.context["formset"].errors: + self.assertEqual(len(form_errors), 0) + self.assertEqual( + response.context["formset"].non_form_errors(), + ['Header matches must have distinct orders.']) + self.assertEqual(len(self.mlist.header_matches), 2) + self.assertEqual( + [(hm.header, hm.pattern, hm.action) + for hm in self.mlist.header_matches], + [('testheader-1', 'testpattern-1', 'discard'), + ('testheader-2', 'testpattern-2', 'discard')] + ) + + def test_add_existing(self): + self.mlist.header_matches.add( + header='testheader', pattern='testpattern', action='discard') + self.client.login(username='testowner', password='testpass') + url = reverse('list_header_matches', args=['list.example.com']) + data = { + # Management form + 'form-TOTAL_FORMS': '2', + 'form-INITIAL_FORMS': '1', + 'form-MIN_NUM_FORMS': '0', + 'form-MAX_NUM_FORMS': '1000', + # Existing patterns + 'form-0-header': 'testheader', + 'form-0-pattern': 'testpattern', + 'form-0-action': 'discard', + 'form-0-ORDER': '1', + 'form-0-DELETE': '', + # New form + 'form-1-header': 'testheader', + 'form-1-pattern': 'testpattern', + 'form-1-action': 'hold', + } + response = self.client.post(url, data) + self.assertRedirects(response, url) + self.assertHasErrorMessage(response) + self.assertEqual(len(self.mlist.header_matches), 1) + self.assertEqual( + [(hm.header, hm.pattern, hm.action) + for hm in self.mlist.header_matches], + [('testheader', 'testpattern', 'discard')]) diff --git a/src/postorius/tests/mailman_api_tests/test_list_settings.py b/src/postorius/tests/mailman_api_tests/test_list_settings.py index 516e889..c6204ff 100644 --- a/src/postorius/tests/mailman_api_tests/test_list_settings.py +++ b/src/postorius/tests/mailman_api_tests/test_list_settings.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License along with # Postorius. If not, see . -"""Tests for ban lists""" +"""Tests for list settings""" from __future__ import absolute_import, print_function, unicode_literals diff --git a/src/postorius/tests/utils.py b/src/postorius/tests/utils.py index dc70f10..d9786eb 100644 --- a/src/postorius/tests/utils.py +++ b/src/postorius/tests/utils.py @@ -129,6 +129,10 @@ self.assertEqual(msgs[0].level, messages.ERROR, msgs[0].message) return msgs[0].message + def assertHasNoMessage(self, response): + msgs = get_flash_messages(response) + self.assertEqual(len(msgs), 0) + def assertRedirectsToLogin(self, url): response = self.client.get(url) self.assertRedirects(response, diff --git a/src/postorius/urls.py b/src/postorius/urls.py index 0d2f55c..ef58024 100644 --- a/src/postorius/urls.py +++ b/src/postorius/urls.py @@ -52,6 +52,7 @@ name='reject_held_message'), url(r'^held_messages$', list_views.list_moderation, name='list_held_messages'), url(r'^bans/$', list_views.list_bans, name='list_bans'), + url(r'^header-matches/$', list_views.list_header_matches, name='list_header_matches'), url(r'^remove/(?P[^/]+)/(?P
[^/]+)', list_views.remove_role, name='remove_role'), url(r'^settings/(?P[^/]+)?$', list_views.list_settings, name='list_settings'), url(r'^unsubscribe_all$', list_views.remove_all_subscribers, name='unsubscribe_all'), diff --git a/src/postorius/views/list.py b/src/postorius/views/list.py index 8bb777d..451b1f2 100644 --- a/src/postorius/views/list.py +++ b/src/postorius/views/list.py @@ -15,6 +15,7 @@ # # You should have received a copy of the GNU General Public License along with # Postorius. If not, see . + import logging import csv @@ -24,6 +25,7 @@ from django.contrib.auth.decorators import (login_required, user_passes_test) from django.core.urlresolvers import reverse +from django.forms import formset_factory from django.shortcuts import render, redirect from django.template import RequestContext from django.core.exceptions import ValidationError @@ -809,3 +811,68 @@ 'list': m_list, 'addban_form': addban_form, }) + + +@login_required +@list_owner_required +def list_header_matches(request, list_id): + """ + View and edit the list's header matches. + """ + m_list = List.objects.get_or_404(fqdn_listname=list_id) + header_matches = m_list.header_matches + HeaderMatchFormset = formset_factory( + ListHeaderMatchForm, extra=1, can_delete=True, can_order=True, + formset=ListHeaderMatchFormset) + initial_data = [ + dict([ + (key, getattr(hm, key)) for key in ListHeaderMatchForm.base_fields + ]) for hm in header_matches] + + # Process form submission. + if request.method == 'POST': + formset = HeaderMatchFormset(request.POST, initial=initial_data) + if formset.is_valid(): + if not formset.has_changed(): + return redirect('list_header_matches', list_id) + # Purge the existing header_matches + header_matches.clear() + # Add the ones in the form + def form_order(f): + # If ORDER is None (new header match), add it last. + return f.cleaned_data.get('ORDER') or len(formset.forms) + errors = [] + for form in sorted(formset, key=form_order): + if 'header' not in form.cleaned_data: + # The new header match form was not filled + continue + if form.cleaned_data.get('DELETE'): + continue + try: + header_matches.add( + header=form.cleaned_data['header'], + pattern=form.cleaned_data['pattern'], + action=form.cleaned_data['action'], + ) + except HTTPError as e: + errors.append(e) + for e in errors: + messages.error( + request, _('An error occured: %s') % e.reason) + if not errors: + messages.success(request, + _('The header matches were successfully modified.')) + return redirect('list_header_matches', list_id) + else: + formset = HeaderMatchFormset(initial=initial_data) + # Adapt the last form to create new matches + form_new = formset.forms[-1] + form_new.fields['header'].widget.attrs['placeholder'] = _('New header') + form_new.fields['pattern'].widget.attrs['placeholder'] = _('New pattern') + del form_new.fields['ORDER'] + del form_new.fields['DELETE'] + + return render(request, 'postorius/lists/header_matches.html', { + 'list': m_list, + 'formset': formset, + })