diff --git a/backend/src/appointment/controller/calendar.py b/backend/src/appointment/controller/calendar.py index d82c9a2fd..1d02a3d3c 100644 --- a/backend/src/appointment/controller/calendar.py +++ b/backend/src/appointment/controller/calendar.py @@ -249,10 +249,11 @@ def __init__(self, subscriber_id: int, calendar_id: int, redis_instance, url: st super().__init__(subscriber_id, calendar_id, redis_instance) self.provider = CalendarProvider.caldav - self.url = url + self.url = url if url[-1] == '/' else url + '/' self.password = password self.user = user - # connect to CalDAV server + + # connect to the CalDAV server self.client = DAVClient(url=url, username=user, password=password) def test_connection(self) -> bool: diff --git a/backend/src/appointment/routes/api.py b/backend/src/appointment/routes/api.py index 21ee1cabc..6a12c350d 100644 --- a/backend/src/appointment/routes/api.py +++ b/backend/src/appointment/routes/api.py @@ -135,10 +135,6 @@ def create_my_calendar( google_tkn=external_connection.token, ) else: - # make sure, the CalDAV url has a trailing slash - if calendar.url[-1] != '/': - calendar.url += '/' - con = CalDavConnector( redis_instance=None, url=calendar.url, @@ -194,10 +190,6 @@ def update_my_calendar( if not repo.calendar.is_owned(db, calendar_id=id, subscriber_id=subscriber.id): raise validation.CalendarNotAuthorizedException() - # make sure, the CalDAV url has a trailing slash - if calendar.provider == CalendarProvider.caldav and calendar.url[-1] != '/': - calendar.url += '/' - cal = repo.calendar.update(db=db, calendar=calendar, calendar_id=id) return schemas.CalendarOut(id=cal.id, title=cal.title, color=cal.color, connected=cal.connected) diff --git a/backend/test/integration/test_calendar.py b/backend/test/integration/test_calendar.py index 5b84eac4c..d9d4a8566 100644 --- a/backend/test/integration/test_calendar.py +++ b/backend/test/integration/test_calendar.py @@ -361,7 +361,7 @@ def test_update_existing_caldav_calendar_with_password(self, with_client, with_d with with_db() as db: cal = db.scalars(query).one() - assert cal.url == os.getenv("CALDAV_TEST_CALENDAR_URL") + "x/" + assert cal.url == os.getenv("CALDAV_TEST_CALENDAR_URL") + "x" assert cal.user == os.getenv("CALDAV_TEST_USER") + "x" assert cal.password == os.getenv("CALDAV_TEST_PASS") + "x" @@ -394,6 +394,6 @@ def test_update_existing_caldav_calendar_without_password(self, with_client, wit with with_db() as db: cal = db.scalars(query).one() - assert cal.url == os.getenv("CALDAV_TEST_CALENDAR_URL") + "/" + assert cal.url == os.getenv("CALDAV_TEST_CALENDAR_URL") assert cal.user == os.getenv("CALDAV_TEST_USER") assert cal.password == ''