• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright 2015 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_TEST_CPP_INTEROP_CLIENT_HELPER_H
20 #define GRPC_TEST_CPP_INTEROP_CLIENT_HELPER_H
21 
22 #include <memory>
23 #include <unordered_map>
24 
25 #include <grpcpp/channel.h>
26 
27 #include "src/core/lib/surface/call_test_only.h"
28 
29 namespace grpc {
30 namespace testing {
31 
32 grpc::string GetServiceAccountJsonKey();
33 
34 grpc::string GetOauth2AccessToken();
35 
36 void UpdateActions(
37     std::unordered_map<grpc::string, std::function<bool()>>* actions);
38 
39 std::shared_ptr<Channel> CreateChannelForTestCase(
40     const grpc::string& test_case);
41 
42 class InteropClientContextInspector {
43  public:
InteropClientContextInspector(const::grpc::ClientContext & context)44   InteropClientContextInspector(const ::grpc::ClientContext& context)
45       : context_(context) {}
46 
47   // Inspector methods, able to peek inside ClientContext, follow.
GetCallCompressionAlgorithm()48   grpc_compression_algorithm GetCallCompressionAlgorithm() const {
49     return grpc_call_test_only_get_compression_algorithm(context_.call_);
50   }
51 
GetMessageFlags()52   uint32_t GetMessageFlags() const {
53     return grpc_call_test_only_get_message_flags(context_.call_);
54   }
55 
56  private:
57   const ::grpc::ClientContext& context_;
58 };
59 
60 }  // namespace testing
61 }  // namespace grpc
62 
63 #endif  // GRPC_TEST_CPP_INTEROP_CLIENT_HELPER_H
64