Skip to content

Commit 3c53606

Browse files
committed
Test encryption-keys round-trip through V3 metadata JSON
model_dump_json is now the write path for V3 metadata, so cover that encryption keys survive serializing and re-parsing.
1 parent 7b5d3ff commit 3c53606

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎tests/table/test_metadata.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,3 +1010,18 @@ def test_v3_metadata_with_encryption_keys_serializes_them(example_table_metadata
10101010
assert table_metadata.model_dump(mode="json")["encryption-keys"] == [
10111011
{"key-id": "a", "encrypted-key-metadata": "a2V5", "properties": {}}
10121012
]
1013+
1014+
1015+
def test_v3_metadata_encryption_keys_round_trip_through_json(example_table_metadata_v3: dict[str, Any]) -> None:
1016+
encryption_keys = [
1017+
{"key-id": "table-key-1", "encrypted-key-metadata": "a2V5", "properties": {"a": "b"}},
1018+
{"key-id": "table-key-2", "encrypted-key-metadata": "a2V5", "encrypted-by-id": "table-key-1"},
1019+
]
1020+
table_metadata = TableMetadataUtil.parse_obj({**example_table_metadata_v3, "encryption-keys": encryption_keys})
1021+
1022+
serialized = table_metadata.model_dump_json()
1023+
assert json.loads(serialized)["encryption-keys"] == [
1024+
{"key-id": "table-key-1", "encrypted-key-metadata": "a2V5", "properties": {"a": "b"}},
1025+
{"key-id": "table-key-2", "encrypted-key-metadata": "a2V5", "encrypted-by-id": "table-key-1", "properties": {}},
1026+
]
1027+
assert TableMetadataUtil.parse_raw(serialized) == table_metadata

0 commit comments

Comments
 (0)