sharing/test: per db extension

This commit is contained in:
Peter Bieringer
2026-02-28 07:39:42 +01:00
parent fae972d25c
commit 3efd405382

View File

@@ -76,24 +76,55 @@ class TestSharingApiSanity(BaseTest):
# disabled # disabled
for path in ["/.sharing", "/.sharing/"]: for path in ["/.sharing", "/.sharing/"]:
_, headers, _ = self.request("POST", path, check=404) _, headers, _ = self.request("POST", path, check=404)
# enabled (permutations)
path = "/.sharing/"
# no database is active
logging.info("\n*** check API hook base: map=True token=False")
self.configure({"sharing": { self.configure({"sharing": {
"collection_by_map": "True", "collection_by_map": "True",
"collection_by_token": "False"} "collection_by_token": "False"}
}) })
path = "/.sharing/" _, headers, _ = self.request("POST", path, check=404)
_, headers, _ = self.request("POST", path, check=401)
logging.info("\n*** check API hook base: map=False token=True")
self.configure({"sharing": { self.configure({"sharing": {
"collection_by_map": "False", "collection_by_map": "False",
"collection_by_token": "True"} "collection_by_token": "True"}
}) })
path = "/.sharing/" _, headers, _ = self.request("POST", path, check=404)
_, headers, _ = self.request("POST", path, check=401)
logging.info("\n*** check API hook base: map=True token=True")
self.configure({"sharing": {
"collection_by_map": "True",
"collection_by_token": "True"}
})
_, headers, _ = self.request("POST", path, check=404)
for db_type in list(filter(lambda item: item != "none", sharing.INTERNAL_TYPES)):
logging.info("\n*** test: %s", db_type)
self.configure({"sharing": {"type": db_type}})
# no database is active
logging.info("\n*** check API hook base: map=True token=False")
self.configure({"sharing": {
"collection_by_map": "True",
"collection_by_token": "False"}
})
_, headers, _ = self.request("POST", path, check=401)
logging.info("\n*** check API hook base: map=False token=True")
self.configure({"sharing": {
"collection_by_map": "False",
"collection_by_token": "True"}
})
_, headers, _ = self.request("POST", path, check=401)
logging.info("\n*** check API hook base: map=True token=True")
self.configure({"sharing": { self.configure({"sharing": {
"collection_by_map": "True", "collection_by_map": "True",
"collection_by_token": "True"} "collection_by_token": "True"}
}) })
path = "/.sharing/"
_, headers, _ = self.request("POST", path, check=401) _, headers, _ = self.request("POST", path, check=401)
def test_sharing_api_base_with_auth(self) -> None: def test_sharing_api_base_with_auth(self) -> None:
@@ -108,12 +139,17 @@ class TestSharingApiSanity(BaseTest):
json_dict: dict json_dict: dict
# path with no valid API hook for db_type in list(filter(lambda item: item != "none", sharing.INTERNAL_TYPES)):
logging.info("\n*** test: %s", db_type)
self.configure({"sharing": {"type": db_type}})
for path in ["/.sharing/", "/.sharing/v9/"]: for path in ["/.sharing/", "/.sharing/v9/"]:
logging.info("\n*** check invalid API URI: %r", path)
_, headers, _ = self.request("POST", path, check=404, login="owner:ownerpw") _, headers, _ = self.request("POST", path, check=404, login="owner:ownerpw")
# path with valid API but no hook # path with valid API but no hook
for path in ["/.sharing/v1/"]: for path in ["/.sharing/v1/"]:
logging.info("\n*** check valid API URI without hook: %r", path)
_, headers, _ = self.request("POST", path, check=404, login="owner:ownerpw") _, headers, _ = self.request("POST", path, check=404, login="owner:ownerpw")
# path with valid API and hook but not enabled "map" # path with valid API and hook but not enabled "map"
@@ -124,6 +160,7 @@ class TestSharingApiSanity(BaseTest):
sharetype = "map" sharetype = "map"
for action in sharing.API_HOOKS_V1: for action in sharing.API_HOOKS_V1:
path = "/.sharing/v1/" + sharetype + "/" + action path = "/.sharing/v1/" + sharetype + "/" + action
logging.info("\n*** check valid API URI hook (but not enabled): %r", path)
_, headers, _ = self.request("POST", path, check=404, login="owner:ownerpw") _, headers, _ = self.request("POST", path, check=404, login="owner:ownerpw")
# path with valid API and hook but not enabled "token" # path with valid API and hook but not enabled "token"
@@ -134,6 +171,7 @@ class TestSharingApiSanity(BaseTest):
sharetype = "token" sharetype = "token"
for action in sharing.API_HOOKS_V1: for action in sharing.API_HOOKS_V1:
path = "/.sharing/v1/" + sharetype + "/" + action path = "/.sharing/v1/" + sharetype + "/" + action
logging.info("\n*** check valid API URI hook (but not enabled): %r", path)
_, headers, _ = self.request("POST", path, check=404, login="owner:ownerpw") _, headers, _ = self.request("POST", path, check=404, login="owner:ownerpw")
# check info hook # check info hook