[tests] Tests for email subscription w/o auth
This commit is contained in:
parent
8f7840fb7c
commit
ae979c37f9
|
@ -13,18 +13,3 @@ def test_email_create_unauthorized(client, hood_id):
|
||||||
def test_email_delete_unauthorized(client, hood_id):
|
def test_email_delete_unauthorized(client, hood_id):
|
||||||
response = client.delete('/api/hoods/%d/email/' % hood_id)
|
response = client.delete('/api/hoods/%d/email/' % hood_id)
|
||||||
assert response.status_code == status.HTTP_401_UNAUTHORIZED
|
assert response.status_code == status.HTTP_401_UNAUTHORIZED
|
||||||
|
|
||||||
|
|
||||||
def test_email_subscribe(client, hood_id):
|
|
||||||
response = client.post('/api/hoods/%d/email/subscribe/' % hood_id)
|
|
||||||
assert response.status_code == status.HTTP_401_UNAUTHORIZED
|
|
||||||
|
|
||||||
|
|
||||||
def test_email_subscribe_confirm(client, hood_id):
|
|
||||||
response = client.post('/api/hoods/%d/email/subscribe/confirm/asdf' % hood_id)
|
|
||||||
assert response.status_code == status.HTTP_401_UNAUTHORIZED
|
|
||||||
|
|
||||||
|
|
||||||
def test_email_unsubscribe(client, hood_id):
|
|
||||||
response = client.get('/api/hoods/%d/email/unsubscribe/asdf' % hood_id)
|
|
||||||
assert response.status_code == status.HTTP_401_UNAUTHORIZED
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
# Copyright (C) 2020 by Maike <maike@systemli.org>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: 0BSD
|
||||||
|
|
||||||
|
from fastapi import status
|
||||||
|
from nacl.exceptions import CryptoError
|
||||||
|
|
||||||
|
|
||||||
|
def test_email_subscribe_empty(client, hood_id):
|
||||||
|
response = client.post('/api/hoods/%d/email/subscribe/' % hood_id)
|
||||||
|
assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY
|
||||||
|
|
||||||
|
|
||||||
|
def test_email_subscribe_confirm_wrong_token(client, hood_id):
|
||||||
|
try:
|
||||||
|
client.get(
|
||||||
|
'/api/hoods/%d/email/subscribe/confirm/asdfasdfasdfasdfasdfasdfasdfasdf'
|
||||||
|
% hood_id
|
||||||
|
)
|
||||||
|
except CryptoError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_email_subscribe_confirm_wrong_hood(client):
|
||||||
|
response = client.get(
|
||||||
|
'/api/hoods/99999/email/unsubscribe/asdfasdfasdfasdfasdfasdfasdfasdf'
|
||||||
|
)
|
||||||
|
assert response.json()['detail'] == 'Not Found'
|
||||||
|
|
||||||
|
|
||||||
|
def test_email_unsubscribe_wrong_token(client, hood_id):
|
||||||
|
try:
|
||||||
|
client.get(
|
||||||
|
'/api/hoods/%d/email/unsubscribe/asdfasdfasdfasdfasdfasdfasdfasdf' % hood_id
|
||||||
|
)
|
||||||
|
except CryptoError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_email_unsubscribe_wrong_hood(client):
|
||||||
|
response = client.get(
|
||||||
|
'/api/hoods/99999/email/unsubscribe/asdfasdfasdfasdfasdfasdfasdfasdf'
|
||||||
|
)
|
||||||
|
assert response.json()['detail'] == 'Not Found'
|
Loading…
Reference in a new issue