1 // Copyright 2019 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #include "google/cloud/storage/client.h" 16 #include "google/cloud/storage/internal/openssl_util.h" 17 #include "google/cloud/storage/testing/storage_integration_test.h" 18 #include "google/cloud/internal/getenv.h" 19 #include "google/cloud/testing_util/assert_ok.h" 20 #include <gmock/gmock.h> 21 22 namespace google { 23 namespace cloud { 24 namespace storage { 25 inline namespace STORAGE_CLIENT_NS { 26 namespace internal { 27 namespace { 28 29 class CurlSignBlobIntegrationTest 30 : public google::cloud::storage::testing::StorageIntegrationTest { 31 protected: SetUp()32 void SetUp() override { 33 service_account_ = 34 google::cloud::internal::GetEnv( 35 "GOOGLE_CLOUD_CPP_STORAGE_TEST_SIGNING_SERVICE_ACCOUNT") 36 .value_or(""); 37 ASSERT_FALSE(service_account_.empty()); 38 } 39 40 std::string service_account_; 41 }; 42 TEST_F(CurlSignBlobIntegrationTest,Simple)43TEST_F(CurlSignBlobIntegrationTest, Simple) { 44 StatusOr<Client> client = MakeIntegrationTestClient(); 45 ASSERT_STATUS_OK(client); 46 47 auto encoded = Base64Encode(LoremIpsum()); 48 49 SignBlobRequest request(service_account_, encoded, {}); 50 51 StatusOr<SignBlobResponse> response = client->raw_client()->SignBlob(request); 52 ASSERT_STATUS_OK(response); 53 54 EXPECT_FALSE(response->key_id.empty()); 55 EXPECT_FALSE(response->signed_blob.empty()); 56 57 auto decoded = Base64Decode(response->signed_blob); 58 EXPECT_FALSE(decoded.empty()); 59 } 60 61 } // namespace 62 } // namespace internal 63 } // namespace STORAGE_CLIENT_NS 64 } // namespace storage 65 } // namespace cloud 66 } // namespace google 67