Skip to content

Commit c782ca3

Browse files
committed
tests(serializer): ensure internal fields are removed
1 parent b5aa66f commit c782ca3

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

cds/modules/records/serializers/json.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def _remove_internal_fields(self, record, metadata):
9595
metadata.pop("_access", None)
9696
metadata.pop("_buckets", None)
9797
metadata.pop("_cds", None)
98-
metadata.pop("_deposit", None)
9998
return metadata
10099

101100
def preprocess_record(self, pid, record, links_factory=None):

tests/unit/test_serializer.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ def test_cds_json_serializer_sanitization(video_record_metadata):
173173
'title': {'title': '<script>alert("bad")</script> Titre'}
174174
}
175175
]
176+
177+
record["_access"] = {
178+
"key": "value"
179+
}
180+
record["_buckets"] = {
181+
"key":"value"
182+
}
183+
record["_cds"] = {
184+
"key":"value"
185+
}
176186

177187
# Test the serializer
178188
serializer = CDSJSONSerializer()
@@ -201,3 +211,7 @@ def test_cds_json_serializer_sanitization(video_record_metadata):
201211
translations = result['metadata']['translations']
202212
for tr in translations:
203213
assert '<script>' not in tr['description']
214+
215+
assert "_access" not in result
216+
assert "_buckets" not in result
217+
assert "_cds" not in result

0 commit comments

Comments
 (0)