Conversation
…search environments
…or different edge cases
…refactors for readability, changes to upstream_url_regex
…gic, also organized the functions
…ts to service/backend.py WIP
…tests for duplicate backend deletion
…_check_backend_path_file
…lenames, minor changes in service/backend.py
…ackend and delete_backend functions for improved clarity and robustness.
dweinholz
left a comment
There was a problem hiding this comment.
{% if only_allow_owner %}
This part must be removed from all templates where we want to prevent the deactivation of the authorisation.
Also please change the permissions of the files again
| return randint(range_start, range_end) | ||
|
|
||
|
|
||
| # TODO: unlikely but potential error cause, if two users have same randomly generated user_key_url! |
There was a problem hiding this comment.
This part should avoid this (which could be refactored into an own method):
backends: List[BackendOut] = await get_backends()
same_name_backend_suffixes: List[int] = []
for backend in backends:
if backend.location_url == location_url:
suffix: int = int(backend.location_url.split("_")[1])
same_name_backend_suffixes.append(suffix)
if not same_name_backend_suffixes:
return 100
# return highest found suffix number + 1 to iterate
same_name_backend_suffixes.sort()
highest_id: int = same_name_backend_suffixes[-1]
| async def backend_update_auth(backend_id: int, body: dict = Body(...), api_key: APIKey = Depends(get_api_key)): | ||
| # process inputs TODO: should we validate further? | ||
| backend_id = int(secure_filename(str(backend_id))) # TODO: are secure_filename and str necessary? validation? | ||
| assert backend_id is not None, "backend_id is required" # @reviewer: is this okay? |
There was a problem hiding this comment.
Does this raise an exception?
If no backend id is provided it should raise an exception
| async def delete_backend(backend_id: int, api_key: APIKey = Depends(get_api_key)): | ||
| try: | ||
| backend_id = int(secure_filename(str(backend_id))) | ||
| assert backend_id is not None, "backend_id is required" # @reviewer: is this okay? |
There was a problem hiding this comment.
Does this raise an exception?
If no backend id is provided it should raise an exception
dweinholz
left a comment
There was a problem hiding this comment.
{% if only_allow_owner %}
This part must be removed from all templates where we want to prevent the deactivation of the authorisation.
Also please change the permissions of the files again
Currently the deactivaten of the auth is not working
…leted cwlab template
Most of the logic of the feature happens here.
The important changes are in services/backend.py.
Because I introduced tests I had to refactor many of the existing functions in that file like create_backend.
The function of de/activating the authorization basically deletes previous backends with the same ID and uses create_backend to build a new one, which will keep the same ID and URL.