mockserver-client 7.0.0 → 7.1.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 +4 -4
- data/README.md +104 -0
- data/lib/mockserver/binary_launcher.rb +634 -0
- data/lib/mockserver/client.rb +151 -6
- data/lib/mockserver/models.rb +62 -27
- data/lib/mockserver/version.rb +1 -1
- data/lib/mockserver/websocket_client.rb +129 -2
- data/lib/mockserver-client.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b853b4ba04e3473e6e664a0f1a2f6b4f0a8146f624a2308a19349fe94f536d9e
|
|
4
|
+
data.tar.gz: 848eedd40df3e43ac6299250c92d4f30ee1b7fbeedb15699cd7254af20fcb6a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a2c283e6f9ed9fb935ff296a84298abc7c73768609c0601b8079e20441ebd25ca1029256a7c21a968578ef3f9ea28777b7d07dd20c7d8b4387031298389c4eb8
|
|
7
|
+
data.tar.gz: 77bc8cf3f5e4e919ba758c4c720cbf9795600094d7bfc41faa66b5571c0ea2b7ee39fa3a4f6871726ffc3a6468f84defb34afce05b33203b734e1cc1ac1c3c53
|
data/README.md
CHANGED
|
@@ -99,6 +99,110 @@ All 25 domain model classes are available under the `MockServer` module:
|
|
|
99
99
|
- `Ports`
|
|
100
100
|
- `RequestDefinition` (alias for `HttpRequest`)
|
|
101
101
|
|
|
102
|
+
## Interactive Breakpoints
|
|
103
|
+
|
|
104
|
+
The client supports matcher-driven interactive breakpoints over the callback WebSocket. Register a breakpoint matcher to pause forwarded/proxied exchanges at specific phases and inspect/modify/continue them via callback handlers.
|
|
105
|
+
|
|
106
|
+
### Register a breakpoint
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
client = MockServer::Client.new('localhost', 1080)
|
|
110
|
+
|
|
111
|
+
# REQUEST phase only
|
|
112
|
+
bp_id = client.add_request_breakpoint(
|
|
113
|
+
MockServer::HttpRequest.new(path: '/api/.*'),
|
|
114
|
+
->(request) { request } # continue unchanged (or return HttpResponse to abort)
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
# REQUEST + RESPONSE
|
|
118
|
+
bp_id = client.add_request_and_response_breakpoint(
|
|
119
|
+
MockServer::HttpRequest.new(path: '/api/.*'),
|
|
120
|
+
->(request) { request }, # REQUEST handler
|
|
121
|
+
->(request, response) { response } # RESPONSE handler
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
# All phases with stream frame handler
|
|
125
|
+
bp_id = client.add_breakpoint(
|
|
126
|
+
MockServer::HttpRequest.new(path: '/stream/.*'),
|
|
127
|
+
%w[REQUEST RESPONSE RESPONSE_STREAM INBOUND_STREAM],
|
|
128
|
+
request_handler: ->(request) { request },
|
|
129
|
+
response_handler: ->(request, response) { response },
|
|
130
|
+
stream_frame_handler: ->(frame) { { 'action' => 'CONTINUE' } }
|
|
131
|
+
# Other actions: MODIFY (with body), DROP, INJECT (with body), CLOSE
|
|
132
|
+
)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Manage breakpoints
|
|
136
|
+
|
|
137
|
+
```ruby
|
|
138
|
+
# List all matchers
|
|
139
|
+
matchers = client.list_breakpoint_matchers # {"matchers" => [...]}
|
|
140
|
+
|
|
141
|
+
# Remove a specific matcher
|
|
142
|
+
client.remove_breakpoint_matcher(bp_id)
|
|
143
|
+
|
|
144
|
+
# Clear all matchers
|
|
145
|
+
client.clear_breakpoint_matchers
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Start / Launch MockServer
|
|
149
|
+
|
|
150
|
+
The Ruby client can download and launch a local MockServer instance directly -- no Java installation and no Docker required. The launcher downloads a self-contained platform bundle (`mockserver-<version>-<os>-<arch>`) from the GitHub Release, verifies its SHA-256, caches it per-user, and starts it.
|
|
151
|
+
|
|
152
|
+
### Quick start
|
|
153
|
+
|
|
154
|
+
```ruby
|
|
155
|
+
require 'mockserver-client'
|
|
156
|
+
|
|
157
|
+
# Download (first run) and start MockServer on port 1080
|
|
158
|
+
handle = MockServer::BinaryLauncher.start(port: 1080)
|
|
159
|
+
puts "MockServer running on port #{handle.port}, PID #{handle.pid}"
|
|
160
|
+
|
|
161
|
+
# ... use MockServer ...
|
|
162
|
+
|
|
163
|
+
handle.stop
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Just ensure the binary is present
|
|
167
|
+
|
|
168
|
+
```ruby
|
|
169
|
+
launcher_path = MockServer::BinaryLauncher.ensure_launcher
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Specify a version
|
|
173
|
+
|
|
174
|
+
```ruby
|
|
175
|
+
handle = MockServer::BinaryLauncher.start(port: 1080, version: '7.1.0')
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### API reference
|
|
179
|
+
|
|
180
|
+
| Method / Class | Description |
|
|
181
|
+
|---|---|
|
|
182
|
+
| `MockServer::BinaryLauncher.ensure_launcher(version:, log:)` | Download, verify, cache, and return the launcher path. Defaults to `MockServer::VERSION`. |
|
|
183
|
+
| `MockServer::BinaryLauncher.start(port:, version:, extra_args:, log:)` | Ensure the binary and start MockServer. Returns a `ServerHandle`. |
|
|
184
|
+
| `MockServer::BinaryLauncher::ServerHandle` | Handle to the running process. Methods: `stop(timeout:)`, `running?`. Attributes: `pid`, `port`, `launcher`. |
|
|
185
|
+
|
|
186
|
+
### Supported platforms
|
|
187
|
+
|
|
188
|
+
| OS | Architecture |
|
|
189
|
+
|---|---|
|
|
190
|
+
| Linux | x86_64, aarch64 |
|
|
191
|
+
| macOS (darwin) | x86_64, aarch64 |
|
|
192
|
+
| Windows | x86_64, aarch64 |
|
|
193
|
+
|
|
194
|
+
### Environment variables
|
|
195
|
+
|
|
196
|
+
| Variable | Purpose |
|
|
197
|
+
|---|---|
|
|
198
|
+
| `MOCKSERVER_BINARY_BASE_URL` | Mirror host for the release assets (corporate / air-gapped networks) |
|
|
199
|
+
| `MOCKSERVER_BINARY_CACHE` | Override the cache directory (default: `~/.cache/mockserver/binaries` on Unix) |
|
|
200
|
+
| `MOCKSERVER_SKIP_BINARY_DOWNLOAD` | Fail instead of downloading (use with a pre-seeded cache in CI) |
|
|
201
|
+
|
|
202
|
+
### Version
|
|
203
|
+
|
|
204
|
+
By default the launcher downloads the MockServer version matching this client gem (currently `MockServer::VERSION` from `lib/mockserver/version.rb`). Pass an explicit `version:` keyword to override.
|
|
205
|
+
|
|
102
206
|
## License
|
|
103
207
|
|
|
104
208
|
Apache-2.0
|