diff --git a/src/postorius/forms.py b/src/postorius/forms.py
index 708165e..c18c91f 100644
--- a/src/postorius/forms.py
+++ b/src/postorius/forms.py
@@ -629,6 +629,18 @@
layout = [["Mass Removal", "emails"]]
+class ListAddBanForm(forms.Form):
+ """Ban an email address for a list."""
+ email = forms.CharField(
+ label=_('Add ban'),
+ help_text=_(
+ 'You can ban a single email address or use a regular expression '
+ 'to match similar email addresses.'),
+ error_messages={
+ 'required': _('Please enter an email adddress.'),
+ 'invalid': _('Please enter a valid email adddress.')})
+
+
class UserPreferences(FieldsetForm):
"""
diff --git a/src/postorius/static/postorius/css/style.css b/src/postorius/static/postorius/css/style.css
index d902126..894097c 100644
--- a/src/postorius/static/postorius/css/style.css
+++ b/src/postorius/static/postorius/css/style.css
@@ -24,3 +24,10 @@
.margin-bottom {
margin-bottom: 1em;
}
+
+form.bans-add-form {
+ margin-bottom: 2.5em;
+}
+table.bans-current {
+ width: auto;
+}
diff --git a/src/postorius/templates/postorius/lists/bans.html b/src/postorius/templates/postorius/lists/bans.html
new file mode 100644
index 0000000..9d57940
--- /dev/null
+++ b/src/postorius/templates/postorius/lists/bans.html
@@ -0,0 +1,64 @@
+{% extends postorius_base_template %}
+{% load i18n %}
+{% load bootstrap_tags %}
+{% load nav_helpers %}
+
+{% block subtitle %}
+{% trans 'Banned addresses' %} | {{ list.fqdn_listname }}
+{% endblock %}
+
+{% block main %}
+
+ {% list_nav 'list_bans' 'Banned addresses' %}
+
+
+
+
+
+ {% trans 'Currently banned addresses' %}
+
+ {% with list_bans=list.bans %}
+
+ {% if list_bans|length > 0 %}
+
+
+ {% for ban in list.bans %}
+
+ {{ ban.email }} |
+
+
+ |
+
+ {% endfor %}
+
+
+ {% else %}
+ {% trans 'No addresses are currently banned.' %}
+ {% endif %}
+
+ {% endwith %}
+
+{% endblock %}
+
diff --git a/src/postorius/templates/postorius/menu/list_nav.html b/src/postorius/templates/postorius/menu/list_nav.html
index 4349819..852875a 100644
--- a/src/postorius/templates/postorius/menu/list_nav.html
+++ b/src/postorius/templates/postorius/menu/list_nav.html
@@ -23,7 +23,8 @@
{% trans 'Settings' %}
{% trans 'Mass subscribe' %}
{% trans 'Mass removal' %}
- {% trans 'Archivers' %}
+ {% trans 'Banned addresses' %}
+ {% trans 'Archivers' %}
{% trans 'Delete list' %}
{% endif %}
diff --git a/src/postorius/tests/fixtures/vcr_cassettes/list_bans.yaml b/src/postorius/tests/fixtures/vcr_cassettes/list_bans.yaml
new file mode 100644
index 0000000..79ae65b
--- /dev/null
+++ b/src/postorius/tests/fixtures/vcr_cassettes/list_bans.yaml
@@ -0,0 +1,745 @@
+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=test_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/test_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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_list.example.com/bans
+ 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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_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}
+- 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=test_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/test_list.example.com']
+ status: {code: 201, message: Created}
+- request:
+ body: null
+ headers:
+ accept-encoding: ['gzip, deflate']
+ method: !!python/unicode DELETE
+ uri: http://localhost:9001/3.0/lists/test_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}
+- 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=test_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/test_list.example.com']
+ status: {code: 201, message: Created}
+- request:
+ body: null
+ headers:
+ accept-encoding: ['gzip, deflate']
+ method: !!python/unicode DELETE
+ uri: http://localhost:9001/3.0/lists/test_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}
+- 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=test_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/test_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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_list.example.com/bans
+ 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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_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}
+- 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=test_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/test_list.example.com']
+ status: {code: 201, message: Created}
+- request:
+ body: null
+ headers:
+ accept-encoding: ['gzip, deflate']
+ method: !!python/unicode DELETE
+ uri: http://localhost:9001/3.0/lists/test_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}
+- 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=test_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/test_list.example.com']
+ status: {code: 201, message: Created}
+- request:
+ body: null
+ headers:
+ accept-encoding: ['gzip, deflate']
+ method: !!python/unicode DELETE
+ uri: http://localhost:9001/3.0/lists/test_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}
+- 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=test_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/test_list.example.com']
+ status: {code: 201, message: Created}
+- request:
+ body: null
+ headers:
+ accept-encoding: ['gzip, deflate']
+ method: !!python/unicode DELETE
+ uri: http://localhost:9001/3.0/lists/test_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}
+- 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=test_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/test_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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_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}
+- 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=test_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/test_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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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_user@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/test_list.example.com/roster/owner
+ response:
+ body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"",
+ "start": 0, "total_size": 0}'}
+ headers:
+ content-length: ['90']
+ content-type: [application/json; charset=utf-8]
+ status: {code: 200, message: OK}
+- request:
+ body: null
+ headers:
+ accept-encoding: ['gzip, deflate']
+ method: !!python/unicode GET
+ uri: http://localhost:9001/3.0/lists/test_list.example.com/roster/moderator
+ response:
+ body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"",
+ "start": 0, "total_size": 0}'}
+ headers:
+ content-length: ['90']
+ content-type: [application/json; charset=utf-8]
+ status: {code: 200, message: OK}
+- request:
+ body: null
+ headers:
+ accept-encoding: ['gzip, deflate']
+ method: !!python/unicode GET
+ uri: http://localhost:9001/3.0/lists/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_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/list_bans_add_ban.yaml b/src/postorius/tests/fixtures/vcr_cassettes/list_bans_add_ban.yaml
new file mode 100644
index 0000000..9038106
--- /dev/null
+++ b/src/postorius/tests/fixtures/vcr_cassettes/list_bans_add_ban.yaml
@@ -0,0 +1,93 @@
+interactions:
+- request:
+ body: null
+ headers:
+ accept-encoding: ['gzip, deflate']
+ method: !!python/unicode GET
+ uri: http://localhost:9001/3.0/lists/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ content-type: [application/json; charset=utf-8]
+ status: {code: 200, message: OK}
+- request:
+ body: email=banned%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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode ''}
+ headers:
+ content-length: ['0']
+ location: ['http://localhost:9001/3.0/lists/test_list.example.com/bans/banned@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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode '{"entries": [{"email": "banned@example.com",
+ "http_etag": "\"f97c7e71d9d67fe90f1f8d98429c3fa6a5c76f3d\"", "list_id": "test_list.example.com",
+ "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned@example.com"}],
+ "http_etag": "\"3f2107d752512a58b966f626957a8a21f2280abd\"", "start": 0, "total_size":
+ 1}'}
+ headers:
+ content-length: ['327']
+ 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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_list.example.com/bans/banned@example.com
+ response:
+ body: {string: !!python/unicode '{"email": "banned@example.com", "http_etag":
+ "\"f97c7e71d9d67fe90f1f8d98429c3fa6a5c76f3d\"", "list_id": "test_list.example.com",
+ "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned@example.com"}'}
+ headers:
+ content-length: ['222']
+ content-type: [application/json; charset=utf-8]
+ status: {code: 200, message: OK}
+version: 1
diff --git a/src/postorius/tests/fixtures/vcr_cassettes/list_bans_add_duplicate.yaml b/src/postorius/tests/fixtures/vcr_cassettes/list_bans_add_duplicate.yaml
new file mode 100644
index 0000000..f2688da
--- /dev/null
+++ b/src/postorius/tests/fixtures/vcr_cassettes/list_bans_add_duplicate.yaml
@@ -0,0 +1,106 @@
+interactions:
+- request:
+ body: null
+ headers:
+ accept-encoding: ['gzip, deflate']
+ method: !!python/unicode GET
+ uri: http://localhost:9001/3.0/lists/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ content-type: [application/json; charset=utf-8]
+ status: {code: 200, message: OK}
+- request:
+ body: email=banned%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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode ''}
+ headers:
+ content-length: ['0']
+ location: ['http://localhost:9001/3.0/lists/test_list.example.com/bans/banned@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/test_list.example.com/bans/banned@example.com
+ response:
+ body: {string: !!python/unicode '{"email": "banned@example.com", "http_etag":
+ "\"f97c7e71d9d67fe90f1f8d98429c3fa6a5c76f3d\"", "list_id": "test_list.example.com",
+ "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned@example.com"}'}
+ headers:
+ content-length: ['222']
+ 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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ content-type: [application/json; charset=utf-8]
+ status: {code: 200, message: OK}
+- request:
+ body: email=banned%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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode Address is already banned}
+ headers:
+ content-length: ['25']
+ 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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode '{"entries": [{"email": "banned@example.com",
+ "http_etag": "\"f97c7e71d9d67fe90f1f8d98429c3fa6a5c76f3d\"", "list_id": "test_list.example.com",
+ "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned@example.com"}],
+ "http_etag": "\"3f2107d752512a58b966f626957a8a21f2280abd\"", "start": 0, "total_size":
+ 1}'}
+ headers:
+ content-length: ['327']
+ content-type: [application/json; charset=utf-8]
+ status: {code: 200, message: OK}
+version: 1
diff --git a/src/postorius/tests/fixtures/vcr_cassettes/list_bans_del_ban.yaml b/src/postorius/tests/fixtures/vcr_cassettes/list_bans_del_ban.yaml
new file mode 100644
index 0000000..81c50b9
--- /dev/null
+++ b/src/postorius/tests/fixtures/vcr_cassettes/list_bans_del_ban.yaml
@@ -0,0 +1,129 @@
+interactions:
+- request:
+ body: null
+ headers:
+ accept-encoding: ['gzip, deflate']
+ method: !!python/unicode GET
+ uri: http://localhost:9001/3.0/lists/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ content-type: [application/json; charset=utf-8]
+ status: {code: 200, message: OK}
+- request:
+ body: email=banned%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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode ''}
+ headers:
+ content-length: ['0']
+ location: ['http://localhost:9001/3.0/lists/test_list.example.com/bans/banned@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/test_list.example.com/bans/banned@example.com
+ response:
+ body: {string: !!python/unicode '{"email": "banned@example.com", "http_etag":
+ "\"f97c7e71d9d67fe90f1f8d98429c3fa6a5c76f3d\"", "list_id": "test_list.example.com",
+ "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned@example.com"}'}
+ headers:
+ content-length: ['222']
+ 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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode '{"entries": [{"email": "banned@example.com",
+ "http_etag": "\"f97c7e71d9d67fe90f1f8d98429c3fa6a5c76f3d\"", "list_id": "test_list.example.com",
+ "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned@example.com"}],
+ "http_etag": "\"3f2107d752512a58b966f626957a8a21f2280abd\"", "start": 0, "total_size":
+ 1}'}
+ headers:
+ content-length: ['327']
+ 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/test_list.example.com/bans/banned@example.com
+ response:
+ body: {string: !!python/unicode ''}
+ headers:
+ content-length: ['0']
+ status: {code: 204, message: No Content}
+- request:
+ body: null
+ headers:
+ accept-encoding: ['gzip, deflate']
+ method: !!python/unicode GET
+ uri: http://localhost:9001/3.0/lists/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_list.example.com/bans
+ 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/test_list.example.com/bans/banned@example.com
+ response:
+ body: {string: !!python/unicode 'Email is not banned: banned@example.com'}
+ headers:
+ content-length: ['39']
+ content-type: [application/json; charset=utf-8]
+ status: {code: 404, message: Not Found}
+version: 1
diff --git a/src/postorius/tests/fixtures/vcr_cassettes/list_bans_del_unknown_ban.yaml b/src/postorius/tests/fixtures/vcr_cassettes/list_bans_del_unknown_ban.yaml
new file mode 100644
index 0000000..a663f84
--- /dev/null
+++ b/src/postorius/tests/fixtures/vcr_cassettes/list_bans_del_unknown_ban.yaml
@@ -0,0 +1,88 @@
+interactions:
+- request:
+ body: null
+ headers:
+ accept-encoding: ['gzip, deflate']
+ method: !!python/unicode GET
+ uri: http://localhost:9001/3.0/lists/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_list.example.com/bans/banned@example.com
+ response:
+ body: {string: !!python/unicode 'Email is not banned: banned@example.com'}
+ headers:
+ content-length: ['39']
+ 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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_list.example.com/bans
+ 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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode '{"http_etag": "\"32223434a0f3af4cdc4673d1fbc5bac1f6d98fd3\"",
+ "start": 0, "total_size": 0}'}
+ headers:
+ content-length: ['90']
+ content-type: [application/json; charset=utf-8]
+ status: {code: 200, message: OK}
+version: 1
diff --git a/src/postorius/tests/fixtures/vcr_cassettes/list_bans_delete_forms.yaml b/src/postorius/tests/fixtures/vcr_cassettes/list_bans_delete_forms.yaml
new file mode 100644
index 0000000..6e42a58
--- /dev/null
+++ b/src/postorius/tests/fixtures/vcr_cassettes/list_bans_delete_forms.yaml
@@ -0,0 +1,183 @@
+interactions:
+- request:
+ body: null
+ headers:
+ accept-encoding: ['gzip, deflate']
+ method: !!python/unicode GET
+ uri: http://localhost:9001/3.0/lists/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ content-type: [application/json; charset=utf-8]
+ status: {code: 200, message: OK}
+- request:
+ body: email=banned1%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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode ''}
+ headers:
+ content-length: ['0']
+ location: ['http://localhost:9001/3.0/lists/test_list.example.com/bans/banned1@example.com']
+ status: {code: 201, message: Created}
+- request:
+ body: email=banned2%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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode ''}
+ headers:
+ content-length: ['0']
+ location: ['http://localhost:9001/3.0/lists/test_list.example.com/bans/banned2@example.com']
+ status: {code: 201, message: Created}
+- request:
+ body: email=banned3%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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode ''}
+ headers:
+ content-length: ['0']
+ location: ['http://localhost:9001/3.0/lists/test_list.example.com/bans/banned3@example.com']
+ status: {code: 201, message: Created}
+- request:
+ body: email=banned4%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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode ''}
+ headers:
+ content-length: ['0']
+ location: ['http://localhost:9001/3.0/lists/test_list.example.com/bans/banned4@example.com']
+ status: {code: 201, message: Created}
+- request:
+ body: email=banned5%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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode ''}
+ headers:
+ content-length: ['0']
+ location: ['http://localhost:9001/3.0/lists/test_list.example.com/bans/banned5@example.com']
+ status: {code: 201, message: Created}
+- request:
+ body: email=banned6%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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode ''}
+ headers:
+ content-length: ['0']
+ location: ['http://localhost:9001/3.0/lists/test_list.example.com/bans/banned6@example.com']
+ status: {code: 201, message: Created}
+- request:
+ body: email=banned7%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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode ''}
+ headers:
+ content-length: ['0']
+ location: ['http://localhost:9001/3.0/lists/test_list.example.com/bans/banned7@example.com']
+ status: {code: 201, message: Created}
+- request:
+ body: email=banned8%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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode ''}
+ headers:
+ content-length: ['0']
+ location: ['http://localhost:9001/3.0/lists/test_list.example.com/bans/banned8@example.com']
+ status: {code: 201, message: Created}
+- request:
+ body: email=banned9%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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode ''}
+ headers:
+ content-length: ['0']
+ location: ['http://localhost:9001/3.0/lists/test_list.example.com/bans/banned9@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/test_list.example.com
+ response:
+ body: {string: !!python/unicode '{"display_name": "Test_list", "fqdn_listname":
+ "test_list@example.com", "http_etag": "\"3f02dac6cf71a3be179af5064b09ce668186e785\"",
+ "list_id": "test_list.example.com", "list_name": "test_list", "mail_host":
+ "example.com", "member_count": 0, "self_link": "http://localhost:9001/3.0/lists/test_list.example.com",
+ "volume": 1}'}
+ headers:
+ content-length: ['324']
+ 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/test_list.example.com/bans
+ response:
+ body: {string: !!python/unicode '{"entries": [{"email": "banned1@example.com",
+ "http_etag": "\"31fd4b12c69f84bd2bda2111c15b15eced1f890f\"", "list_id": "test_list.example.com",
+ "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned1@example.com"},
+ {"email": "banned2@example.com", "http_etag": "\"ba6d0d5c1d9a927137dcb6b29d74ab571449be86\"",
+ "list_id": "test_list.example.com", "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned2@example.com"},
+ {"email": "banned3@example.com", "http_etag": "\"c659ef9d7966a17bd73be06cec34fe7eedffe518\"",
+ "list_id": "test_list.example.com", "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned3@example.com"},
+ {"email": "banned4@example.com", "http_etag": "\"f7f52a9b77481b0221e185b2ad1ac0e92be1df5e\"",
+ "list_id": "test_list.example.com", "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned4@example.com"},
+ {"email": "banned5@example.com", "http_etag": "\"e8c1f85a8852257519387b125c10b195a02b37fd\"",
+ "list_id": "test_list.example.com", "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned5@example.com"},
+ {"email": "banned6@example.com", "http_etag": "\"f4d4a3159b921ecc7fcb0ac4736ab592d66ac85f\"",
+ "list_id": "test_list.example.com", "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned6@example.com"},
+ {"email": "banned7@example.com", "http_etag": "\"24739d710562601a44c0c7ef70f18c473d099a9e\"",
+ "list_id": "test_list.example.com", "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned7@example.com"},
+ {"email": "banned8@example.com", "http_etag": "\"aa77f6b65a38219393dbdf81fff7ce94e67ea4bb\"",
+ "list_id": "test_list.example.com", "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned8@example.com"},
+ {"email": "banned9@example.com", "http_etag": "\"51bbc9a5717cac6db2d258e677e8fcaeb0863355\"",
+ "list_id": "test_list.example.com", "self_link": "http://localhost:9001/3.0/lists/test_list.example.com/bans/banned9@example.com"}],
+ "http_etag": "\"e4ba18e67f3919a7a8d4fa7ed61bf1432bae9f12\"", "start": 0, "total_size":
+ 9}'}
+ headers:
+ content-length: ['2137']
+ content-type: [application/json; charset=utf-8]
+ status: {code: 200, message: OK}
+version: 1
diff --git a/src/postorius/tests/mailman_api_tests/test_list_bans.py b/src/postorius/tests/mailman_api_tests/test_list_bans.py
new file mode 100644
index 0000000..0c2e014
--- /dev/null
+++ b/src/postorius/tests/mailman_api_tests/test_list_bans.py
@@ -0,0 +1,160 @@
+# -*- 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 ban lists"""
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+import mock
+import logging
+
+from django.contrib import messages
+from django.contrib.auth.models import User
+from django.core.urlresolvers import reverse
+from django.test import Client, RequestFactory, TestCase
+try:
+ from urllib2 import HTTPError
+except ImportError:
+ from urllib.error import HTTPError
+
+from postorius.tests import MM_VCR
+from postorius.tests.utils import get_flash_messages
+from postorius.utils import get_client
+
+
+logger = logging.getLogger(__name__)
+vcr_log = logging.getLogger('vcr')
+vcr_log.setLevel(logging.WARNING)
+
+
+class ListBansTest(TestCase):
+
+ @MM_VCR.use_cassette('list_bans.yaml')
+ def setUp(self):
+ # Create domain `example.com` in Mailman
+ example_com = get_client().create_domain('example.com')
+ self.m_list = example_com.create_list('test_list')
+ self.test_user = User.objects.create_user(
+ 'test_user', 'test_user@example.com', 'pwd')
+ self.test_superuser = User.objects.create_superuser(
+ 'test_superuser', 'test_superuser@example.com', 'pwd')
+ self.client.login(username="test_superuser", password='pwd')
+ self.url = reverse('list_bans', args=['test_list.example.com'])
+
+ @MM_VCR.use_cassette('list_bans.yaml')
+ def tearDown(self):
+ self.test_user.delete()
+ self.test_superuser.delete()
+ self.m_list.delete()
+ get_client().delete_domain('example.com')
+
+ @MM_VCR.use_cassette('list_bans.yaml')
+ def test_login_redirect_for_anonymous(self):
+ self.client.logout()
+ response = self.client.get(self.url)
+ self.assertEqual(response.status_code, 302)
+
+ @MM_VCR.use_cassette('list_bans.yaml')
+ def test_no_access_for_basic_user(self):
+ self.client.logout()
+ self.client.login(username="test_user", password='pwd')
+ response = self.client.get(self.url)
+ self.assertEqual(response.status_code, 403)
+
+ @MM_VCR.use_cassette('list_bans.yaml')
+ def test_access_for_superuser(self):
+ response = self.client.get(self.url)
+ self.assertEqual(response.status_code, 200)
+
+ @MM_VCR.use_cassette('list_bans.yaml')
+ def test_context_contains_create_form(self):
+ response = self.client.get(self.url)
+ self.assertEqual(response.status_code, 200)
+ self.assertTrue('addban_form' in response.context)
+ self.assertContains(response,
+ '')
+ self.assertContains(response,
+ '')
+
+ @MM_VCR.use_cassette('list_bans_delete_forms.yaml')
+ def test_context_contains_delete_forms(self):
+ banned = ["banned{}@example.com".format(i) for i in range(1,10)]
+ for ban in banned:
+ self.m_list.bans.add(ban)
+ response = self.client.get(self.url)
+ self.assertEqual(response.status_code, 200)
+ for ban in banned:
+ self.assertContains(response,
+ '' % ban)
+ self.assertContains(response,
+ '