mirror of
https://github.com/hanzoai/datastore.git
synced 2026-09-26 13:55:07 +00:00
Merge upstream/changelog-26.6 (9593 commits) into our debranded fork. - 190 conflicts resolved: 24 delete-side kept-removed (grpc/arrowflight/gcloud), submodules+version→26.6, contrib/CMakeLists keeps zap + new libpng, drops capnproto (zap provides kj), Server.cpp/CMakeLists re-apply the ZAP wiring + gRPC/arrowflight/gcloud removal. - Full-tree debrand re-swept over the new 26.6 code (uniform Datastore naming; Azure fork Clickhouse* symbols preserved). 0 clickhouse in product src/programs/CMakeLists. - Version now 26.6.1.1. gRPC/google-cloud/chdig stay removed; ZAP remains the transport.
87 lines
2.6 KiB
Python
87 lines
2.6 KiB
Python
import pytest
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
|
|
|
node = cluster.add_instance("node")
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def start_cluster():
|
|
try:
|
|
cluster.start()
|
|
yield cluster
|
|
|
|
finally:
|
|
cluster.shutdown()
|
|
|
|
|
|
def make_storage_with_key(id):
|
|
node.exec_in_container(
|
|
[
|
|
"bash",
|
|
"-c",
|
|
"""cat > /etc/clickhouse-server/config.d/storage_keys_config.xml << EOF
|
|
<datastore>
|
|
<encryption_codecs>
|
|
<aes_128_gcm_siv>
|
|
<key_hex id="0">83e84e9a4eb11535c0670dc62d808ee0</key_hex>
|
|
<key id="1">abcdefghijklmnop</key>
|
|
<current_key_id>{cur_id}</current_key_id>
|
|
</aes_128_gcm_siv>
|
|
<aes_256_gcm_siv>
|
|
<key_hex id="0">83e84e9a4eb11535c0670dc62d808ee083e84e9a4eb11535c0670dc62d808ee0</key_hex>
|
|
<key id="1">abcdefghijklmnopabcdefghijklmnop</key>
|
|
<current_key_id>{cur_id}</current_key_id>
|
|
</aes_256_gcm_siv>
|
|
</encryption_codecs>
|
|
</datastore>
|
|
EOF""".format(
|
|
cur_id=id
|
|
),
|
|
]
|
|
)
|
|
node.query("SYSTEM RELOAD CONFIG")
|
|
|
|
|
|
def test_different_keys(start_cluster):
|
|
make_storage_with_key(0)
|
|
node.query(
|
|
"""
|
|
CREATE TABLE encrypted_test_128 (
|
|
id Int64,
|
|
data String Codec(AES_128_GCM_SIV)
|
|
) ENGINE=MergeTree()
|
|
ORDER BY id
|
|
"""
|
|
)
|
|
|
|
node.query(
|
|
"""
|
|
CREATE TABLE encrypted_test_256 (
|
|
id Int64,
|
|
data String Codec(AES_256_GCM_SIV)
|
|
) ENGINE=MergeTree()
|
|
ORDER BY id
|
|
"""
|
|
)
|
|
|
|
node.query("INSERT INTO encrypted_test_128 VALUES (0,'data'),(1,'data')")
|
|
select_query = "SELECT * FROM encrypted_test_128 ORDER BY id FORMAT Values"
|
|
assert node.query(select_query) == "(0,'data'),(1,'data')"
|
|
|
|
make_storage_with_key(1)
|
|
node.query("INSERT INTO encrypted_test_128 VALUES (3,'text'),(4,'text')")
|
|
select_query = "SELECT * FROM encrypted_test_128 ORDER BY id FORMAT Values"
|
|
assert node.query(select_query) == "(0,'data'),(1,'data'),(3,'text'),(4,'text')"
|
|
|
|
node.query("INSERT INTO encrypted_test_256 VALUES (0,'data'),(1,'data')")
|
|
select_query = "SELECT * FROM encrypted_test_256 ORDER BY id FORMAT Values"
|
|
assert node.query(select_query) == "(0,'data'),(1,'data')"
|
|
|
|
make_storage_with_key(1)
|
|
node.query("INSERT INTO encrypted_test_256 VALUES (3,'text'),(4,'text')")
|
|
select_query = "SELECT * FROM encrypted_test_256 ORDER BY id FORMAT Values"
|
|
assert node.query(select_query) == "(0,'data'),(1,'data'),(3,'text'),(4,'text')"
|