Skip to content

Commit

Permalink
Move code to google/cloud/oauth2
Browse files Browse the repository at this point in the history
  • Loading branch information
coryan committed Jul 12, 2023
1 parent fba2c30 commit a4cc218
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 37 deletions.
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ cc_library(
name = "oauth2",
testonly = True,
deps = [
"//google/cloud:google_cloud_cpp_oauth2",
"//google/cloud/oauth2:google_cloud_cpp_oauth2",
],
)

Expand Down
24 changes: 0 additions & 24 deletions google/cloud/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ load(":google_cloud_cpp_grpc_utils_integration_tests.bzl", "google_cloud_cpp_grp
load(":google_cloud_cpp_grpc_utils_unit_tests.bzl", "google_cloud_cpp_grpc_utils_unit_tests")
load(":google_cloud_cpp_grpc_utils.bzl", "google_cloud_cpp_grpc_utils_hdrs", "google_cloud_cpp_grpc_utils_srcs")
load(":google_cloud_cpp_mocks.bzl", "google_cloud_cpp_mocks_hdrs")
load(":google_cloud_cpp_oauth2_unit_tests.bzl", "google_cloud_cpp_oauth2_unit_tests")
load(":google_cloud_cpp_oauth2.bzl", "google_cloud_cpp_oauth2_hdrs", "google_cloud_cpp_oauth2_srcs")
load(":google_cloud_cpp_rest_internal_benchmarks.bzl", "google_cloud_cpp_rest_internal_benchmarks")
load(":google_cloud_cpp_rest_internal_emulator_integration_tests.bzl", "google_cloud_cpp_rest_internal_emulator_integration_tests")
load(":google_cloud_cpp_rest_internal_production_integration_tests.bzl", "google_cloud_cpp_rest_internal_production_integration_tests")
Expand Down Expand Up @@ -340,28 +338,6 @@ cc_library(
],
) for test in google_cloud_cpp_rest_protobuf_internal_unit_tests]

cc_library(
name = "google_cloud_cpp_oauth2",
srcs = google_cloud_cpp_oauth2_srcs,
hdrs = google_cloud_cpp_oauth2_hdrs,
visibility = ["//:__subpackages__"],
deps = [
":google_cloud_cpp_common",
":google_cloud_cpp_rest_internal",
],
)

[cc_test(
name = test.replace("/", "_").replace(".cc", ""),
srcs = [test],
deps = [
":google_cloud_cpp_oauth2",
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
"//google/cloud/testing_util:google_cloud_cpp_testing_rest_private",
"@com_google_googletest//:gtest_main",
],
) for test in google_cloud_cpp_oauth2_unit_tests]

