GRPC Core  9.0.0
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 
25 
26 #define GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS \
27  "grpc.fake_security.expected_targets"
28 
29 /* -- Fake transport security credentials. -- */
30 
31 /* Creates a fake transport security credentials object for testing. */
33 
34 /* Creates a fake server transport security credentials object for testing. */
36  void);
37 
38 /* Used to verify the target names given to the fake transport security
39  * connector.
40  *
41  * The syntax of \a expected_targets by example:
42  * For LB channels:
43  * "backend_target_1,backend_target_2,...;lb_target_1,lb_target_2,..."
44  * For regular channels:
45  * "backend_taget_1,backend_target_2,..."
46  *
47  * That is to say, LB channels have a heading list of LB targets separated from
48  * the list of backend targets by a semicolon. For non-LB channels, only the
49  * latter is present. */
51 
52 /* Return the value associated with the expected targets channel arg or NULL */
54  const grpc_channel_args* args);
55 
56 /* -- Metadata-only Test credentials. -- */
57 
59  public:
60  grpc_md_only_test_credentials(const char* md_key, const char* md_value,
61  bool is_async)
65  is_async_(is_async) {}
67 
71  grpc_closure* on_request_metadata,
72  grpc_error** error) override;
73 
75  grpc_error* error) override;
76 
77  private:
78  grpc_mdelem md_;
79  bool is_async_;
80 };
81 
82 #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H */
Definition: fake_credentials.h:58
~grpc_md_only_test_credentials() override
Definition: fake_credentials.h:66
bool get_request_metadata(grpc_polling_entity *pollent, grpc_auth_metadata_context context, grpc_credentials_mdelem_array *md_array, grpc_closure *on_request_metadata, grpc_error **error) override
Definition: fake_credentials.cc:91
void cancel_get_request_metadata(grpc_credentials_mdelem_array *md_array, grpc_error *error) override
Definition: fake_credentials.cc:104
grpc_md_only_test_credentials(const char *md_key, const char *md_value, bool is_async)
Definition: fake_credentials.h:60
#define GRPC_CALL_CREDENTIALS_TYPE_OAUTH2
Definition: credentials.h:53
grpc_arg grpc_fake_transport_expected_targets_arg(char *expected_targets)
Definition: fake_credentials.cc:77
grpc_server_credentials * grpc_fake_transport_security_server_credentials_create(void)
Definition: fake_credentials.cc:73
grpc_channel_credentials * grpc_fake_transport_security_credentials_create(void)
Definition: fake_credentials.cc:68
const char * grpc_fake_transport_get_expected_targets(const grpc_channel_args *args)
Definition: fake_credentials.cc:82
grpc_mdelem grpc_mdelem_from_slices(const grpc_slice &key, const grpc_slice &value)
Definition: metadata.cc:503
#define GRPC_MDELEM_UNREF(s)
Definition: metadata.h:368
GPRAPI grpc_slice grpc_slice_from_copied_string(const char *source)
Create a slice by copying a string.
Definition: slice.cc:209
A single argument...
Definition: grpc_types.h:103
Context that can be used by metadata credentials plugin in order to create auth related metadata.
Definition: grpc_security.h:373
Definition: credentials.h:226
An array of arguments that can be passed around.
Definition: grpc_types.h:132
Definition: credentials.h:100
A closure over a grpc_iomgr_cb_func.
Definition: closure.h:56
Definition: credentials.h:205
Definition: error_internal.h:39
Definition: metadata.h:98
Definition: polling_entity.h:37
Definition: credentials.h:264