mockserver-client 5.3.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +2 -5
  3. data/README.md +88 -96
  4. data/lib/mockserver/client.rb +518 -0
  5. data/lib/mockserver/errors.rb +18 -0
  6. data/lib/mockserver/forward_chain_expectation.rb +117 -0
  7. data/lib/mockserver/models.rb +1507 -0
  8. data/lib/mockserver/version.rb +5 -0
  9. data/lib/mockserver/websocket_client.rb +353 -0
  10. data/lib/mockserver-client.rb +8 -64
  11. data/mockserver-client.gemspec +35 -44
  12. metadata +37 -256
  13. data/Gemfile.lock +0 -79
  14. data/Rakefile +0 -10
  15. data/docs/Body.md +0 -7
  16. data/docs/BodyWithContentType.md +0 -7
  17. data/docs/ConnectionOptions.md +0 -12
  18. data/docs/ControlApi.md +0 -269
  19. data/docs/Delay.md +0 -9
  20. data/docs/Expectation.md +0 -7
  21. data/docs/ExpectationApi.md +0 -51
  22. data/docs/Expectations.md +0 -7
  23. data/docs/HttpClassCallback.md +0 -8
  24. data/docs/HttpError.md +0 -10
  25. data/docs/HttpForward.md +0 -11
  26. data/docs/HttpObjectCallback.md +0 -8
  27. data/docs/HttpOverrideForwardedRequest.md +0 -9
  28. data/docs/HttpRequest.md +0 -15
  29. data/docs/HttpResponse.md +0 -14
  30. data/docs/HttpTemplate.md +0 -10
  31. data/docs/KeyToMultiValue.md +0 -7
  32. data/docs/KeyToValue.md +0 -7
  33. data/docs/Ports.md +0 -8
  34. data/docs/TimeToLive.md +0 -10
  35. data/docs/Times.md +0 -9
  36. data/docs/Verification.md +0 -9
  37. data/docs/VerificationSequence.md +0 -8
  38. data/docs/VerificationTimes.md +0 -9
  39. data/docs/VerifyApi.md +0 -94
  40. data/lib/mockserver-client/api/control_api.rb +0 -316
  41. data/lib/mockserver-client/api/expectation_api.rb +0 -73
  42. data/lib/mockserver-client/api/verify_api.rb +0 -127
  43. data/lib/mockserver-client/api_client.rb +0 -388
  44. data/lib/mockserver-client/api_error.rb +0 -38
  45. data/lib/mockserver-client/configuration.rb +0 -202
  46. data/lib/mockserver-client/models/body.rb +0 -174
  47. data/lib/mockserver-client/models/body_with_content_type.rb +0 -174
  48. data/lib/mockserver-client/models/connection_options.rb +0 -219
  49. data/lib/mockserver-client/models/delay.rb +0 -192
  50. data/lib/mockserver-client/models/expectation.rb +0 -174
  51. data/lib/mockserver-client/models/expectations.rb +0 -174
  52. data/lib/mockserver-client/models/http_class_callback.rb +0 -183
  53. data/lib/mockserver-client/models/http_error.rb +0 -201
  54. data/lib/mockserver-client/models/http_forward.rb +0 -244
  55. data/lib/mockserver-client/models/http_object_callback.rb +0 -183
  56. data/lib/mockserver-client/models/http_override_forwarded_request.rb +0 -192
  57. data/lib/mockserver-client/models/http_request.rb +0 -246
  58. data/lib/mockserver-client/models/http_response.rb +0 -237
  59. data/lib/mockserver-client/models/http_template.rb +0 -235
  60. data/lib/mockserver-client/models/key_to_multi_value.rb +0 -174
  61. data/lib/mockserver-client/models/key_to_value.rb +0 -174
  62. data/lib/mockserver-client/models/ports.rb +0 -185
  63. data/lib/mockserver-client/models/time_to_live.rb +0 -235
  64. data/lib/mockserver-client/models/times.rb +0 -192
  65. data/lib/mockserver-client/models/verification.rb +0 -192
  66. data/lib/mockserver-client/models/verification_sequence.rb +0 -185
  67. data/lib/mockserver-client/models/verification_times.rb +0 -192
  68. data/lib/mockserver-client/version.rb +0 -15
  69. data/spec/api/control_api_spec.rb +0 -102
  70. data/spec/api/expectation_api_spec.rb +0 -46
  71. data/spec/api/verify_api_spec.rb +0 -57
  72. data/spec/api_client_spec.rb +0 -226
  73. data/spec/configuration_spec.rb +0 -42
  74. data/spec/models/body_spec.rb +0 -35
  75. data/spec/models/body_with_content_type_spec.rb +0 -35
  76. data/spec/models/connection_options_spec.rb +0 -65
  77. data/spec/models/delay_spec.rb +0 -47
  78. data/spec/models/expectation_spec.rb +0 -35
  79. data/spec/models/expectations_spec.rb +0 -35
  80. data/spec/models/http_class_callback_spec.rb +0 -41
  81. data/spec/models/http_error_spec.rb +0 -53
  82. data/spec/models/http_forward_spec.rb +0 -63
  83. data/spec/models/http_object_callback_spec.rb +0 -41
  84. data/spec/models/http_override_forwarded_request_spec.rb +0 -47
  85. data/spec/models/http_request_spec.rb +0 -83
  86. data/spec/models/http_response_spec.rb +0 -77
  87. data/spec/models/http_template_spec.rb +0 -57
  88. data/spec/models/key_to_multi_value_spec.rb +0 -35
  89. data/spec/models/key_to_value_spec.rb +0 -35
  90. data/spec/models/ports_spec.rb +0 -41
  91. data/spec/models/time_to_live_spec.rb +0 -57
  92. data/spec/models/times_spec.rb +0 -47
  93. data/spec/models/verification_sequence_spec.rb +0 -41
  94. data/spec/models/verification_spec.rb +0 -47
  95. data/spec/models/verification_times_spec.rb +0 -47
  96. data/spec/spec_helper.rb +0 -111
