Skip to content

Commit 6d2b173

Browse files
mrk-vidanielecalda
authored andcommitted
Issue #2237: Cover acl update in partial payload
Add a test proving an acl carried by the partial document is kept and merged: on update acl behaves like any other field, while the default acl stays a creation-only concern. Correct the default-acl test comment and drop the now-misleading acl note from the buildBulkOperations javadoc. Co-Authored-By: Claude Opus 4.8 from Anthropic via Claude Code
1 parent 1b7852a commit 6d2b173

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

core/app/datasource/src/main/java/io/openk9/datasource/pipeline/actor/PartialUpdateWriter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ public Receive<Writer.Command> createReceive() {
118118

119119
/**
120120
* Builds one update operation for each document id, all merging
121-
* the same partial document. No default acl is added: the acl
122-
* field is a creation-only concern.
121+
* the same partial document.
123122
*
124123
* @param indexName the index holding the documents
125124
* @param documentIds the ids of the documents to update

core/app/datasource/src/test/java/io/openk9/datasource/pipeline/actor/PartialUpdateWriterTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class PartialUpdateWriterTest {
4646

4747
static byte[] jsonArray = "[]".getBytes();
4848

49+
static byte[] partialWithAcl =
50+
"{\"contentId\":\"content-1\",\"acl\":{\"public\":false}}".getBytes();
51+
4952
@Test
5053
void should_update_single_document_with_partial_fields() {
5154
// classic enrich pipeline: one indexed document for the contentId
@@ -105,13 +108,21 @@ void should_build_no_operations_when_no_documents_match() {
105108

106109
@Test
107110
void should_not_add_default_acl_on_update() {
108-
// the default acl is a creation-only concern:
109-
// a partial update must not touch it.
111+
// the default acl is injected only at creation:
112+
// when the payload omits acl, the update adds none.
110113
var partial = PartialUpdateWriter.preparePartialDocument(partialDocument);
111114

112115
Assertions.assertFalse(partial.containsKey("acl"));
113116
}
114117

118+
@Test
119+
void should_update_acl_when_present_in_partial_document() {
120+
// an acl carried by the partial document is applied, not stripped
121+
var partial = PartialUpdateWriter.preparePartialDocument(partialWithAcl);
122+
123+
Assertions.assertEquals(Map.of("public", false), partial.get("acl"));
124+
}
125+
115126
@Test
116127
void should_strip_null_fields_and_type_from_partial_document() {
117128
var partial = PartialUpdateWriter.preparePartialDocument(partialDocument);

0 commit comments

Comments
 (0)