Skip to content

Commit

Permalink
Fix conformance test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
bajajneha27 committed May 22, 2024
1 parent 9bd47d7 commit d2ad425
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions google/cloud/storage/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "google/cloud/internal/make_status.h"
#include "google/cloud/internal/opentelemetry.h"
#include "google/cloud/log.h"
#include "absl/strings/str_split.h"
#include <fstream>
#include <memory>
#include <thread>
Expand Down Expand Up @@ -487,9 +488,12 @@ std::string Client::Endpoint() const {
}

std::string Client::Host() const {
auto const host = Endpoint();
auto const prefix = std::string{"https://"};
return host.substr(prefix.length());
auto endpoint = Endpoint();
auto host = absl::string_view(endpoint);
if (!absl::ConsumePrefix(&host, "https://")) {
absl::ConsumePrefix(&host, "http://");
}
return std::string(host);
}

namespace internal {
Expand Down
3 changes: 3 additions & 0 deletions google/cloud/storage/tests/signed_url_conformance_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "google/cloud/internal/time_utils.h"
#include "google/cloud/terminate_handler.h"
#include "google/cloud/testing_util/status_matchers.h"
#include "google/cloud/testing_util/scoped_environment.h"
#include <google/protobuf/util/json_util.h>
#include <gmock/gmock.h>
#include <fstream>
Expand Down Expand Up @@ -75,6 +76,7 @@ class V4SignedUrlConformanceTest
class V4PostPolicyConformanceTest : public V4SignedUrlConformanceTest {};

TEST_P(V4SignedUrlConformanceTest, V4SignJson) {
testing_util::ScopedEnvironment endpoint("CLOUD_STORAGE_EMULATOR_ENDPOINT", absl::nullopt);
auto creds = oauth2::CreateServiceAccountCredentialsFromJsonFilePath(
service_account_key_filename_);
ASSERT_STATUS_OK(creds);
Expand Down Expand Up @@ -176,6 +178,7 @@ INSTANTIATE_TEST_SUITE_P(
}()));

TEST_P(V4PostPolicyConformanceTest, V4PostPolicy) {
testing_util::ScopedEnvironment endpoint("CLOUD_STORAGE_EMULATOR_ENDPOINT", absl::nullopt);
auto creds = oauth2::CreateServiceAccountCredentialsFromJsonFilePath(
service_account_key_filename_);
ASSERT_STATUS_OK(creds);
Expand Down

0 comments on commit d2ad425

Please sign in to comment.