Add actual state of PermittedCreateCollectionByMap and PermittedCreateCollectionByToken in info response

This commit is contained in:
Max Berger
2026-03-03 22:54:42 +01:00
parent 460b249cdc
commit 08d35d97f2
2 changed files with 25 additions and 7 deletions

View File

@@ -963,10 +963,10 @@ class BaseSharing:
answer['Status'] = "success"
if ShareType in ["all", "map"]:
answer['FeatureEnabledCollectionByMap'] = self.sharing_collection_by_map
answer['PermittedCreateCollectionByMap'] = True # TODO toggle per permission, default?
answer['PermittedCreateCollectionByMap'] = self.permit_create_map
if ShareType in ["all", "token"]:
answer['FeatureEnabledCollectionByToken'] = self.sharing_collection_by_token
answer['PermittedCreateCollectionByToken'] = True # TODO toggle per permission, default?
answer['PermittedCreateCollectionByToken'] = self.permit_create_token
# action: TOGGLE
elif action in API_SHARE_TOGGLES_V1:

View File

@@ -220,7 +220,9 @@ class TestSharingApiSanity(BaseTest):
# path with valid API and hook but not enabled "token"
self.configure({"sharing": {
"collection_by_map": "True",
"collection_by_token": "False"}
"collection_by_token": "False",
"permit_create_map": "False",
"permit_create_token": "False"}
})
sharetype = "token"
for action in sharing.API_HOOKS_V1:
@@ -233,10 +235,10 @@ class TestSharingApiSanity(BaseTest):
json_dict = {}
_, headers, answer = self._sharing_api_json("all", "info", check=200, login="owner:ownerpw", json_dict=json_dict)
answer_dict = json.loads(answer)
assert answer_dict['FeatureEnabledCollectionByMap'] is True
assert answer_dict['FeatureEnabledCollectionByToken'] is False
assert answer_dict['PermittedCreateCollectionByMap'] is True
assert answer_dict['PermittedCreateCollectionByToken'] is True
assert answer_dict['FeatureEnabledCollectionByMap'] is True, f'FeatureEnabledCollectionByMap {db_type}'
assert answer_dict['FeatureEnabledCollectionByToken'] is False, f'FeatureEnabledCollectionByToken {db_type}'
assert answer_dict['PermittedCreateCollectionByMap'] is False, f'PermittedCreateCollectionByMap {db_type}'
assert answer_dict['PermittedCreateCollectionByToken'] is False, f'PermittedCreateCollectionByToken {db_type}'
logging.info("\n*** check API hook: info/map")
json_dict = {}
@@ -270,6 +272,22 @@ class TestSharingApiSanity(BaseTest):
assert 'FeatureEnabledCollectionByMap' not in answer_dict
assert 'PermittedCreateCollectionByMap' not in answer_dict
# When turning on permission to create
self.configure({"sharing": {
"collection_by_map": "True",
"collection_by_token": "True",
"permit_create_map": "True",
"permit_create_token": "True"}
})
logging.info("\n*** check API hook: info/all")
json_dict = {}
_, headers, answer = self._sharing_api_json("all", "info", check=200, login="owner:ownerpw", json_dict=json_dict)
answer_dict = json.loads(answer)
assert answer_dict['FeatureEnabledCollectionByMap'] is True, f'FeatureEnabledCollectionByMap {db_type}'
assert answer_dict['FeatureEnabledCollectionByToken'] is True, f'FeatureEnabledCollectionByToken {db_type}'
assert answer_dict['PermittedCreateCollectionByMap'] is True, f'PermittedCreateCollectionByMap {db_type}'
assert answer_dict['PermittedCreateCollectionByToken'] is True, f'PermittedCreateCollectionByToken {db_type}'
def test_sharing_api_list_with_auth(self) -> None:
"""POST/list with authentication."""
self.configure({"auth": {"type": "htpasswd",