grpc 1.58.3-aarch64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/etc/roots.pem +4337 -0
- data/grpc_c.32-msvcrt.ruby +0 -0
- data/grpc_c.64-msvcrt.ruby +0 -0
- data/grpc_c.64-ucrt.ruby +0 -0
- data/src/ruby/bin/math_client.rb +140 -0
- data/src/ruby/bin/math_pb.rb +40 -0
- data/src/ruby/bin/math_server.rb +191 -0
- data/src/ruby/bin/math_services_pb.rb +51 -0
- data/src/ruby/bin/noproto_client.rb +93 -0
- data/src/ruby/bin/noproto_server.rb +97 -0
- data/src/ruby/ext/grpc/ext-export-truffleruby-with-ruby-abi-version.clang +2 -0
- data/src/ruby/ext/grpc/ext-export-truffleruby-with-ruby-abi-version.gcc +7 -0
- data/src/ruby/ext/grpc/ext-export-with-ruby-abi-version.clang +2 -0
- data/src/ruby/ext/grpc/ext-export-with-ruby-abi-version.gcc +7 -0
- data/src/ruby/ext/grpc/ext-export.clang +1 -0
- data/src/ruby/ext/grpc/ext-export.gcc +6 -0
- data/src/ruby/ext/grpc/extconf.rb +208 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.c +65 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.h +35 -0
- data/src/ruby/ext/grpc/rb_call.c +1075 -0
- data/src/ruby/ext/grpc/rb_call.h +57 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +340 -0
- data/src/ruby/ext/grpc/rb_call_credentials.h +31 -0
- data/src/ruby/ext/grpc/rb_channel.c +875 -0
- data/src/ruby/ext/grpc/rb_channel.h +35 -0
- data/src/ruby/ext/grpc/rb_channel_args.c +170 -0
- data/src/ruby/ext/grpc/rb_channel_args.h +42 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.c +285 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.h +37 -0
- data/src/ruby/ext/grpc/rb_completion_queue.c +101 -0
- data/src/ruby/ext/grpc/rb_completion_queue.h +36 -0
- data/src/ruby/ext/grpc/rb_compression_options.c +470 -0
- data/src/ruby/ext/grpc/rb_compression_options.h +29 -0
- data/src/ruby/ext/grpc/rb_enable_cpp.cc +22 -0
- data/src/ruby/ext/grpc/rb_event_thread.c +161 -0
- data/src/ruby/ext/grpc/rb_event_thread.h +22 -0
- data/src/ruby/ext/grpc/rb_grpc.c +496 -0
- data/src/ruby/ext/grpc/rb_grpc.h +83 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +599 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +904 -0
- data/src/ruby/ext/grpc/rb_loader.c +61 -0
- data/src/ruby/ext/grpc/rb_loader.h +25 -0
- data/src/ruby/ext/grpc/rb_server.c +405 -0
- data/src/ruby/ext/grpc/rb_server.h +32 -0
- data/src/ruby/ext/grpc/rb_server_credentials.c +258 -0
- data/src/ruby/ext/grpc/rb_server_credentials.h +37 -0
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +217 -0
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.h +37 -0
- data/src/ruby/ext/grpc/rb_xds_server_credentials.c +169 -0
- data/src/ruby/ext/grpc/rb_xds_server_credentials.h +37 -0
- data/src/ruby/lib/grpc/2.6/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.7/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/3.0/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/3.1/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/3.2/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/core/status_codes.rb +135 -0
- data/src/ruby/lib/grpc/core/time_consts.rb +56 -0
- data/src/ruby/lib/grpc/errors.rb +277 -0
- data/src/ruby/lib/grpc/generic/active_call.rb +670 -0
- data/src/ruby/lib/grpc/generic/bidi_call.rb +237 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +503 -0
- data/src/ruby/lib/grpc/generic/interceptor_registry.rb +53 -0
- data/src/ruby/lib/grpc/generic/interceptors.rb +186 -0
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +204 -0
- data/src/ruby/lib/grpc/generic/rpc_server.rb +551 -0
- data/src/ruby/lib/grpc/generic/service.rb +211 -0
- data/src/ruby/lib/grpc/google_rpc_status_utils.rb +40 -0
- data/src/ruby/lib/grpc/grpc.rb +24 -0
- data/src/ruby/lib/grpc/logconfig.rb +44 -0
- data/src/ruby/lib/grpc/notifier.rb +45 -0
- data/src/ruby/lib/grpc/structs.rb +15 -0
- data/src/ruby/lib/grpc/version.rb +18 -0
- data/src/ruby/lib/grpc.rb +37 -0
- data/src/ruby/pb/README.md +42 -0
- data/src/ruby/pb/generate_proto_ruby.sh +46 -0
- data/src/ruby/pb/grpc/health/checker.rb +75 -0
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +42 -0
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +62 -0
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +44 -0
- data/src/ruby/pb/grpc/testing/metrics_pb.rb +28 -0
- data/src/ruby/pb/grpc/testing/metrics_services_pb.rb +49 -0
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +38 -0
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +63 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +40 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +152 -0
- data/src/ruby/pb/test/client.rb +785 -0
- data/src/ruby/pb/test/server.rb +252 -0
- data/src/ruby/pb/test/xds_client.rb +415 -0
- data/src/ruby/spec/call_credentials_spec.rb +42 -0
- data/src/ruby/spec/call_spec.rb +180 -0
- data/src/ruby/spec/channel_connection_spec.rb +126 -0
- data/src/ruby/spec/channel_credentials_spec.rb +124 -0
- data/src/ruby/spec/channel_spec.rb +207 -0
- data/src/ruby/spec/client_auth_spec.rb +152 -0
- data/src/ruby/spec/client_server_spec.rb +676 -0
- data/src/ruby/spec/compression_options_spec.rb +149 -0
- data/src/ruby/spec/debug_message_spec.rb +134 -0
- data/src/ruby/spec/error_sanity_spec.rb +49 -0
- data/src/ruby/spec/errors_spec.rb +142 -0
- data/src/ruby/spec/generic/active_call_spec.rb +692 -0
- data/src/ruby/spec/generic/client_interceptors_spec.rb +153 -0
- data/src/ruby/spec/generic/client_stub_spec.rb +1083 -0
- data/src/ruby/spec/generic/interceptor_registry_spec.rb +65 -0
- data/src/ruby/spec/generic/rpc_desc_spec.rb +374 -0
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +127 -0
- data/src/ruby/spec/generic/rpc_server_spec.rb +748 -0
- data/src/ruby/spec/generic/server_interceptors_spec.rb +218 -0
- data/src/ruby/spec/generic/service_spec.rb +263 -0
- data/src/ruby/spec/google_rpc_status_utils_spec.rb +282 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options.proto +28 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto +22 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto +23 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto +41 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/same_package_service_name.proto +27 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/same_ruby_package_service_name.proto +29 -0
- data/src/ruby/spec/pb/codegen/package_option_spec.rb +98 -0
- data/src/ruby/spec/pb/duplicate/codegen_spec.rb +57 -0
- data/src/ruby/spec/pb/health/checker_spec.rb +236 -0
- data/src/ruby/spec/server_credentials_spec.rb +104 -0
- data/src/ruby/spec/server_spec.rb +231 -0
- data/src/ruby/spec/spec_helper.rb +61 -0
- data/src/ruby/spec/support/helpers.rb +107 -0
- data/src/ruby/spec/support/services.rb +160 -0
- data/src/ruby/spec/testdata/README +1 -0
- data/src/ruby/spec/testdata/ca.pem +20 -0
- data/src/ruby/spec/testdata/client.key +28 -0
- data/src/ruby/spec/testdata/client.pem +20 -0
- data/src/ruby/spec/testdata/server1.key +28 -0
- data/src/ruby/spec/testdata/server1.pem +22 -0
- data/src/ruby/spec/time_consts_spec.rb +74 -0
- data/src/ruby/spec/user_agent_spec.rb +74 -0
- metadata +406 -0
@@ -0,0 +1,107 @@
|
|
1
|
+
# Copyright 2017 gRPC authors.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# GRPC contains the General RPC module.
|
16
|
+
module GRPC
|
17
|
+
##
|
18
|
+
# GRPC RSpec base module
|
19
|
+
#
|
20
|
+
module Spec
|
21
|
+
##
|
22
|
+
# A module that is used for providing generic helpers across the
|
23
|
+
# GRPC test suite
|
24
|
+
#
|
25
|
+
module Helpers
|
26
|
+
# Shortcut syntax for a GRPC RPC Server
|
27
|
+
RpcServer = GRPC::RpcServer
|
28
|
+
|
29
|
+
##
|
30
|
+
# Build an RPC server used for testing
|
31
|
+
#
|
32
|
+
def build_rpc_server(server_opts: {},
|
33
|
+
client_opts: {})
|
34
|
+
@server = new_rpc_server_for_testing({ poll_period: 1 }.merge(server_opts))
|
35
|
+
@port = @server.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
|
36
|
+
@host = "0.0.0.0:#{@port}"
|
37
|
+
@client_opts = client_opts
|
38
|
+
@server
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Run services on an RPC server, yielding to allow testing within
|
43
|
+
#
|
44
|
+
# @param [RpcServer] server
|
45
|
+
# @param [Array<Class>] services
|
46
|
+
#
|
47
|
+
def run_services_on_server(server, services: [])
|
48
|
+
services.each do |s|
|
49
|
+
server.handle(s)
|
50
|
+
end
|
51
|
+
t = Thread.new { server.run }
|
52
|
+
server.wait_till_running
|
53
|
+
|
54
|
+
yield
|
55
|
+
|
56
|
+
server.stop
|
57
|
+
t.join
|
58
|
+
end
|
59
|
+
|
60
|
+
##
|
61
|
+
# Build an insecure stub from a given stub class
|
62
|
+
#
|
63
|
+
# @param [Class] klass
|
64
|
+
# @param [String] host
|
65
|
+
#
|
66
|
+
def build_insecure_stub(klass, host: nil, opts: nil)
|
67
|
+
host ||= @host
|
68
|
+
opts ||= @client_opts
|
69
|
+
klass.new(host, :this_channel_is_insecure, **opts)
|
70
|
+
end
|
71
|
+
|
72
|
+
##
|
73
|
+
# Build an RPCServer for use in tests. Adds args
|
74
|
+
# that are useful for all tests.
|
75
|
+
#
|
76
|
+
# @param [Hash] server_opts
|
77
|
+
#
|
78
|
+
def new_rpc_server_for_testing(server_opts = {})
|
79
|
+
server_opts[:server_args] ||= {}
|
80
|
+
update_server_args_hash(server_opts[:server_args])
|
81
|
+
RpcServer.new(**server_opts)
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# Build an GRPC::Core::Server for use in tests. Adds args
|
86
|
+
# that are useful for all tests.
|
87
|
+
#
|
88
|
+
# @param [Hash] server_args
|
89
|
+
#
|
90
|
+
def new_core_server_for_testing(server_args)
|
91
|
+
server_args.nil? && server_args = {}
|
92
|
+
update_server_args_hash(server_args)
|
93
|
+
GRPC::Core::Server.new(server_args)
|
94
|
+
end
|
95
|
+
|
96
|
+
def update_server_args_hash(server_args)
|
97
|
+
so_reuseport_arg = 'grpc.so_reuseport'
|
98
|
+
unless server_args[so_reuseport_arg].nil?
|
99
|
+
fail 'Unexpected. grpc.so_reuseport already set.'
|
100
|
+
end
|
101
|
+
# Run tests without so_reuseport to eliminate the chance of
|
102
|
+
# cross-talk.
|
103
|
+
server_args[so_reuseport_arg] = 0
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
# Copyright 2017 gRPC authors.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# Test stubs for various scenarios
|
16
|
+
require 'spec_helper'
|
17
|
+
|
18
|
+
# A test message
|
19
|
+
class EchoMsg
|
20
|
+
attr_reader :msg
|
21
|
+
|
22
|
+
def initialize(msg: '')
|
23
|
+
@msg = msg
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.marshal(o)
|
27
|
+
o.msg
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.unmarshal(msg)
|
31
|
+
EchoMsg.new(msg: msg)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# A test service with an echo implementation.
|
36
|
+
class EchoService
|
37
|
+
include GRPC::GenericService
|
38
|
+
rpc :an_rpc, EchoMsg, EchoMsg
|
39
|
+
rpc :a_client_streaming_rpc, stream(EchoMsg), EchoMsg
|
40
|
+
rpc :a_server_streaming_rpc, EchoMsg, stream(EchoMsg)
|
41
|
+
rpc :a_bidi_rpc, stream(EchoMsg), stream(EchoMsg)
|
42
|
+
rpc :a_client_streaming_rpc_unimplemented, stream(EchoMsg), EchoMsg
|
43
|
+
attr_reader :received_md
|
44
|
+
|
45
|
+
def initialize(**kw)
|
46
|
+
@trailing_metadata = kw
|
47
|
+
@received_md = []
|
48
|
+
end
|
49
|
+
|
50
|
+
def an_rpc(req, call)
|
51
|
+
GRPC.logger.info('echo service received a request')
|
52
|
+
call.output_metadata.update(@trailing_metadata)
|
53
|
+
@received_md << call.metadata unless call.metadata.nil?
|
54
|
+
req
|
55
|
+
end
|
56
|
+
|
57
|
+
def a_client_streaming_rpc(call)
|
58
|
+
# iterate through requests so call can complete
|
59
|
+
call.output_metadata.update(@trailing_metadata)
|
60
|
+
call.each_remote_read.each do |r|
|
61
|
+
GRPC.logger.info(r)
|
62
|
+
end
|
63
|
+
EchoMsg.new
|
64
|
+
end
|
65
|
+
|
66
|
+
def a_server_streaming_rpc(_req, call)
|
67
|
+
call.output_metadata.update(@trailing_metadata)
|
68
|
+
[EchoMsg.new, EchoMsg.new]
|
69
|
+
end
|
70
|
+
|
71
|
+
def a_bidi_rpc(requests, call)
|
72
|
+
call.output_metadata.update(@trailing_metadata)
|
73
|
+
requests.each do |r|
|
74
|
+
GRPC.logger.info(r)
|
75
|
+
end
|
76
|
+
[EchoMsg.new, EchoMsg.new]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
EchoStub = EchoService.rpc_stub_class
|
81
|
+
|
82
|
+
# For testing server interceptors
|
83
|
+
class TestServerInterceptor < GRPC::ServerInterceptor
|
84
|
+
def request_response(request:, call:, method:)
|
85
|
+
GRPC.logger.info("Received request/response call at method #{method}" \
|
86
|
+
" with request #{request} for call #{call}")
|
87
|
+
call.output_metadata[:interc] = 'from_request_response'
|
88
|
+
GRPC.logger.info("[GRPC::Ok] (#{method.owner.name}.#{method.name})")
|
89
|
+
yield
|
90
|
+
end
|
91
|
+
|
92
|
+
def client_streamer(call:, method:)
|
93
|
+
call.output_metadata[:interc] = 'from_client_streamer'
|
94
|
+
call.each_remote_read.each do |r|
|
95
|
+
GRPC.logger.info("In interceptor: #{r}")
|
96
|
+
end
|
97
|
+
GRPC.logger.info(
|
98
|
+
"Received client streamer call at method #{method} for call #{call}"
|
99
|
+
)
|
100
|
+
yield
|
101
|
+
end
|
102
|
+
|
103
|
+
def server_streamer(request:, call:, method:)
|
104
|
+
GRPC.logger.info("Received server streamer call at method #{method} with request" \
|
105
|
+
" #{request} for call #{call}")
|
106
|
+
call.output_metadata[:interc] = 'from_server_streamer'
|
107
|
+
yield
|
108
|
+
end
|
109
|
+
|
110
|
+
def bidi_streamer(requests:, call:, method:)
|
111
|
+
requests.each do |r|
|
112
|
+
GRPC.logger.info("Bidi request: #{r}")
|
113
|
+
end
|
114
|
+
GRPC.logger.info("Received bidi streamer call at method #{method} with requests" \
|
115
|
+
" #{requests} for call #{call}")
|
116
|
+
call.output_metadata[:interc] = 'from_bidi_streamer'
|
117
|
+
yield
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
# For testing client interceptors
|
122
|
+
class TestClientInterceptor < GRPC::ClientInterceptor
|
123
|
+
def request_response(request:, call:, method:, metadata: {})
|
124
|
+
GRPC.logger.info("Intercepted request/response call at method #{method}" \
|
125
|
+
" with request #{request} for call #{call}" \
|
126
|
+
" and metadata: #{metadata}")
|
127
|
+
metadata['foo'] = 'bar_from_request_response'
|
128
|
+
yield
|
129
|
+
end
|
130
|
+
|
131
|
+
def client_streamer(requests:, call:, method:, metadata: {})
|
132
|
+
GRPC.logger.info("Received client streamer call at method #{method}" \
|
133
|
+
" with requests #{requests} for call #{call}" \
|
134
|
+
" and metadata: #{metadata}")
|
135
|
+
requests.each do |r|
|
136
|
+
GRPC.logger.info("In client interceptor: #{r}")
|
137
|
+
end
|
138
|
+
metadata['foo'] = 'bar_from_client_streamer'
|
139
|
+
yield
|
140
|
+
end
|
141
|
+
|
142
|
+
def server_streamer(request:, call:, method:, metadata: {})
|
143
|
+
GRPC.logger.info("Received server streamer call at method #{method}" \
|
144
|
+
" with request #{request} for call #{call}" \
|
145
|
+
" and metadata: #{metadata}")
|
146
|
+
metadata['foo'] = 'bar_from_server_streamer'
|
147
|
+
yield
|
148
|
+
end
|
149
|
+
|
150
|
+
def bidi_streamer(requests:, call:, method:, metadata: {})
|
151
|
+
GRPC.logger.info("Received bidi streamer call at method #{method}" \
|
152
|
+
"with requests #{requests} for call #{call}" \
|
153
|
+
" and metadata: #{metadata}")
|
154
|
+
requests.each do |r|
|
155
|
+
GRPC.logger.info("In client interceptor: #{r}")
|
156
|
+
end
|
157
|
+
metadata['foo'] = 'bar_from_bidi_streamer'
|
158
|
+
yield
|
159
|
+
end
|
160
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
These are test keys *NOT* to be used in production.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDWjCCAkKgAwIBAgIUWrP0VvHcy+LP6UuYNtiL9gBhD5owDQYJKoZIhvcNAQEL
|
3
|
+
BQAwVjELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
|
4
|
+
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEPMA0GA1UEAwwGdGVzdGNhMB4XDTIw
|
5
|
+
MDMxNzE4NTk1MVoXDTMwMDMxNTE4NTk1MVowVjELMAkGA1UEBhMCQVUxEzARBgNV
|
6
|
+
BAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0
|
7
|
+
ZDEPMA0GA1UEAwwGdGVzdGNhMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
|
8
|
+
AQEAsGL0oXflF0LzoM+Bh+qUU9yhqzw2w8OOX5mu/iNCyUOBrqaHi7mGHx73GD01
|
9
|
+
diNzCzvlcQqdNIH6NQSL7DTpBjca66jYT9u73vZe2MDrr1nVbuLvfu9850cdxiUO
|
10
|
+
Inv5xf8+sTHG0C+a+VAvMhsLiRjsq+lXKRJyk5zkbbsETybqpxoJ+K7CoSy3yc/k
|
11
|
+
QIY3TipwEtwkKP4hzyo6KiGd/DPexie4nBUInN3bS1BUeNZ5zeaIC2eg3bkeeW7c
|
12
|
+
qT55b+Yen6CxY0TEkzBK6AKt/WUialKMgT0wbTxRZO7kUCH3Sq6e/wXeFdJ+HvdV
|
13
|
+
LPlAg5TnMaNpRdQih/8nRFpsdwI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x0IYhlZXNbIGWLBNhBhvVjJh7UvOqpADk4xtl8o5j0xgMIRg6WJGK6c
|
12
|
+
6ffSIg4eP1XmovNYZ9LLEJG68tF0Q/yIN43B4dt1oq4jzSdCbG4F1EiykT2TmwPV
|
13
|
+
YDi8tml6DfOCDGnit8svnMEmBv/fcPd31GSbXjF8M+KGGQIDAQABo2swaTAJBgNV
|
14
|
+
HRMEAjAAMAsGA1UdDwQEAwIF4DBPBgNVHREESDBGghAqLnRlc3QuZ29vZ2xlLmZy
|
15
|
+
ghh3YXRlcnpvb2kudGVzdC5nb29nbGUuYmWCEioudGVzdC55b3V0dWJlLmNvbYcE
|
16
|
+
wKgBAzANBgkqhkiG9w0BAQsFAAOCAQEAS8hDQA8PSgipgAml7Q3/djwQ644ghWQv
|
17
|
+
C2Kb+r30RCY1EyKNhnQnIIh/OUbBZvh0M0iYsy6xqXgfDhCB93AA6j0i5cS8fkhH
|
18
|
+
Jl4RK0tSkGQ3YNY4NzXwQP/vmUgfkw8VBAZ4Y4GKxppdATjffIW+srbAmdDruIRM
|
19
|
+
wPeikgOoRrXf0LA1fi4TqxARzeRwenQpayNfGHTvVF9aJkl8HoaMunTAdG5pIVcr
|
20
|
+
9GKi/gEMpXUJbbVv3U5frX1Wo4CFo+rZWJ/LyCMeb0jciNLxSdMwj/E/ZuExlyeZ
|
21
|
+
gc9ctPjSMvgSyXEKv6Vwobleeg88V2ZgzenziORoWj4KszG/lbQZvg==
|
22
|
+
-----END CERTIFICATE-----
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Copyright 2015 gRPC authors.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'spec_helper'
|
16
|
+
|
17
|
+
TimeConsts = GRPC::Core::TimeConsts
|
18
|
+
|
19
|
+
describe TimeConsts do
|
20
|
+
before(:each) do
|
21
|
+
@known_consts = [:ZERO, :INFINITE_FUTURE, :INFINITE_PAST].sort
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have all the known types' do
|
25
|
+
expect(TimeConsts.constants.collect.sort).to eq(@known_consts)
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#to_time' do
|
29
|
+
it 'converts each constant to a Time' do
|
30
|
+
m = TimeConsts
|
31
|
+
m.constants.each do |c|
|
32
|
+
expect(m.const_get(c).to_time).to be_a(Time)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#from_relative_time' do
|
39
|
+
it 'cannot handle arbitrary objects' do
|
40
|
+
expect { TimeConsts.from_relative_time(Object.new) }.to raise_error
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'preserves TimeConsts' do
|
44
|
+
m = TimeConsts
|
45
|
+
m.constants.each do |c|
|
46
|
+
const = m.const_get(c)
|
47
|
+
expect(TimeConsts.from_relative_time(const)).to be(const)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'converts 0 to TimeConsts::ZERO' do
|
52
|
+
expect(TimeConsts.from_relative_time(0)).to eq(TimeConsts::ZERO)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'converts nil to TimeConsts::ZERO' do
|
56
|
+
expect(TimeConsts.from_relative_time(nil)).to eq(TimeConsts::ZERO)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'converts negative values to TimeConsts::INFINITE_FUTURE' do
|
60
|
+
[-1, -3.2, -1e6].each do |t|
|
61
|
+
y = TimeConsts.from_relative_time(t)
|
62
|
+
expect(y).to eq(TimeConsts::INFINITE_FUTURE)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'converts a positive value to an absolute time' do
|
67
|
+
epsilon = 1
|
68
|
+
[1, 3.2, 1e6].each do |t|
|
69
|
+
want = Time.now + t
|
70
|
+
abs = TimeConsts.from_relative_time(t)
|
71
|
+
expect(abs.to_f).to be_within(epsilon).of(want.to_f)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Copyright 2020 gRPC authors.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'spec_helper'
|
16
|
+
|
17
|
+
# a test service that checks the cert of its peer
|
18
|
+
class UserAgentEchoService
|
19
|
+
include GRPC::GenericService
|
20
|
+
rpc :an_rpc, EchoMsg, EchoMsg
|
21
|
+
|
22
|
+
def an_rpc(_req, call)
|
23
|
+
EchoMsg.new(msg: call.metadata['user-agent'])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
UserAgentEchoServiceStub = UserAgentEchoService.rpc_stub_class
|
28
|
+
|
29
|
+
describe 'user agent' do
|
30
|
+
RpcServer = GRPC::RpcServer
|
31
|
+
|
32
|
+
before(:all) do
|
33
|
+
server_opts = {
|
34
|
+
poll_period: 1
|
35
|
+
}
|
36
|
+
@srv = new_rpc_server_for_testing(**server_opts)
|
37
|
+
@port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
|
38
|
+
@srv.handle(UserAgentEchoService)
|
39
|
+
@srv_thd = Thread.new { @srv.run }
|
40
|
+
@srv.wait_till_running
|
41
|
+
end
|
42
|
+
|
43
|
+
after(:all) do
|
44
|
+
expect(@srv.stopped?).to be(false)
|
45
|
+
@srv.stop
|
46
|
+
@srv_thd.join
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'client sends expected user agent' do
|
50
|
+
stub = UserAgentEchoServiceStub.new("localhost:#{@port}",
|
51
|
+
:this_channel_is_insecure,
|
52
|
+
channel_args: {})
|
53
|
+
response = stub.an_rpc(EchoMsg.new)
|
54
|
+
expected_user_agent_prefix = "grpc-ruby/#{GRPC::VERSION}"
|
55
|
+
expect(response.msg.start_with?(expected_user_agent_prefix)).to be true
|
56
|
+
# check that the expected user agent prefix occurs in the real user agent exactly once
|
57
|
+
expect(response.msg.split(expected_user_agent_prefix).size).to eq 2
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'user agent header does not grow when the same channel args hash is used across multiple stubs' do
|
61
|
+
shared_channel_args_hash = {}
|
62
|
+
10.times do
|
63
|
+
stub = UserAgentEchoServiceStub.new("localhost:#{@port}",
|
64
|
+
:this_channel_is_insecure,
|
65
|
+
channel_args: shared_channel_args_hash)
|
66
|
+
response = stub.an_rpc(EchoMsg.new)
|
67
|
+
puts "got echo response: #{response.msg}"
|
68
|
+
expected_user_agent_prefix = "grpc-ruby/#{GRPC::VERSION}"
|
69
|
+
expect(response.msg.start_with?(expected_user_agent_prefix)).to be true
|
70
|
+
# check that the expected user agent prefix occurs in the real user agent exactly once
|
71
|
+
expect(response.msg.split(expected_user_agent_prefix).size).to eq 2
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|