mockserver-client 7.6.0 → 8.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5058c222282161435bc425f0993f4795a0d4d8ca0f8fd1a921f5848ebe7b7fe8
4
- data.tar.gz: 91e14949df3f145e9c107374ee8edc6edea90343c91d509922495ea5eb220c37
3
+ metadata.gz: b32e53f8e5117c75dddf6e9b86e379892b47066fe7dbe3919da8d97232600fce
4
+ data.tar.gz: 64aa0e6608d0be522249a761e0009fce60058ebe2f6c67dbd9617bd3fffaa3fe
5
5
  SHA512:
6
- metadata.gz: b038601c5a23e3d510d85f3a7843d9f53cf87b849c1b0c76e9bab0a7dfca5a30daf81e036384c36afdae28e09504ec4ff8ff27ebf2d31bbd03f0c348a5f567ba
7
- data.tar.gz: 1b2958cd9f90ad4f8570f061d75fe20faf255eb427303056f8d7fdd4c6872c74dd504a05ed28a30694ecb0a4fc759411bdacf584c330e4f2b9bfd00b3b1d6398
6
+ metadata.gz: c87f1c996f7ec3f49502a5465c8990a076bef51262408570706cb520359f6446e9adbfafd0a9b6c1bace45b3164caaf3340fb1f4d848d877047c0f41d361a159
7
+ data.tar.gz: 741e8bd63ccb4d63edcfd7be2467d6b619fa5be8924f295d2f886da3af0017e201d8891adc8076c6af65c42dbbbf4202d259573e6c55f9a58f0a131993f4294d
data/README.md CHANGED
@@ -353,7 +353,7 @@ launcher_path = MockServer::BinaryLauncher.ensure_launcher
353
353
  ### Specify a version
354
354
 
355
355
  ```ruby
356
- handle = MockServer::BinaryLauncher.start(port: 1080, version: '7.6.0')
356
+ handle = MockServer::BinaryLauncher.start(port: 1080, version: '8.0.0')
357
357
  ```
358
358
 
359
359
  ### API reference
@@ -862,8 +862,8 @@ module MockServer
862
862
  # (PUT /mockserver/verifySLO).
863
863
  #
864
864
  # The server encodes the verdict in the HTTP status: 200 for PASS or
865
- # INCONCLUSIVE, 406 for FAIL, 400 for malformed criteria or when SLO tracking
866
- # is disabled (+sloTrackingEnabled=false+). The decoded verdict Hash carries
865
+ # INCONCLUSIVE, 406 for FAIL, 403 when SLO tracking is disabled
866
+ # (+sloTrackingEnabled=false+) and 400 for malformed criteria. The decoded verdict Hash carries
867
867
  # the overall +result+ and the per-objective +objectiveResults+ so callers can
868
868
  # inspect why an SLO failed.
869
869
  #
@@ -875,7 +875,7 @@ module MockServer
875
875
  # @param criteria [Hash, #to_h] the SLO criteria
876
876
  # @return [Hash] the SLO verdict (result PASS or INCONCLUSIVE)
877
877
  # @raise [VerificationError] if the verdict is FAIL (HTTP 406)
878
- # @raise [Error] if criteria are malformed or SLO tracking is disabled (HTTP 400),
878
+ # @raise [Error] if SLO tracking is disabled (HTTP 403) or criteria are malformed (HTTP 400),
879
879
  # or on any other failure
880
880
  def verify_slo(criteria)
881
881
  payload = criteria.respond_to?(:to_h) ? criteria.to_h : criteria
@@ -884,9 +884,12 @@ module MockServer
884
884
  if status == 406
885
885
  raise VerificationError, (response_body && !response_body.empty? ? response_body : 'SLO verdict: FAIL')
886
886
  end
887
+ if status == 403
888
+ raise Error, 'SLO tracking is disabled — set sloTrackingEnabled=true ' \
889
+ "on the server: #{response_body}"
890
+ end
887
891
  if status == 400
888
- raise Error, 'Invalid SLO criteria (or SLO tracking disabled — set ' \
889
- "sloTrackingEnabled=true on the server): #{response_body}"
892
+ raise Error, "Invalid SLO criteria: #{response_body}"
890
893
  end
891
894
  if status >= 400
892
895
  raise Error, "Failed to verify SLO (status=#{status}): #{response_body}"
@@ -1129,6 +1132,116 @@ module MockServer
1129
1132
  []
1130
1133
  end
1131
1134
 
