certificate_provider_registry_test.cc
Go to the documentation of this file.
1 //
2 //
3 // Copyright 2020 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18 
20 
22 
23 #include <gmock/gmock.h>
24 
27 
28 namespace grpc_core {
29 namespace testing {
30 namespace {
31 
32 class FakeCertificateProviderFactory1 : public CertificateProviderFactory {
33  public:
34  const char* name() const override { return "fake1"; }
35 
36  RefCountedPtr<Config> CreateCertificateProviderConfig(
37  const Json& /*config_json*/, grpc_error_handle* /*error*/) override {
38  return nullptr;
39  }
40 
41  RefCountedPtr<grpc_tls_certificate_provider> CreateCertificateProvider(
42  RefCountedPtr<Config> /*config*/) override {
43  return nullptr;
44  }
45 };
46 
47 class FakeCertificateProviderFactory2 : public CertificateProviderFactory {
48  public:
49  const char* name() const override { return "fake2"; }
50 
51  RefCountedPtr<Config> CreateCertificateProviderConfig(
52  const Json& /*config_json*/, grpc_error_handle* /*error*/) override {
53  return nullptr;
54  }
55 
56  RefCountedPtr<grpc_tls_certificate_provider> CreateCertificateProvider(
57  RefCountedPtr<Config> /*config*/) override {
58  return nullptr;
59  }
60 };
61 
62 TEST(CertificateProviderRegistryTest, Basic) {
64  auto* fake_factory_1 = new FakeCertificateProviderFactory1;
65  auto* fake_factory_2 = new FakeCertificateProviderFactory2;
67  std::unique_ptr<CertificateProviderFactory>(fake_factory_1));
69  std::unique_ptr<CertificateProviderFactory>(fake_factory_2));
70  EXPECT_EQ(
72  fake_factory_1);
73  EXPECT_EQ(
75  fake_factory_2);
76  EXPECT_EQ(
78  nullptr);
80 }
81 
82 } // namespace
83 } // namespace testing
84 } // namespace grpc_core
85 
86 int main(int argc, char** argv) {
87  ::testing::InitGoogleTest(&argc, argv);
89  auto result = RUN_ALL_TESTS();
90  return result;
91 }
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
testing
Definition: aws_request_signer_test.cc:25
grpc_core::CertificateProviderRegistry::RegisterCertificateProviderFactory
static void RegisterCertificateProviderFactory(std::unique_ptr< CertificateProviderFactory > factory)
Definition: certificate_provider_registry.cc:85
generate.env
env
Definition: generate.py:37
grpc_core::CertificateProviderRegistry::ShutdownRegistry
static void ShutdownRegistry()
Definition: certificate_provider_registry.cc:80
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::CertificateProviderRegistry::InitRegistry
static void InitRegistry()
Definition: certificate_provider_registry.cc:76
setup.name
name
Definition: setup.py:542
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition: iomgr/time_averaged_stats_test.cc:27
grpc_tls_certificate_provider.h
Json
JSON (JavaScript Object Notation).
Definition: third_party/bloaty/third_party/protobuf/conformance/third_party/jsoncpp/json.h:227
RUN_ALL_TESTS
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2471
test_config.h
testing::InitGoogleTest
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6106
grpc::testing::TestEnvironment
Definition: test/core/util/test_config.h:54
certificate_provider_registry.h
grpc_core::testing::TEST
TEST(ServiceConfigParserTest, DoubleRegistration)
Definition: service_config_test.cc:448
main
int main(int argc, char **argv)
Definition: certificate_provider_registry_test.cc:86
grpc_error
Definition: error_internal.h:42
grpc_core::CertificateProviderRegistry::LookupCertificateProviderFactory
static CertificateProviderFactory * LookupCertificateProviderFactory(absl::string_view name)
Definition: certificate_provider_registry.cc:70
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:52