From b46b207b1903f3a0ab4ff2d36db5a7c2964f5629 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 27 Aug 2024 14:51:52 +0200 Subject: bytestream API: verify that invalid digests are rejected --- .../execution_api/bazel/bytestream_client.test.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/buildtool/execution_api/bazel/bytestream_client.test.cpp') diff --git a/test/buildtool/execution_api/bazel/bytestream_client.test.cpp b/test/buildtool/execution_api/bazel/bytestream_client.test.cpp index fba05118..10fe0c83 100644 --- a/test/buildtool/execution_api/bazel/bytestream_client.test.cpp +++ b/test/buildtool/execution_api/bazel/bytestream_client.test.cpp @@ -74,6 +74,24 @@ TEST_CASE("ByteStream Client: Transfer single blob", "[execution_api]") { } } + SECTION("Small blob with wrong digest") { + std::string instance_name{"remote-execution"}; + std::string content("foobar"); + std::string other_content("This is a differnt string"); + + // Valid digest, but for a different string + auto digest = static_cast( + ArtifactDigest::Create(hash_function, + other_content)); + + CHECK(not stream.Write(fmt::format("{}/uploads/{}/blobs/{}/{}", + instance_name, + uuid, + digest.hash(), + digest.size_bytes()), + content)); + } + SECTION("Upload large blob") { std::string instance_name{"remote-execution"}; -- cgit v1.2.3