def wrapper(*args: Any, **kwargs: Any) -> Any:
     username = get_session_username(str(request.cookies.get(SESSION_ID)))
     authorization = Authorization(calendar_data=CalendarData(data_folder=current_app.config['DATA_FOLDER']))
     if "calendar_id" not in kwargs:
         raise ValueError("calendar_id")
     calendar_id = str(kwargs["calendar_id"])
     if not authorization.can_access(username=username, calendar_id=calendar_id):
         abort(403)
     return decorated_function(*args, **kwargs)
Exemple #2
0
def test_authorized_if_calendar_user_in_list_using_calendar_data(
        authorization: Authorization) -> None:
    data = {"users": [EXISTING_USERNAME]}
    assert authorization.can_access(username=EXISTING_USERNAME,
                                    data=data) is True
Exemple #3
0
def test_authorized_if_calendar_user_in_list(
        authorization: Authorization) -> None:
    assert authorization.can_access(username=EXISTING_USERNAME,
                                    calendar_id="sample_data_file") is True
Exemple #4
0
def test_unauthorized_if_calendar_user_not_in_list(
        authorization: Authorization) -> None:
    assert authorization.can_access(username="******",
                                    calendar_id="sample_data_file") is False