fake_credentials.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 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 
19 #ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H
20 #define GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H
21 
23 
24 #include <string>
25 
26 #include "absl/status/statusor.h"
27 
28 #include <grpc/grpc.h>
29 #include <grpc/grpc_security.h>
32 
39 
40 #define GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS \
41  "grpc.fake_security.expected_targets"
42 
43 /* -- Fake transport security credentials. -- */
44 
45 /* Creates a fake transport security credentials object for testing. */
47 
48 /* Creates a fake server transport security credentials object for testing. */
50  void);
51 
52 /* Used to verify the target names given to the fake transport security
53  * connector.
54  *
55  * The syntax of \a expected_targets by example:
56  * For LB channels:
57  * "backend_target_1,backend_target_2,...;lb_target_1,lb_target_2,..."
58  * For regular channels:
59  * "backend_taget_1,backend_target_2,..."
60  *
61  * That is to say, LB channels have a heading list of LB targets separated from
62  * the list of backend targets by a semicolon. For non-LB channels, only the
63  * latter is present. */
65 
66 /* Return the value associated with the expected targets channel arg or NULL */
68  const grpc_channel_args* args);
69 
70 /* -- Metadata-only Test credentials. -- */
71 
73  public:
74  grpc_md_only_test_credentials(const char* md_key, const char* md_value)
76  key_(grpc_core::Slice::FromCopiedString(md_key)),
77  value_(grpc_core::Slice::FromCopiedString(md_value)) {}
78 
81  const GetRequestMetadataArgs* args) override;
82 
83  std::string debug_string() override { return "MD only Test Credentials"; }
84 
86 
87  grpc_core::UniqueTypeName type() const override { return Type(); }
88 
89  private:
90  int cmp_impl(const grpc_call_credentials* other) const override {
91  // TODO(yashykt): Check if we can do something better here
93  static_cast<const grpc_call_credentials*>(this), other);
94  }
95 
98 };
99 
100 #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H */
grpc_arg
Definition: grpc_types.h:103
slice.h
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::Slice
Definition: src/core/lib/slice/slice.h:282
grpc_fake_transport_security_credentials_create
grpc_channel_credentials * grpc_fake_transport_security_credentials_create(void)
Definition: fake_credentials.cc:79
useful.h
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc_call_credentials
Definition: src/core/lib/security/credentials/credentials.h:189
grpc_md_only_test_credentials::cmp_impl
int cmp_impl(const grpc_call_credentials *other) const override
Definition: fake_credentials.h:90
grpc_md_only_test_credentials::key_
grpc_core::Slice key_
Definition: fake_credentials.h:96
grpc_security.h
credentials.h
grpc_channel_args
Definition: grpc_types.h:132
grpc_fake_transport_expected_targets_arg
grpc_arg grpc_fake_transport_expected_targets_arg(char *expected_targets)
Definition: fake_credentials.cc:88
grpc_types.h
grpc_md_only_test_credentials::type
grpc_core::UniqueTypeName type() const override
Definition: fake_credentials.h:87
GRPC_SECURITY_NONE
@ GRPC_SECURITY_NONE
Definition: grpc_security_constants.h:133
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
grpc_md_only_test_credentials::grpc_md_only_test_credentials
grpc_md_only_test_credentials(const char *md_key, const char *md_value)
Definition: fake_credentials.h:74
grpc.h
grpc_md_only_test_credentials::value_
grpc_core::Slice value_
Definition: fake_credentials.h:97
arena_promise.h
grpc_md_only_test_credentials::Type
static grpc_core::UniqueTypeName Type()
Definition: fake_credentials.cc:113
grpc_md_only_test_credentials
Definition: fake_credentials.h:72
grpc_core::MetadataHandle< ClientMetadata >
grpc_server_credentials
Definition: src/core/lib/security/credentials/credentials.h:259
grpc_fake_transport_security_server_credentials_create
grpc_server_credentials * grpc_fake_transport_security_server_credentials_create(void)
Definition: fake_credentials.cc:84
grpc_core::UniqueTypeName
Definition: unique_type_name.h:56
grpc_core::ArenaPromise
Definition: arena_promise.h:152
grpc_core::QsortCompare
int QsortCompare(const T &a, const T &b)
Definition: useful.h:95
grpc_md_only_test_credentials::debug_string
std::string debug_string() override
Definition: fake_credentials.h:83
grpc_security_constants.h
grpc_md_only_test_credentials::GetRequestMetadata
grpc_core::ArenaPromise< absl::StatusOr< grpc_core::ClientMetadataHandle > > GetRequestMetadata(grpc_core::ClientMetadataHandle initial_metadata, const GetRequestMetadataArgs *args) override
Definition: fake_credentials.cc:104
unique_type_name.h
transport.h
grpc_channel_credentials
Definition: src/core/lib/security/credentials/credentials.h:96
grpc_fake_transport_get_expected_targets
const char * grpc_fake_transport_get_expected_targets(const grpc_channel_args *args)
Definition: fake_credentials.cc:94
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:22