@@ -1,192 +0,0 @@
1
- =begin
2
- #Mock Server API
3
-
4
- #MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby and a simple REST API (as shown below). MockServer Proxy is a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding). Both MockServer and the MockServer Proxy record all received requests so that it is possible to verify exactly what requests have been sent by the system under test.
5
-
6
- OpenAPI spec version: 5.3.0
7
-
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 3.3.1
10
-
11
- =end
12
-
13
- require 'date'
14
-
15
- module MockServer
16
- class VerificationTimes
17
- attr_accessor :count
18
-
19
- attr_accessor :exact
20
-
21
- # Attribute mapping from ruby-style variable name to JSON key.
22
- def self.attribute_map
23
- {
24
- :'count' => :'count',
25
- :'exact' => :'exact'
26
- }
27
- end
28
-
29
- # Attribute type mapping.
30
- def self.openapi_types
31
- {
32
- :'count' => :'Integer',
33
- :'exact' => :'BOOLEAN'
34
- }
35
- end
36
-
37
- # Initializes the object
38
- # @param [Hash] attributes Model attributes in the form of hash
39
- def initialize(attributes = {})
40
- return unless attributes.is_a?(Hash)
41
-
42
- # convert string to symbol for hash key
43
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
44
-
45
- if attributes.has_key?(:'count')
46
- self.count = attributes[:'count']
47
- end
48
-
49
- if attributes.has_key?(:'exact')
50
- self.exact = attributes[:'exact']
51
- end
52
- end
53
-
54
- # Show invalid properties with the reasons. Usually used together with valid?
55
- # @return Array for valid properties with the reasons
56
- def list_invalid_properties
57
- invalid_properties = Array.new
58
- invalid_properties
59
- end
60
-
61
- # Check to see if the all the properties in the model are valid
62
- # @return true if the model is valid
63
- def valid?
64
- true
65
- end
66
-
67
- # Checks equality by comparing each attribute.
68
- # @param [Object] Object to be compared
69
- def ==(o)
70
- return true if self.equal?(o)
71
- self.class == o.class &&
72
- count == o.count &&
73
- exact == o.exact
74
- end
75
-
76
- # @see the `==` method
77
- # @param [Object] Object to be compared
78
- def eql?(o)
79
- self == o
80
- end
81
-
82
- # Calculates hash code according to all attributes.
83
- # @return [Fixnum] Hash code
84
- def hash
85
- [count, exact].hash
86
- end
87
-
88
- # Builds the object from hash
89
- # @param [Hash] attributes Model attributes in the form of hash
90
- # @return [Object] Returns the model itself
91
- def build_from_hash(attributes)
92
- return nil unless attributes.is_a?(Hash)
93
- self.class.openapi_types.each_pair do |key, type|
94
- if type =~ /\AArray<(.*)>/i
95
- # check to ensure the input is an array given that the the attribute
96
- # is documented as an array but the input is not
97
- if attributes[self.class.attribute_map[key]].is_a?(Array)
98
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
99
- end
100
- elsif !attributes[self.class.attribute_map[key]].nil?
101
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
102
- end # or else data not found in attributes(hash), not an issue as the data can be optional
103
- end
104
-
105
- self
106
- end
107
-
108
- # Deserializes the data based on type
109
- # @param string type Data type
110
- # @param string value Value to be deserialized
111
- # @return [Object] Deserialized data
112
- def _deserialize(type, value)
113
- case type.to_sym
114
- when :DateTime
115
- DateTime.parse(value)
116
- when :Date
117
- Date.parse(value)
118
- when :String
119
- value.to_s
120
- when :Integer
121
- value.to_i
122
- when :Float
123
- value.to_f
124
- when :BOOLEAN
125
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
126
- true
127
- else
128
- false
129
- end
130
- when :Object
131
- # generic object (usually a Hash), return directly
132
- value
133
- when /\AArray<(?<inner_type>.+)>\z/
134
- inner_type = Regexp.last_match[:inner_type]
135
- value.map { |v| _deserialize(inner_type, v) }
136
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
137
- k_type = Regexp.last_match[:k_type]
138
- v_type = Regexp.last_match[:v_type]
139
- {}.tap do |hash|
140
- value.each do |k, v|
141
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
142
- end
143
- end
144
- else # model
145
- temp_model = MockServer.const_get(type).new
146
- temp_model.build_from_hash(value)
147
- end
148
- end
149
-
150
- # Returns the string representation of the object
151
- # @return [String] String presentation of the object
152
- def to_s
153
- to_hash.to_s
154
- end
155
-
156
- # to_body is an alias to to_hash (backward compatibility)
157
- # @return [Hash] Returns the object in the form of hash
158
- def to_body
159
- to_hash
160
- end
161
-
162
- # Returns the object in the form of hash
163
- # @return [Hash] Returns the object in the form of hash
164
- def to_hash
165
- hash = {}
166
- self.class.attribute_map.each_pair do |attr, param|
167
- value = self.send(attr)
168
- next if value.nil?
169
- hash[param] = _to_hash(value)
170
- end
171
- hash
172
- end
173
-
174
- # Outputs non-array value in the form of hash
175
- # For object, use to_hash. Otherwise, just return the value
176
- # @param [Object] value Any valid value
177
- # @return [Hash] Returns the value in the form of hash
178
- def _to_hash(value)
179
- if value.is_a?(Array)
180
- value.compact.map { |v| _to_hash(v) }
181
- elsif value.is_a?(Hash)
182
- {}.tap do |hash|
183
- value.each { |k, v| hash[k] = _to_hash(v) }
184
- end
185
- elsif value.respond_to? :to_hash
186
- value.to_hash
187
- else
188
- value
189
- end
190
- end
191
- end
192
- end
@@ -1,15 +0,0 @@
1
- =begin
2
- #Mock Server API
3
-
4
- #MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby and a simple REST API (as shown below). MockServer Proxy is a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding). Both MockServer and the MockServer Proxy record all received requests so that it is possible to verify exactly what requests have been sent by the system under test.
5
-
6
- OpenAPI spec version: 5.3.0
7
-
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 3.3.1
10
-
11
- =end
12
-
13
- module MockServer
14
- VERSION = '5.3.0'
15
- end
@@ -1,102 +0,0 @@
1
- =begin
2
- #Mock Server API
3
-
4
- #MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby and a simple REST API (as shown below). MockServer Proxy is a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding). Both MockServer and the MockServer Proxy record all received requests so that it is possible to verify exactly what requests have been sent by the system under test.
5
-
6
- OpenAPI spec version: 5.3.0
7
-
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 3.3.1
10
-
11
- =end
12
-
13
- require 'spec_helper'
14
- require 'json'
15
-
16
- # Unit tests for MockServer::ControlApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'ControlApi' do
20
- before do
21
- # run before each test
22
- @instance = MockServer::ControlApi.new
23
- end
24
-
25
- after do
26
- # run after each test
27
- end
28
-
29
- describe 'test an instance of ControlApi' do
30
- it 'should create an instance of ControlApi' do
31
- expect(@instance).to be_instance_of(MockServer::ControlApi)
32
- end
33
- end
34
-
35
- # unit tests for bind_put
36
- # bind additional listening ports
37
- # only supported on Netty version
38
- # @param ports list of ports to bind to, where 0 indicates dynamically bind to any available port
39
- # @param [Hash] opts the optional parameters
40
- # @return [Ports]
41
- describe 'bind_put test' do
42
- it 'should work' do
43
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
- end
45
- end
46
-
47
- # unit tests for clear_put
48
- # clears expectations and recorded requests that match the request matcher
49
- # @param [Hash] opts the optional parameters
50
- # @option opts [HttpRequest] :http_request request used to match expectations and recored requests to clear
51
- # @return [nil]
52
- describe 'clear_put test' do
53
- it 'should work' do
54
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
55
- end
56
- end
57
-
58
- # unit tests for reset_put
59
- # clears all expectations and recorded requests
60
- # @param [Hash] opts the optional parameters
61
- # @return [nil]
62
- describe 'reset_put test' do
63
- it 'should work' do
64
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
65
- end
66
- end
67
-
68
- # unit tests for retrieve_put
69
- # retrieve recorded requests, active expectations, recorded expectations or log messages
70
- # @param [Hash] opts the optional parameters
71
- # @option opts [String] :format changes response format, default if not specificed is \&quot;json\&quot;, supported values are \&quot;java\&quot;, \&quot;json\&quot;
72
- # @option opts [String] :type specifies the type of object that is retrieve, default if not specified is \&quot;requests\&quot;, supported values are \&quot;logs\&quot;, \&quot;requests\&quot;, \&quot;recorded_expectations\&quot;, \&quot;active_expectations\&quot;
73
- # @option opts [HttpRequest] :http_request request used to match which recorded requests, expectations or log messages to return, an empty body matches all requests, expectations or log messages
74
- # @return [Object]
75
- describe 'retrieve_put test' do
76
- it 'should work' do
77
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
78
- end
79
- end
80
-
81
- # unit tests for status_put
82
- # return listening ports
83
- # @param [Hash] opts the optional parameters
84
- # @return [Ports]
85
- describe 'status_put test' do
86
- it 'should work' do
87
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
88
- end
89
- end
90
-
91
- # unit tests for stop_put
92
- # stop running process
93
- # only supported on Netty version
94
- # @param [Hash] opts the optional parameters
95
- # @return [nil]
96
- describe 'stop_put test' do
97
- it 'should work' do
98
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
99
- end
100
- end
101
-
102
- end
@@ -1,46 +0,0 @@
1
- =begin
2
- #Mock Server API
3
-
4
- #MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby and a simple REST API (as shown below). MockServer Proxy is a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding). Both MockServer and the MockServer Proxy record all received requests so that it is possible to verify exactly what requests have been sent by the system under test.
5
-
6
- OpenAPI spec version: 5.3.0
7
-
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 3.3.1
10
-
11
- =end
12
-
13
- require 'spec_helper'
14
- require 'json'
15
-
16
- # Unit tests for MockServer::ExpectationApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'ExpectationApi' do
20
- before do
21
- # run before each test
22
- @instance = MockServer::ExpectationApi.new
23
- end
24
-
25
- after do
26
- # run after each test
27
- end
28
-
29
- describe 'test an instance of ExpectationApi' do
30
- it 'should create an instance of ExpectationApi' do
31
- expect(@instance).to be_instance_of(MockServer::ExpectationApi)
32
- end
33
- end
34
-
35
- # unit tests for expectation_put
36
- # create expectation
37
- # @param expectations expectation to create
38
- # @param [Hash] opts the optional parameters
39
- # @return [nil]
40
- describe 'expectation_put test' do
41
- it 'should work' do
42
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
43
- end
44
- end
45
-
46
- end
@@ -1,57 +0,0 @@
1
- =begin
2
- #Mock Server API
3
-
4
- #MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby and a simple REST API (as shown below). MockServer Proxy is a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding). Both MockServer and the MockServer Proxy record all received requests so that it is possible to verify exactly what requests have been sent by the system under test.
5
-
6
- OpenAPI spec version: 5.3.0
7
-
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 3.3.1
10
-
11
- =end
12
-
13
- require 'spec_helper'
14
- require 'json'
15
-
16
- # Unit tests for MockServer::VerifyApi
17
- # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
- # Please update as you see appropriate
19
- describe 'VerifyApi' do
20
- before do
21
- # run before each test
22
- @instance = MockServer::VerifyApi.new
23
- end
24
-
25
- after do
26
- # run after each test
27
- end
28
-
29
- describe 'test an instance of VerifyApi' do
30
- it 'should create an instance of VerifyApi' do
31
- expect(@instance).to be_instance_of(MockServer::VerifyApi)
32
- end
33
- end
34
-
35
- # unit tests for verify_put
36
- # verify a request has been received a specific number of times
37
- # @param verification request matcher and the number of times to match
38
- # @param [Hash] opts the optional parameters
39
- # @return [nil]
40
- describe 'verify_put test' do
41
- it 'should work' do
42
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
43
- end
44
- end
45
-
46
- # unit tests for verify_sequence_put
47
- # verify a sequence of request has been received in the specific order
48
- # @param verification_sequence the sequence of requests matchers
49
- # @param [Hash] opts the optional parameters
50
- # @return [nil]
51
- describe 'verify_sequence_put test' do
52
- it 'should work' do
53
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
54
- end
55
- end
56
-
57
- end
@@ -1,226 +0,0 @@
1
- =begin
2
- #Mock Server API
3
-
4
- #MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby and a simple REST API (as shown below). MockServer Proxy is a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding). Both MockServer and the MockServer Proxy record all received requests so that it is possible to verify exactly what requests have been sent by the system under test.
5
-
6
- OpenAPI spec version: 5.3.0
7
-
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 3.3.1
10
-
11
- =end
12
-
13
- require 'spec_helper'
14
-
15
- describe MockServer::ApiClient do
16
- context 'initialization' do
17
- context 'URL stuff' do
18
- context 'host' do
19
- it 'removes http from host' do
20
- MockServer.configure { |c| c.host = 'http://example.com' }
21
- expect(MockServer::Configuration.default.host).to eq('example.com')
22
- end
23
-
24
- it 'removes https from host' do
25
- MockServer.configure { |c| c.host = 'https://wookiee.com' }
26
- expect(MockServer::ApiClient.default.config.host).to eq('wookiee.com')
27
- end
28
-
29
- it 'removes trailing path from host' do
30
- MockServer.configure { |c| c.host = 'hobo.com/v4' }
31
- expect(MockServer::Configuration.default.host).to eq('hobo.com')
32
- end
33
- end
34
-
35
- context 'base_path' do
36
- it "prepends a slash to base_path" do
37
- MockServer.configure { |c| c.base_path = 'v4/dog' }
38
- expect(MockServer::Configuration.default.base_path).to eq('/v4/dog')
39
- end
40
-
41
- it "doesn't prepend a slash if one is already there" do
42
- MockServer.configure { |c| c.base_path = '/v4/dog' }
43
- expect(MockServer::Configuration.default.base_path).to eq('/v4/dog')
44
- end
45
-
46
- it "ends up as a blank string if nil" do
47
- MockServer.configure { |c| c.base_path = nil }
48
- expect(MockServer::Configuration.default.base_path).to eq('')
49
- end
50
- end
51
- end
52
- end
53
-
54
- describe 'params_encoding in #build_request' do
55
- let(:config) { MockServer::Configuration.new }
56
- let(:api_client) { MockServer::ApiClient.new(config) }
57
-
58
- it 'defaults to nil' do
59
- expect(MockServer::Configuration.default.params_encoding).to eq(nil)
60
- expect(config.params_encoding).to eq(nil)
61
-
62
- request = api_client.build_request(:get, '/test')
63
- expect(request.options[:params_encoding]).to eq(nil)
64
- end
65
-
66
- it 'can be customized' do
67
- config.params_encoding = :multi
68
- request = api_client.build_request(:get, '/test')
69
- expect(request.options[:params_encoding]).to eq(:multi)
70
- end
71
- end
72
-
73
- describe 'timeout in #build_request' do
74
- let(:config) { MockServer::Configuration.new }
75
- let(:api_client) { MockServer::ApiClient.new(config) }
76
-
77
- it 'defaults to 0' do
78
- expect(MockServer::Configuration.default.timeout).to eq(0)
79
- expect(config.timeout).to eq(0)
80
-
81
- request = api_client.build_request(:get, '/test')
82
- expect(request.options[:timeout]).to eq(0)
83
- end
84
-
85
- it 'can be customized' do
86
- config.timeout = 100
87
- request = api_client.build_request(:get, '/test')
88
- expect(request.options[:timeout]).to eq(100)
89
- end
90
- end
91
-
92
- describe '#deserialize' do
93
- it "handles Array<Integer>" do
94
- api_client = MockServer::ApiClient.new
95
- headers = { 'Content-Type' => 'application/json' }
96
- response = double('response', headers: headers, body: '[12, 34]')
97
- data = api_client.deserialize(response, 'Array<Integer>')
98
- expect(data).to be_instance_of(Array)
99
- expect(data).to eq([12, 34])
100
- end
101
-
102
- it 'handles Array<Array<Integer>>' do
103
- api_client = MockServer::ApiClient.new
104
- headers = { 'Content-Type' => 'application/json' }
105
- response = double('response', headers: headers, body: '[[12, 34], [56]]')
106
- data = api_client.deserialize(response, 'Array<Array<Integer>>')
107
- expect(data).to be_instance_of(Array)
108
- expect(data).to eq([[12, 34], [56]])
109
- end
110
-
111
- it 'handles Hash<String, String>' do
112
- api_client = MockServer::ApiClient.new
113
- headers = { 'Content-Type' => 'application/json' }
114
- response = double('response', headers: headers, body: '{"message": "Hello"}')
115
- data = api_client.deserialize(response, 'Hash<String, String>')
116
- expect(data).to be_instance_of(Hash)
117
- expect(data).to eq(:message => 'Hello')
118
- end
119
- end
120
-
121
- describe "#object_to_hash" do
122
- it 'ignores nils and includes empty arrays' do
123
- # uncomment below to test object_to_hash for model
124
- # api_client = MockServer::ApiClient.new
125
- # _model = MockServer::ModelName.new
126
- # update the model attribute below
127
- # _model.id = 1
128
- # update the expected value (hash) below
129
- # expected = {id: 1, name: '', tags: []}
130
- # expect(api_client.object_to_hash(_model)).to eq(expected)
131
- end
132
- end
133
-
134
- describe '#build_collection_param' do
135
- let(:param) { ['aa', 'bb', 'cc'] }
136
- let(:api_client) { MockServer::ApiClient.new }
137
-
138
- it 'works for csv' do
139
- expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
140
- end
141
-
142
- it 'works for ssv' do
143
- expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
144
- end
145
-
146
- it 'works for tsv' do
147
- expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
148
- end
149
-
150
- it 'works for pipes' do
151
- expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
152
- end
153
-
154
- it 'works for multi' do
155
- expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
156
- end
157
-
158
- it 'fails for invalid collection format' do
159
- expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
160
- end
161
- end
162
-
163
- describe '#json_mime?' do
164
- let(:api_client) { MockServer::ApiClient.new }
165
-
166
- it 'works' do
167
- expect(api_client.json_mime?(nil)).to eq false
168
- expect(api_client.json_mime?('')).to eq false
169
-
170
- expect(api_client.json_mime?('application/json')).to eq true
171
- expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
172
- expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
173
-
174
- expect(api_client.json_mime?('application/xml')).to eq false
175
- expect(api_client.json_mime?('text/plain')).to eq false
176
- expect(api_client.json_mime?('application/jsonp')).to eq false
177
- end
178
- end
179
-
180
- describe '#select_header_accept' do
181
- let(:api_client) { MockServer::ApiClient.new }
182
-
183
- it 'works' do
184
- expect(api_client.select_header_accept(nil)).to be_nil
185
- expect(api_client.select_header_accept([])).to be_nil
186
-
187
- expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
188
- expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
189
- expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
190
-
191
- expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
192
- expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
193
- end
194
- end
195
-
196
- describe '#select_header_content_type' do
197
- let(:api_client) { MockServer::ApiClient.new }
198
-
199
- it 'works' do
200
- expect(api_client.select_header_content_type(nil)).to eq('application/json')
201
- expect(api_client.select_header_content_type([])).to eq('application/json')
202
-
203
- expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
204
- expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
205
- expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
206
- expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
207
- expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
208
- end
209
- end
210
-
211
- describe '#sanitize_filename' do
212
- let(:api_client) { MockServer::ApiClient.new }
213
-
214
- it 'works' do
215
- expect(api_client.sanitize_filename('sun')).to eq('sun')
216
- expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
217
- expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
218
- expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
219
- expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
220
- expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
221
- expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
222
- expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
223
- expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
224
- end
225
- end
226
- end
@@ -1,42 +0,0 @@
1
- =begin
2
- #Mock Server API
3
-
4
- #MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby and a simple REST API (as shown below). MockServer Proxy is a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding). Both MockServer and the MockServer Proxy record all received requests so that it is possible to verify exactly what requests have been sent by the system under test.
5
-
6
- OpenAPI spec version: 5.3.0
7
-
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 3.3.1
10
-
11
- =end
12
-
13
- require 'spec_helper'
14
-
15
- describe MockServer::Configuration do
16
- let(:config) { MockServer::Configuration.default }
17
-
18
- before(:each) do
19
- # uncomment below to setup host and base_path
20
- # require 'URI'
21
- # uri = URI.parse("http://localhost:1080")
22
- # MockServer.configure do |c|
23
- # c.host = uri.host
24
- # c.base_path = uri.path
25
- # end
26
- end
27
-
28
- describe '#base_url' do
29
- it 'should have the default value' do
30
- # uncomment below to test default value of the base path
31
- # expect(config.base_url).to eq("http://localhost:1080")
32
- end
33
-
34
- it 'should remove trailing slashes' do
35
- [nil, '', '/', '//'].each do |base_path|
36
- config.base_path = base_path
37
- # uncomment below to test trailing slashes
38
- # expect(config.base_url).to eq("http://localhost:1080")
39
- end
40
- end
41
- end
42
- end