1135
+ # Send a retrieve request filtered by expectation id.
1136
+ #
1137
+ # An expectation id may be sent in place of a request matcher. For
1138
+ # "ACTIVE_EXPECTATIONS" the server returns only the expectation with that id;
1139
+ # for every other type it returns the entries matching that expectation's
1140
+ # request, exactly as verify by expectation id matches them. An unknown id is
1141
+ # rejected with a 400.
1142
+ #
1143
+ # @param expectation_id [String]
1144
+ # @param query_params [Hash]
1145
+ # @return [Array(Integer, String)] the status and response body
1146
+ # @api private
1147
+ def retrieve_by_id(expectation_id, query_params)
1148
+ do_request(
1149
+ 'PUT', '/mockserver/retrieve', JSON.generate({ 'id' => expectation_id }), query_params
1150
+ )
1151
+ end
1152
+ private :retrieve_by_id
1153
+
1154
+ # Retrieve the recorded requests matching the request of the expectation with the given id.
1155
+ # @param expectation_id [String]
1156
+ # @return [Array<HttpRequest>]
1157
+ def retrieve_recorded_requests_by_id(expectation_id)
1158
+ status, response_body = retrieve_by_id(
1159
+ expectation_id, { 'type' => 'REQUESTS', 'format' => 'JSON' }
1160
+ )
1161
+ if status >= 400
1162
+ raise Error, "Failed to retrieve recorded requests by id (status=#{status}): #{response_body}"
1163
+ end
1164
+
1165
+ if response_body && !response_body.empty?
1166
+ parsed = JSON.parse(response_body)
1167
+ return parsed.map { |r| HttpRequest.from_hash(r) } if parsed.is_a?(Array)
1168
+ end
1169
+ []
1170
+ end
1171
+
1172
+ # Retrieve the active expectation with the given id.
1173
+ # @param expectation_id [String]
1174
+ # @return [Array<Expectation>]
1175
+ def retrieve_active_expectations_by_id(expectation_id)
1176
+ status, response_body = retrieve_by_id(
1177
+ expectation_id, { 'type' => 'ACTIVE_EXPECTATIONS', 'format' => 'JSON' }
1178
+ )
1179
+ if status >= 400
1180
+ raise Error, "Failed to retrieve active expectations by id (status=#{status}): #{response_body}"
1181
+ end
1182
+
1183
+ if response_body && !response_body.empty?
1184
+ parsed = JSON.parse(response_body)
1185
+ return parsed.map { |e| Expectation.from_hash(e) } if parsed.is_a?(Array)
1186
+ end
1187
+ []
1188
+ end
1189
+
1190
+ # Retrieve the recorded expectations matching the request of the expectation with the given id.
1191
+ # @param expectation_id [String]
1192
+ # @return [Array<Expectation>]
1193
+ def retrieve_recorded_expectations_by_id(expectation_id)
1194
+ status, response_body = retrieve_by_id(
1195
+ expectation_id, { 'type' => 'RECORDED_EXPECTATIONS', 'format' => 'JSON' }
1196
+ )
1197
+ if status >= 400
1198
+ raise Error, "Failed to retrieve recorded expectations by id (status=#{status}): #{response_body}"
1199
+ end
1200
+
1201
+ if response_body && !response_body.empty?
1202
+ parsed = JSON.parse(response_body)
1203
+ return parsed.map { |e| Expectation.from_hash(e) } if parsed.is_a?(Array)
1204
+ end
1205
+ []
1206
+ end
1207
+
1208
+ # Retrieve the recorded requests and responses matching the request of the expectation with the given id.
1209
+ # @param expectation_id [String]
1210
+ # @return [Array<HttpRequestAndHttpResponse>]
1211
+ def retrieve_recorded_requests_and_responses_by_id(expectation_id)
1212
+ status, response_body = retrieve_by_id(
1213
+ expectation_id, { 'type' => 'REQUEST_RESPONSES', 'format' => 'JSON' }
1214
+ )
1215
+ if status >= 400
1216
+ raise Error, "Failed to retrieve request/responses by id (status=#{status}): #{response_body}"
1217
+ end
1218
+
1219
+ if response_body && !response_body.empty?
1220
+ parsed = JSON.parse(response_body)
1221
+ return parsed.map { |rr| HttpRequestAndHttpResponse.from_hash(rr) } if parsed.is_a?(Array)
1222
+ end
1223
+ []
1224
+ end
1225
+
1226
+ # Retrieve the log messages matching the request of the expectation with the given id.
1227
+ # @param expectation_id [String]
1228
+ # @return [Array<String>]
1229
+ def retrieve_log_messages_by_id(expectation_id)
1230
+ status, response_body = retrieve_by_id(expectation_id, { 'type' => 'LOGS' })
1231
+ if status >= 400
1232
+ raise Error, "Failed to retrieve log messages by id (status=#{status}): #{response_body}"
1233
+ end
1234
+
1235
+ return [] unless response_body && !response_body.empty?
1236
+
1237
+ begin
1238
+ parsed = JSON.parse(response_body)
1239
+ parsed.is_a?(Array) ? parsed : []
1240
+ rescue JSON::ParserError
1241
+ response_body.split("------------------------------------\n")
1242
+ end
1243
+ end
1244
+
1132
1245
  # Retrieve the active expectations as MockServer SDK setup code (the builder
1133
1246
  # code that recreates the expectations) in the requested language.
1134
1247
  # @param format [String] one of "java", "javascript", "python", "go",
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MockServer
4
- VERSION = '7.6.0'
4
+ VERSION = '8.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mockserver-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.6.0
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Bloom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-17 00:00:00.000000000 Z
11
+ date: 2026-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger