-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add the new tables and an updated data scrubber to download * Add test for account deletion, including new external connections factory. * Streamline the account deletion flow, and update scrubbers/download readme. * Delete localstorage user data after we delete the account * ➕ update German translations --------- Co-authored-by: Andreas Müller <[email protected]>
- Loading branch information
1 parent
6ffff25
commit e7d5c2e
Showing
9 changed files
with
119 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
from faker import Faker | ||
from backend.src.appointment.database import repo, schemas, models | ||
from defines import FAKER_RANDOM_VALUE, factory_has_value | ||
|
||
|
||
@pytest.fixture | ||
def make_external_connections(with_db): | ||
fake = Faker() | ||
|
||
def _make_external_connections(subscriber_id, | ||
name=FAKER_RANDOM_VALUE, | ||
type=FAKER_RANDOM_VALUE, | ||
type_id=FAKER_RANDOM_VALUE, | ||
token=FAKER_RANDOM_VALUE): | ||
with with_db() as db: | ||
return repo.create_subscriber_external_connection(db, schemas.ExternalConnection( | ||
owner_id=subscriber_id, | ||
name=name if factory_has_value(name) else fake.name(), | ||
type=type if factory_has_value(type) else fake.random_element( | ||
(models.ExternalConnectionType.zoom.value, models.ExternalConnectionType.google.value, models.ExternalConnectionType.fxa.value)), | ||
type_id=type_id if factory_has_value(type_id) else fake.uuid4(), | ||
token=token if factory_has_value(token) else fake.password(), | ||
)) | ||
|
||
return _make_external_connections |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from argon2 import PasswordHasher | ||
|
||
from backend.src.appointment.controller.data import model_to_csv_buffer, delete_account | ||
|
||
|
||
class TestData: | ||
def test_model_to_csv_buffer(self, make_pro_subscriber): | ||
"""Make sure our model to csv buffer is working, scrubbers and all!""" | ||
ph = PasswordHasher() | ||
|
||
password = "cool beans" | ||
subscriber = make_pro_subscriber(password=password) | ||
|
||
buffer = model_to_csv_buffer([subscriber]) | ||
csv_data = buffer.getvalue() | ||
|
||
assert csv_data | ||
# Check if our scrubber is working as intended | ||
assert 'subscriber.password' not in csv_data | ||
assert password not in csv_data | ||
assert ph.hash(password) not in csv_data | ||
# Ensure that some of our subscriber data is there | ||
assert subscriber.email in csv_data | ||
assert subscriber.username in csv_data | ||
|
||
def test_delete_account(self, with_db, make_pro_subscriber, make_appointment, make_schedule, make_caldav_calendar, make_external_connections): | ||
"""Test that our delete account functionality actually deletes everything""" | ||
subscriber = make_pro_subscriber() | ||
calendar = make_caldav_calendar(subscriber_id=subscriber.id) | ||
appointment = make_appointment(calendar_id=calendar.id) | ||
schedule = make_schedule(calendar_id=calendar.id) | ||
external_connection = make_external_connections(subscriber_id=subscriber.id) | ||
|
||
# Get some relationships | ||
slots = appointment.slots | ||
|
||
# Bunch them together into a list. They must have an id field, otherwise assert them manually. | ||
models_to_check = [subscriber, external_connection, calendar, appointment, schedule, *slots] | ||
|
||
with with_db() as db: | ||
ret = delete_account(db, subscriber) | ||
assert ret is True | ||
|
||
for model in models_to_check: | ||
check = db.get(model.__class__, model.id) | ||
assert check is None, f"Ensuring {model.__class__} is None" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters