More CMIS scoring optimization

This commit is contained in:
2026-05-13 23:42:56 +02:00
parent 852b45c158
commit b11c9189e4
7 changed files with 775 additions and 52 deletions

View File

@@ -213,8 +213,9 @@ def test_cmis_query_reports_unsupported_subset_diagnostics(cmis_client) -> None:
params={"q": "SELECT * FROM cmis:document JOIN cmis:relationship"},
)
assert response.status_code == 422
assert response.json()["detail"]["details"]["supported"] == [
assert response.status_code == 400
assert response.json()["exception"] == "invalidArgument"
assert response.json()["details"]["supported"] == [
"SELECT * FROM cmis:document",
"SELECT * FROM kontextual:document",
]
@@ -245,6 +246,10 @@ def test_cmis_governed_authoring_routes_allow_selected_mutations(cmis_client) ->
"/cmis/governed-authoring/browser/content-bytes/cmis:asset:asset-api-authored",
params={"offset": 2, "length": 4},
)
byte_offset_zero = cmis_client.get(
"/cmis/governed-authoring/browser/content-bytes/cmis:asset:asset-api-authored",
params={"offset": 0},
)
deleted = cmis_client.post(
"/cmis/governed-authoring/browser/object/cmis:asset:asset-api-authored/delete",
json={},
@@ -258,6 +263,9 @@ def test_cmis_governed_authoring_routes_allow_selected_mutations(cmis_client) ->
assert byte_stream.headers["etag"].startswith("sha256:")
assert byte_range.content == b"Upda"
assert byte_range.headers["content-length"] == "4"
assert byte_offset_zero.status_code == 200
assert byte_offset_zero.content == b"# Updated"
assert "content-range" not in byte_offset_zero.headers
assert deleted.json()["lifecycle"] == "delete_requested"
@@ -286,8 +294,9 @@ def test_cmis_browser_binding_create_document_validates_type_and_secondary_ids(c
files={"content": ("secondary.txt", b"Secondary content", "text/plain")},
)
assert invalid.status_code == 422
assert invalid.json()["detail"]["details"]["type_id"] == "cmis:folder"
assert invalid.status_code == 400
assert invalid.json()["exception"] == "invalidArgument"
assert invalid.json()["details"]["type_id"] == "cmis:folder"
assert created.status_code == 200
assert created.json()["properties"]["cmis:secondaryObjectTypeIds"]["value"] == ["kontextual:secondary"]
@@ -326,6 +335,227 @@ def test_cmis_browser_binding_document_without_content_streams_empty_compatibili
assert content.headers["content-length"] == "0"
def test_cmis_browser_binding_delete_content_stream_tombstones_content(cmis_client) -> None:
document = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={
"cmisaction": "createDocument",
"propertyId[0]": "cmis:objectTypeId",
"propertyValue[0]": "cmis:document",
"propertyId[1]": "cmis:name",
"propertyValue[1]": "Delete Content Document",
},
files={"content": ("delete-content.txt", b"Delete me", "text/plain")},
).json()
object_id = document["properties"]["cmis:objectId"]["value"]
token = document["properties"]["cmis:changeToken"]["value"]
deleted = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={"cmisaction": "deleteContentStream", "objectId": object_id, "changeToken": token},
)
content_after_delete = cmis_client.get(
"/cmis/compat-tck/browser/root",
params={"cmisselector": "content", "objectId": object_id},
)
assert deleted.status_code == 200
assert deleted.json()["properties"]["cmis:contentStreamLength"]["value"] is None
assert deleted.json()["properties"]["cmis:changeToken"]["value"] != token
assert content_after_delete.status_code == 409
assert content_after_delete.json()["exception"] == "constraint"
def test_cmis_browser_binding_change_tokens_conflict_on_stale_updates(cmis_client) -> None:
document = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={
"cmisaction": "createDocument",
"propertyId[0]": "cmis:objectTypeId",
"propertyValue[0]": "cmis:document",
"propertyId[1]": "cmis:name",
"propertyValue[1]": "Token Document",
},
files={"content": ("token.txt", b"Token content", "text/plain")},
).json()
object_id = document["properties"]["cmis:objectId"]["value"]
original_token = document["properties"]["cmis:changeToken"]["value"]
renamed = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={
"cmisaction": "updateProperties",
"objectId": object_id,
"changeToken": original_token,
"propertyId[0]": "cmis:name",
"propertyValue[0]": "Token Document Renamed",
},
)
renamed_token = renamed.json()["properties"]["cmis:changeToken"]["value"]
stale_property_update = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={
"cmisaction": "updateProperties",
"objectId": object_id,
"changeToken": original_token,
"propertyId[0]": "cmis:description",
"propertyValue[0]": "stale",
},
)
content_updated = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={
"cmisaction": "setContentStream",
"objectId": object_id,
"changeToken": renamed_token,
"content": "Updated token content",
"media_type": "text/plain",
},
)
stale_content_update = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={
"cmisaction": "setContentStream",
"objectId": object_id,
"changeToken": renamed_token,
"content": "Stale update",
"media_type": "text/plain",
},
)
assert renamed.status_code == 200
assert renamed_token != original_token
assert stale_property_update.status_code == 409
assert stale_property_update.json()["exception"] == "updateConflict"
assert content_updated.status_code == 200
assert content_updated.json()["properties"]["cmis:changeToken"]["value"] != renamed_token
assert stale_content_update.status_code == 409
assert stale_content_update.json()["exception"] == "updateConflict"
def test_cmis_browser_binding_create_document_from_source_reuses_content_projection(cmis_client) -> None:
source = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={
"cmisaction": "createDocument",
"propertyId[0]": "cmis:objectTypeId",
"propertyValue[0]": "cmis:document",
"propertyId[1]": "cmis:name",
"propertyValue[1]": "Copy Source",
},
files={"content": ("copy-source.txt", b"Source copy bytes", "text/plain")},
).json()
folder = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={
"cmisaction": "createFolder",
"propertyId[0]": "cmis:objectTypeId",
"propertyValue[0]": "cmis:folder",
"propertyId[1]": "cmis:name",
"propertyValue[1]": "Copy Destination",
},
).json()
source_id = source["properties"]["cmis:objectId"]["value"]
folder_id = folder["properties"]["cmis:objectId"]["value"]
copied = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={
"cmisaction": "createDocumentFromSource",
"objectId": folder_id,
"sourceId": source_id,
"propertyId[0]": "cmis:objectTypeId",
"propertyValue[0]": "cmis:document",
"propertyId[1]": "cmis:name",
"propertyValue[1]": "Copied Document",
},
)
copied_id = copied.json()["properties"]["cmis:objectId"]["value"]
copied_content = cmis_client.get(
"/cmis/compat-tck/browser/root",
params={"cmisselector": "content", "objectId": copied_id},
)
assert copied.status_code == 200
assert copied_id != source_id
assert copied.json()["properties"]["cmis:name"]["value"] == "Copied Document"
assert copied.json()["properties"]["cmis:contentStreamLength"]["value"] == 17
assert copied_content.content == b"Source copy bytes"
def test_cmis_browser_binding_bulk_update_renames_documents(cmis_client) -> None:
folder_one = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={
"cmisaction": "createFolder",
"propertyId[0]": "cmis:objectTypeId",
"propertyValue[0]": "cmis:folder",
"propertyId[1]": "cmis:name",
"propertyValue[1]": "Bulk Folder One",
},
).json()
folder_two = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={
"cmisaction": "createFolder",
"propertyId[0]": "cmis:objectTypeId",
"propertyValue[0]": "cmis:folder",
"propertyId[1]": "cmis:name",
"propertyValue[1]": "Bulk Folder Two",
},
).json()
first = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={
"cmisaction": "createDocument",
"objectId": folder_one["properties"]["cmis:objectId"]["value"],
"propertyId[0]": "cmis:objectTypeId",
"propertyValue[0]": "cmis:document",
"propertyId[1]": "cmis:name",
"propertyValue[1]": "Bulk One",
},
files={"content": ("bulk-one.txt", b"bulk one", "text/plain")},
).json()
second = cmis_client.post(
"/cmis/compat-tck/browser/root",
data={
"cmisaction": "createDocument",
"objectId": folder_two["properties"]["cmis:objectId"]["value"],
"propertyId[0]": "cmis:objectTypeId",
"propertyValue[0]": "cmis:document",
"propertyId[1]": "cmis:name",
"propertyValue[1]": "Bulk Two",
},
files={"content": ("bulk-two.txt", b"bulk two", "text/plain")},
).json()
first_id = first["properties"]["cmis:objectId"]["value"]
second_id = second["properties"]["cmis:objectId"]["value"]
response = cmis_client.post(
"/cmis/compat-tck/browser",
data={
"cmisaction": "bulkUpdate",
"objectId[0]": first_id,
"changeToken[0]": first["properties"]["cmis:changeToken"]["value"],
"objectId[1]": second_id,
"changeToken[1]": second["properties"]["cmis:changeToken"]["value"],
"propertyId[0]": "cmis:name",
"propertyValue[0]": "Bulk Renamed",
},
)
first_after = cmis_client.get(
"/cmis/compat-tck/browser/root",
params={"cmisselector": "object", "objectId": first_id},
).json()
second_after = cmis_client.get(
"/cmis/compat-tck/browser/root",
params={"cmisselector": "object", "objectId": second_id},
).json()
assert response.status_code == 200
assert {item["id"] for item in response.json()} == {first_id, second_id}
assert all(item["changeToken"] for item in response.json())
assert first_after["properties"]["cmis:name"]["value"] == "Bulk Renamed"
assert second_after["properties"]["cmis:name"]["value"] == "Bulk Renamed"
def test_cmis_browser_binding_create_folder_action_creates_workspace_folder(cmis_client) -> None:
created = cmis_client.post(
"/cmis/compat-tck/browser/root",
@@ -523,9 +753,10 @@ def test_cmis_rejects_unsupported_standard_property_update_with_diagnostics(cmis
json={"properties": {"cmis:objectTypeId": "cmis:folder"}},
)
assert response.status_code == 422
assert response.json()["detail"]["details"]["property"] == "cmis:objectTypeId"
assert response.json()["detail"]["details"]["supported"] == [
assert response.status_code == 400
assert response.json()["exception"] == "invalidArgument"
assert response.json()["details"]["property"] == "cmis:objectTypeId"
assert response.json()["details"]["supported"] == [
"cmis:name",
"cmis:description",
"cmis:secondaryObjectTypeIds",