Skip to content

Commit bbae259

Browse files
committed
update tests
1 parent 0e6ae61 commit bbae259

5 files changed

Lines changed: 17 additions & 8 deletions

File tree

ci/cloudbuild/builds/cmake-install.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ expected_dirs+=(
133133
./include/google/cloud/storage/internal/grpc
134134
./include/google/cloud/storage/internal/rest
135135
./include/google/cloud/storage/mocks
136-
./include/google/cloud/storage/oauth2
137136
./include/google/cloud/storage/testing
138137
# no gRPC services in google/cloud/workflows/type.
139138
./include/google/cloud/workflows/type

google/cloud/credentials.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ std::shared_ptr<Credentials> MakeServiceAccountCredentials(
335335
* [service account key]:
336336
* https://cloud.google.com/iam/docs/creating-managing-service-account-keys#iam-service-account-keys-create-cpp
337337
*
338+
* Use `ScopesOption` to restrict the authentication scope for the obtained
339+
* credentials.
340+
*
338341
* @ingroup guac
339342
*
340343
* @note While JSON file formats are supported for both REST and gRPC transport,

google/cloud/internal/unified_rest_credentials.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,16 @@ std::shared_ptr<oauth2_internal::Credentials> MapCredentials(
165165

166166
void visit(ServiceAccountConfig const& cfg) override {
167167
if (cfg.file_path().has_value()) {
168-
result = Decorate(CreateServiceAccountCredentialsFromFilePath(
169-
*cfg.file_path(), {}, {}, cfg.options(),
170-
std::move(client_factory_)),
171-
cfg.options());
168+
std::set<std::string> scopes;
169+
if (cfg.options().has<ScopesOption>()) {
170+
auto s = cfg.options().get<ScopesOption>();
171+
scopes.insert(s.begin(), s.end());
172+
}
173+
result =
174+
Decorate(CreateServiceAccountCredentialsFromFilePath(
175+
*cfg.file_path(), std::move(scopes), absl::nullopt,
176+
cfg.options(), std::move(client_factory_)),
177+
cfg.options());
172178
} else {
173179
auto creds = CreateServiceAccountCredentialsFromJsonContents(
174180
cfg.json_object(), cfg.options(), std::move(client_factory_));

google/cloud/storage/ci/run_integration_tests_emulator_bazel.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ readonly PRODUCTION_ONLY_BASE=(
5959
"//google/cloud/storage/tests:alternative_endpoint_integration_test"
6060
"//google/cloud/storage/tests:key_file_integration_test"
6161
"//google/cloud/storage/tests:signed_url_integration_test"
62-
"//google/cloud/storage/tests:unified_credentials_integration_test"
6362
)
6463
for base in "${PRODUCTION_ONLY_BASE[@]}"; do
6564
production_only_targets+=(

google/cloud/storage/tests/service_account_credentials_integration_test.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// #include "google/cloud/storage/oauth2/google_credentials.h"
1615
#include "google/cloud/storage/testing/retry_http_request.h"
1716
#include "google/cloud/storage/testing/storage_integration_test.h"
1817
#include "google/cloud/internal/getenv.h"
@@ -23,7 +22,6 @@
2322
#include <gmock/gmock.h>
2423
#include <nlohmann/json.hpp>
2524
#include <chrono>
26-
#include <set>
2725
#include <string>
2826
#include <utility>
2927

@@ -44,6 +42,10 @@ TEST_F(ServiceAccountCredentialsTest, UserInfoOAuth2) {
4442
"GOOGLE_CLOUD_CPP_STORAGE_TEST_KEY_FILE_JSON");
4543
if (UsingEmulator() || !filename) GTEST_SKIP();
4644

45+
auto options = Options{}.set<ScopesOption>(std::vector<std::string>(
46+
{"https://www.googleapis.com/auth/userinfo.email",
47+
"https://www.googleapis.com/auth/cloud-platform"}));
48+
4749
auto credentials = MakeServiceAccountCredentialsFromFile(*filename);
4850

4951
// auto credentials = oauth2::CreateServiceAccountCredentialsFromFilePath(

0 commit comments

Comments
 (0)