Skip to content
Snippets Groups Projects
Commit 02c75e77 authored by Christian Boettcher's avatar Christian Boettcher
Browse files

raise httpexception for not found secrets

parent 0f48a88c
Branches
No related tags found
Loading
...@@ -3,6 +3,7 @@ import os ...@@ -3,6 +3,7 @@ import os
import uuid import uuid
from typing import Dict, List, Optional from typing import Dict, List, Optional
import logging import logging
from fastapi.exceptions import HTTPException
from pydantic import BaseModel from pydantic import BaseModel
...@@ -156,13 +157,18 @@ class JsonFileStorageAdapter(AbstractLocationDataStorageAdapter): ...@@ -156,13 +157,18 @@ class JsonFileStorageAdapter(AbstractLocationDataStorageAdapter):
secrets_path = self.__get_secrets_path(value=n_type.value, oid=oid) secrets_path = self.__get_secrets_path(value=n_type.value, oid=oid)
secrets = self.__load_secrets(secrets_path) secrets = self.__load_secrets(secrets_path)
# TODO log # TODO log
try:
return secrets[key] return secrets[key]
except KeyError:
raise HTTPException(404)
def delete_secret(self, n_type: LocationDataType, oid:str, key: str, usr: str): def delete_secret(self, n_type: LocationDataType, oid:str, key: str, usr: str):
""" delete and return the value of the requested secret for the given object""" """ delete and return the value of the requested secret for the given object"""
secrets_path = self.__get_secrets_path(value=n_type.value, oid=oid) secrets_path = self.__get_secrets_path(value=n_type.value, oid=oid)
secrets = self.__load_secrets(secrets_path) secrets = self.__load_secrets(secrets_path)
val = secrets.pop(key, None) val = secrets.pop(key, None)
if not val:
raise HTTPException(404, "Secret does not exist.")
# TODO log # TODO log
self.__store_secrets(secrets_path, secrets) self.__store_secrets(secrets_path, secrets)
return val return val
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment