aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpavook <pavook@yandex-team.com>2024-12-23 18:33:25 +0300
committerpavook <pavook@yandex-team.com>2024-12-23 18:51:37 +0300
commita1dd87a52878ab3e46e5fd2dba5ecbba6113d7e0 (patch)
treecacfeb2d7aba1e4b5cbfffd1b2ded00f6933ec36
parentfc66f0bfe6ea1d138f46d189bc38c3af935de5a8 (diff)
downloadydb-a1dd87a52878ab3e46e5fd2dba5ecbba6113d7e0.tar.gz
YT-22308: Change TSignature interface
- Add a constructor from TYsonString - Make TSignatureGenerator fill out the Signature_ and Header_ fields in a given TSignature based on its payload commit_hash:5918e13134db4306795de57a40c7f96b6b37cc4c
-rw-r--r--yt/yt/client/signature/signature.cpp6
-rw-r--r--yt/yt/client/signature/signature.h8
-rw-r--r--yt/yt/client/signature/unittests/signature_ut.cpp8
3 files changed, 22 insertions, 0 deletions
diff --git a/yt/yt/client/signature/signature.cpp b/yt/yt/client/signature/signature.cpp
index 0a71e0a02c..4c071c1407 100644
--- a/yt/yt/client/signature/signature.cpp
+++ b/yt/yt/client/signature/signature.cpp
@@ -14,6 +14,12 @@ using namespace NYTree;
////////////////////////////////////////////////////////////////////////////////
+TSignature::TSignature(NYson::TYsonString payload)
+ : Payload_(std::move(payload))
+{ }
+
+////////////////////////////////////////////////////////////////////////////////
+
const TYsonString& TSignature::Payload() const
{
return Payload_;
diff --git a/yt/yt/client/signature/signature.h b/yt/yt/client/signature/signature.h
index e0025b7a27..f6602994ce 100644
--- a/yt/yt/client/signature/signature.h
+++ b/yt/yt/client/signature/signature.h
@@ -15,6 +15,14 @@ namespace NYT::NSignature {
class TSignature final
{
public:
+ // NB(pavook) only needed for Deserialize internals.
+
+ //! Constructs an empty TSignature.
+ TSignature() = default;
+
+ //! Creates a TSignature containing the given payload without an actual signature.
+ explicit TSignature(NYson::TYsonString payload);
+
[[nodiscard]] const NYson::TYsonString& Payload() const;
private:
diff --git a/yt/yt/client/signature/unittests/signature_ut.cpp b/yt/yt/client/signature/unittests/signature_ut.cpp
index 2639715746..75ae1733fa 100644
--- a/yt/yt/client/signature/unittests/signature_ut.cpp
+++ b/yt/yt/client/signature/unittests/signature_ut.cpp
@@ -16,6 +16,14 @@ using namespace NYTree;
////////////////////////////////////////////////////////////////////////////////
+TEST(TSignatureTest, PayloadConstruct)
+{
+ TSignature signature(TYsonString("payload"_sb));
+ EXPECT_EQ(signature.Payload().ToString(), "payload");
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
TEST(TSignatureTest, DeserializeSerialize)
{
// SignatureSize bytes.