0001-remove-scheme-identifier-from-unsubscription-page-12.patch
| corbo/views.py | ||
|---|---|---|
|
def get_object(self, queryset=None):
|
||
|
data = signing.loads(self.kwargs['unsubscription_token'])
|
||
|
try:
|
||
|
return models.Subscription.objects.get(category__pk=data['category'],
|
||
|
s = models.Subscription.objects.get(category__pk=data['category'],
|
||
|
identifier=data['identifier'])
|
||
|
try:
|
||
|
# remove schema from identifier
|
||
|
scheme, s.identifier = s.identifier.split(':')
|
||
|
except ValueError:
|
||
|
pass
|
||
|
return s
|
||
|
except models.Subscription.DoesNotExist:
|
||
|
raise Http404
|
||
| tests/test_emailing.py | ||
|---|---|---|
|
def test_unsubscription_link(app, categories, announces):
|
||
|
for category in categories:
|
||
|
uuid = uuid4()
|
||
|
email = '%s@example.net' % uuid
|
||
|
scheme = 'mailto:'
|
||
|
uri = scheme + '%s@example.net' % uuid
|
||
|
s = Subscription.objects.create(category=category,
|
||
|
identifier=email,
|
||
|
identifier=uri,
|
||
|
uuid=str(uuid))
|
||
|
for announce in announces:
|
||
|
if announce.category != category:
|
||
| ... | ... | |
|
assert broadcast.result
|
||
|
assert mail.outbox
|
||
|
signature = signing.dumps({'category': announce.category.pk,
|
||
|
'identifier': email})
|
||
|
'identifier': uri})
|
||
|
unsubscription_link = reverse('unsubscribe', kwargs={'unsubscription_token': signature})
|
||
|
assert mail.outbox[0].subject == announce.title
|
||
|
assert unsubscription_link in mail.outbox[0].html
|
||
|
assert unsubscription_link in mail.outbox[0].text
|
||
|
mail.outbox = []
|
||
|
# make sure the uri schema is not in the page
|
||
|
resp = app.get(unsubscription_link)
|
||
|
assert scheme not in resp.content
|
||