From f49e8df8c9347e42277aa4be7139fc0b08bcca8f Mon Sep 17 00:00:00 2001 From: rwood-moz Date: Wed, 15 Jan 2025 14:44:11 -0500 Subject: [PATCH] Expand the integration tests --- backend/test/integration/test_calendar.py | 16 ++++++++++ backend/test/integration/test_general.py | 36 +++++++++++++++++++++++ backend/test/integration/test_profile.py | 15 ++++++++++ 3 files changed, 67 insertions(+) diff --git a/backend/test/integration/test_calendar.py b/backend/test/integration/test_calendar.py index 6e97470df..de941cbfa 100644 --- a/backend/test/integration/test_calendar.py +++ b/backend/test/integration/test_calendar.py @@ -321,6 +321,22 @@ def test_connect_more_calendars_than_tier_allows( response = with_client.post(f'/cal/{cal[2].id}/connect', headers=auth_headers) assert response.status_code == 403, response.text + def test_create_connection_failure(self, with_client, make_google_calendar, request): + """Attempt to create google calendar connection without having external connection, expect failure""" + response = with_client.post( + '/cal', + json={ + 'title': 'A google calendar', + 'color': '#123456', + 'provider': CalendarProvider.google.value, + 'url': 'test', + 'user': 'test', + 'password': 'test', + }, + headers=auth_headers, + ) + assert response.status_code == 400, response.text + class TestCaldav: """Tests for caldav specific functionality""" diff --git a/backend/test/integration/test_general.py b/backend/test/integration/test_general.py index 447e923a6..87ebd6d4d 100644 --- a/backend/test/integration/test_general.py +++ b/backend/test/integration/test_general.py @@ -32,6 +32,8 @@ def test_health_for_locale(self, with_client): def test_access_without_authentication_token(self, with_client): # response = client.get("/login") # assert response.status_code == 401 + response = with_client.get('/me') + assert response.status_code == 401 response = with_client.put('/me') assert response.status_code == 401 response = with_client.get('/me/calendars') @@ -52,18 +54,52 @@ def test_access_without_authentication_token(self, with_client): assert response.status_code == 401 response = with_client.delete('/cal/1') assert response.status_code == 401 + response = with_client.post('/caldav/auth') + assert response.status_code == 401 + response = with_client.post('/caldav/disconnect') + assert response.status_code == 401 response = with_client.post('/rmt/calendars') assert response.status_code == 401 response = with_client.get('/rmt/cal/1/' + DAY1 + '/' + DAY5) assert response.status_code == 401 response = with_client.post('/rmt/sync') assert response.status_code == 401 + response = with_client.get('/account/available-emails') + assert response.status_code == 401 response = with_client.get('/account/download') assert response.status_code == 401 + response = with_client.get('/account/external-connections/') + assert response.status_code == 401 response = with_client.delete('/account/delete') assert response.status_code == 401 response = with_client.get('/google/auth') assert response.status_code == 401 + response = with_client.post('/google/disconnect') + assert response.status_code == 401 + response = with_client.post('/schedule') + assert response.status_code == 401 + response = with_client.get('/schedule') + assert response.status_code == 401 + response = with_client.get('/schedule/0') + assert response.status_code == 401 + response = with_client.put('/schedule/0') + assert response.status_code == 401 + response = with_client.get('/invite') + assert response.status_code == 401 + response = with_client.post('/invite/generate/1') + assert response.status_code == 401 + response = with_client.put('/invite/revoke/1') + assert response.status_code == 401 + response = with_client.get('/subscriber') + assert response.status_code == 401 + response = with_client.put('/subscriber/enable/someemail@email.com') + assert response.status_code == 401 + response = with_client.put('/subscriber/disable/someemail@email.com') + assert response.status_code == 401 + response = with_client.post('/subscriber/setup') + assert response.status_code == 401 + response = with_client.post('/waiting-list/invite') + assert response.status_code == 401 def test_send_feedback(self, with_client): response = with_client.post( diff --git a/backend/test/integration/test_profile.py b/backend/test/integration/test_profile.py index a823bafd9..2fd3d61c5 100644 --- a/backend/test/integration/test_profile.py +++ b/backend/test/integration/test_profile.py @@ -52,3 +52,18 @@ def test_signed_short_link_refresh(self, with_client): assert response.status_code == 200, response.text url_new = response.json()['url'] assert url_old != url_new + + def test_update_me_username_taken(self, with_db, with_client, make_pro_subscriber): + """Attempt to update current subscriber's profile with already existing username""" + other_subscriber = make_pro_subscriber(username='thunderbird1') + + response = with_client.put( + '/me', + json={ + 'username': 'thunderbird1', + 'name': 'Changed Name', + 'secondary_email': 'adifferentone@example.org', + }, + headers=auth_headers, + ) + assert response.status_code == 403, response.text