Line data Source code
1 : /*
2 : *
3 : * Copyright 2015, Google Inc.
4 : * All rights reserved.
5 : *
6 : * Redistribution and use in source and binary forms, with or without
7 : * modification, are permitted provided that the following conditions are
8 : * met:
9 : *
10 : * * Redistributions of source code must retain the above copyright
11 : * notice, this list of conditions and the following disclaimer.
12 : * * Redistributions in binary form must reproduce the above
13 : * copyright notice, this list of conditions and the following disclaimer
14 : * in the documentation and/or other materials provided with the
15 : * distribution.
16 : * * Neither the name of Google Inc. nor the names of its
17 : * contributors may be used to endorse or promote products derived from
18 : * this software without specific prior written permission.
19 : *
20 : * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 : * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 : * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 : * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 : * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 : * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 : * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 : * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 : * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 : * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 : * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 : *
32 : */
33 :
34 : #include "test/cpp/interop/server_helper.h"
35 :
36 : #include <memory>
37 :
38 : #include <gflags/gflags.h>
39 : #include <grpc++/security/server_credentials.h>
40 :
41 : #include "src/core/surface/call_test_only.h"
42 : #include "test/core/end2end/data/ssl_test_data.h"
43 :
44 : DECLARE_bool(use_tls);
45 :
46 : namespace grpc {
47 : namespace testing {
48 :
49 1 : std::shared_ptr<ServerCredentials> CreateInteropServerCredentials() {
50 1 : if (FLAGS_use_tls) {
51 : SslServerCredentialsOptions::PemKeyCertPair pkcp = {test_server1_key,
52 0 : test_server1_cert};
53 0 : SslServerCredentialsOptions ssl_opts;
54 0 : ssl_opts.pem_root_certs = "";
55 0 : ssl_opts.pem_key_cert_pairs.push_back(pkcp);
56 0 : return SslServerCredentials(ssl_opts);
57 : } else {
58 1 : return InsecureServerCredentials();
59 : }
60 : }
61 :
62 0 : InteropServerContextInspector::InteropServerContextInspector(
63 : const ::grpc::ServerContext& context)
64 0 : : context_(context) {}
65 :
66 : grpc_compression_algorithm
67 0 : InteropServerContextInspector::GetCallCompressionAlgorithm() const {
68 0 : return grpc_call_test_only_get_compression_algorithm(context_.call_);
69 : }
70 :
71 0 : gpr_uint32 InteropServerContextInspector::GetEncodingsAcceptedByClient() const {
72 0 : return grpc_call_test_only_get_encodings_accepted_by_peer(context_.call_);
73 : }
74 :
75 : std::shared_ptr<const AuthContext>
76 0 : InteropServerContextInspector::GetAuthContext() const {
77 0 : return context_.auth_context();
78 : }
79 :
80 0 : bool InteropServerContextInspector::IsCancelled() const {
81 0 : return context_.IsCancelled();
82 : }
83 :
84 : } // namespace testing
85 : } // namespace grpc
|