[cc_test(
name = sample.replace("/", "_").replace(".cc", ""),
srcs = [sample],
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ endif ()

if (GOOGLE_CLOUD_CPP_ENABLE_REST)
include("${CMAKE_CURRENT_SOURCE_DIR}/google_cloud_cpp_rest_internal.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/google_cloud_cpp_oauth2.cmake")
add_subdirectory(oauth2)
endif ()

if (GOOGLE_CLOUD_CPP_ENABLE_REST AND GOOGLE_CLOUD_CPP_ENABLE_GRPC)
Expand Down
42 changes: 42 additions & 0 deletions google/cloud/oauth2/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

package(default_visibility = ["//visibility:private"])

licenses(["notice"]) # Apache 2.0

load(":google_cloud_cpp_oauth2_unit_tests.bzl", "google_cloud_cpp_oauth2_unit_tests")
load(":google_cloud_cpp_oauth2.bzl", "google_cloud_cpp_oauth2_hdrs", "google_cloud_cpp_oauth2_srcs")

cc_library(
name = "google_cloud_cpp_oauth2",
srcs = google_cloud_cpp_oauth2_srcs,
hdrs = google_cloud_cpp_oauth2_hdrs,
visibility = ["//:__subpackages__"],
deps = [
"//:common",
"//google/cloud:google_cloud_cpp_rest_internal",
],
)

[cc_test(
name = test.replace("/", "_").replace(".cc", ""),
srcs = [test],
deps = [
":google_cloud_cpp_oauth2",
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
"//google/cloud/testing_util:google_cloud_cpp_testing_rest_private",
"@com_google_googletest//:gtest_main",
],
) for test in google_cloud_cpp_oauth2_unit_tests]
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
# limitations under the License.
# ~~~

# the library
include(GoogleCloudCppCommon)
set(DOXYGEN_PROJECT_NAME "OAuth2 Access Token Generation Library")
set(DOXYGEN_PROJECT_BRIEF
"Create OAuth2 Access Tokens for any GCP authentication mechanism")
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION}")
set(DOXYGEN_EXCLUDE_SYMBOLS "internal")

add_library(google_cloud_cpp_oauth2 # cmake-format: sort
access_token_generator.cc access_token_generator.h)
target_link_libraries(
Expand Down Expand Up @@ -55,14 +61,12 @@ install(
google_cloud_cpp_install_headers(google_cloud_cpp_oauth2 include/google/cloud)

google_cloud_cpp_add_pkgconfig(
oauth2 "OAuth2 helpers with Google Cloud C++ Client Library"
"Provides components to create OAuth2 access tokens."
oauth2 "${DOXYGEN_PROJECT_NAME}" "${DOXYGEN_PROJECT_BRIEF}"
"google_cloud_cpp_rest_internal" "google_cloud_cpp_common")

# Create and install the CMake configuration files.
include(CMakePackageConfigHelpers)
configure_file("config-oauth2.cmake.in" "google_cloud_cpp_oauth2-config.cmake"
@ONLY)
configure_file("config.cmake.in" "google_cloud_cpp_oauth2-config.cmake" @ONLY)
write_basic_package_version_file(
"google_cloud_cpp_oauth2-config-version.cmake"
VERSION ${PROJECT_VERSION}
Expand All @@ -88,7 +92,7 @@ if (NOT BUILD_TESTING)
endif ()

foreach (fname IN LISTS google_cloud_cpp_oauth2_unit_tests)
google_cloud_cpp_add_executable(target "common" "${fname}")
google_cloud_cpp_add_executable(target "oauth2" "${fname}")
target_link_libraries(
${target}
PRIVATE google-cloud-cpp::oauth2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "google/cloud/access_token_generator.h"
#include "google/cloud/oauth2/access_token_generator.h"
#include "google/cloud/internal/unified_rest_credentials.h"

namespace google {
namespace cloud {
namespace oauth2 {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
namespace {

Expand Down Expand Up @@ -44,5 +45,6 @@ std::shared_ptr<AccessTokenGenerator> MakeAccessTokenGenerator(
}

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace oauth2
} // namespace cloud
} // namespace google
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_ACCESS_TOKEN_GENERATOR_H
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_ACCESS_TOKEN_GENERATOR_H
#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_OAUTH2_ACCESS_TOKEN_GENERATOR_H
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_OAUTH2_ACCESS_TOKEN_GENERATOR_H

#include "google/cloud/access_token.h"
#include "google/cloud/credentials.h"
Expand All @@ -25,6 +25,7 @@

namespace google {
namespace cloud {
namespace oauth2 {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN

/**
Expand Down Expand Up @@ -75,7 +76,8 @@ std::shared_ptr<AccessTokenGenerator> MakeAccessTokenGenerator(
Credentials const& credentials);

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace oauth2
} // namespace cloud
} // namespace google

#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_ACCESS_TOKEN_GENERATOR_H
#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_OAUTH2_ACCESS_TOKEN_GENERATOR_H
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "google/cloud/access_token_generator.h"
#include "google/cloud/oauth2/access_token_generator.h"
#include "google/cloud/testing_util/status_matchers.h"
#include <gmock/gmock.h>

namespace google {
namespace cloud {
namespace oauth2 {
namespace {

using ::google::cloud::testing_util::IsOkAndHolds;
Expand All @@ -32,5 +33,6 @@ TEST(AccessTokenGeneratorTest, Basic) {
}

} // namespace
} // namespace oauth2
} // namespace cloud
} // namespace google
File renamed without changes.
File renamed without changes.

0 comments on commit a4cc218

Please sign in to comment.