@pact-foundation/pact-core 13.7.6 → 13.7.9
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.
- package/CHANGELOG.md +22 -0
- package/build/Makefile +1 -1
- package/ffi/libpact_ffi.dylib +0 -0
- package/ffi/libpact_ffi.so +0 -0
- package/ffi/libpact_ffi.so.gz +0 -0
- package/ffi/osxaarch64/libpact_ffi.dylib +0 -0
- package/ffi/pact-cpp.h +715 -35
- package/ffi/pact.h +718 -35
- package/ffi/pact_ffi.dll +0 -0
- package/ffi/pact_ffi.dll.lib +0 -0
- package/package.json +1 -1
- package/src/ffi/index.d.ts +1 -1
- package/src/ffi/index.js +1 -1
- package/src/ffi/types.d.ts +2 -2
- package/src/verifier/argumentMapper/arguments.d.ts +4 -0
- package/src/verifier/argumentMapper/arguments.js +43 -27
- package/src/verifier/argumentMapper/arguments.js.map +1 -1
- package/src/verifier/argumentMapper/index.js +9 -5
- package/src/verifier/argumentMapper/index.js.map +1 -1
package/ffi/pact-cpp.h
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
#ifndef pact_ffi_h
|
|
8
8
|
#define pact_ffi_h
|
|
9
9
|
|
|
10
|
-
/* Generated with cbindgen:0.
|
|
10
|
+
/* Generated with cbindgen:0.24.3 */
|
|
11
11
|
|
|
12
12
|
/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */
|
|
13
13
|
|
|
@@ -134,6 +134,11 @@ struct MismatchesIterator;
|
|
|
134
134
|
*/
|
|
135
135
|
struct PactMessageIterator;
|
|
136
136
|
|
|
137
|
+
/**
|
|
138
|
+
* An iterator over synchronous HTTP request/response interactions in a pact.
|
|
139
|
+
*/
|
|
140
|
+
struct PactSyncHttpIterator;
|
|
141
|
+
|
|
137
142
|
/**
|
|
138
143
|
* An iterator over synchronous request/response messages in a pact.
|
|
139
144
|
*/
|
|
@@ -162,6 +167,11 @@ struct ProviderStateIterator;
|
|
|
162
167
|
*/
|
|
163
168
|
struct ProviderStateParamIterator;
|
|
164
169
|
|
|
170
|
+
/**
|
|
171
|
+
* V4 HTTP Interaction Type
|
|
172
|
+
*/
|
|
173
|
+
struct SynchronousHttp;
|
|
174
|
+
|
|
165
175
|
/**
|
|
166
176
|
* Synchronous interactions as a request message to a sequence of response messages
|
|
167
177
|
*/
|
|
@@ -271,13 +281,14 @@ using MessageHandle = uint32_t;
|
|
|
271
281
|
extern "C" {
|
|
272
282
|
|
|
273
283
|
/**
|
|
274
|
-
*
|
|
284
|
+
* Returns the current library version
|
|
275
285
|
*/
|
|
276
286
|
const char *pactffi_version();
|
|
277
287
|
|
|
278
288
|
/**
|
|
279
289
|
* Initialise the mock server library, can provide an environment variable name to use to
|
|
280
|
-
* set the log levels.
|
|
290
|
+
* set the log levels. This function should only be called once, as it tries to install a global
|
|
291
|
+
* tracing subscriber.
|
|
281
292
|
*
|
|
282
293
|
* # Safety
|
|
283
294
|
*
|
|
@@ -286,7 +297,8 @@ const char *pactffi_version();
|
|
|
286
297
|
void pactffi_init(const char *log_env_var);
|
|
287
298
|
|
|
288
299
|
/**
|
|
289
|
-
* Initialises logging, and sets the log level explicitly.
|
|
300
|
+
* Initialises logging, and sets the log level explicitly. This function should only be called
|
|
301
|
+
* once, as it tries to install a global tracing subscriber.
|
|
290
302
|
*
|
|
291
303
|
* # Safety
|
|
292
304
|
*
|
|
@@ -436,7 +448,7 @@ int pactffi_log_to_file(const char *file_name, LevelFilter level_filter);
|
|
|
436
448
|
int pactffi_log_to_buffer(LevelFilter level_filter);
|
|
437
449
|
|
|
438
450
|
/**
|
|
439
|
-
* Initialize the
|
|
451
|
+
* Initialize the FFI logger with no sinks.
|
|
440
452
|
*
|
|
441
453
|
* This initialized logger does nothing until `pactffi_logger_apply` has been called.
|
|
442
454
|
*
|
|
@@ -457,7 +469,7 @@ void pactffi_logger_init();
|
|
|
457
469
|
*
|
|
458
470
|
* This logger does nothing until `pactffi_logger_apply` has been called.
|
|
459
471
|
*
|
|
460
|
-
*
|
|
472
|
+
* Types of sinks can be specified:
|
|
461
473
|
*
|
|
462
474
|
* - stdout (`pactffi_logger_attach_sink("stdout", LevelFilter_Info)`)
|
|
463
475
|
* - stderr (`pactffi_logger_attach_sink("stderr", LevelFilter_Debug)`)
|
|
@@ -484,22 +496,25 @@ void pactffi_logger_init();
|
|
|
484
496
|
* # Safety
|
|
485
497
|
*
|
|
486
498
|
* This function checks the validity of the passed-in sink specifier, and errors
|
|
487
|
-
* out if the specifier isn't valid UTF-8.
|
|
499
|
+
* out if the specifier isn't valid UTF-8. Passing in an invalid or NULL pointer will result in
|
|
500
|
+
* undefined behaviour.
|
|
488
501
|
*/
|
|
489
502
|
int pactffi_logger_attach_sink(const char *sink_specifier,
|
|
490
503
|
LevelFilter level_filter);
|
|
491
504
|
|
|
492
505
|
/**
|
|
493
|
-
* Apply the
|
|
506
|
+
* Apply the previously configured sinks and levels to the program. If no sinks have been setup,
|
|
507
|
+
* will set the log level to info and the target to standard out.
|
|
494
508
|
*
|
|
495
|
-
*
|
|
509
|
+
* This function will install a global tracing subscriber. Any attempts to modify the logger
|
|
510
|
+
* after the call to `logger_apply` will fail.
|
|
496
511
|
*/
|
|
497
512
|
int pactffi_logger_apply();
|
|
498
513
|
|
|
499
514
|
/**
|
|
500
515
|
* Fetch the in-memory logger buffer contents. This will only have any contents if the `buffer`
|
|
501
516
|
* sink has been configured to log to. The contents will be allocated on the heap and will need
|
|
502
|
-
* to be freed with `
|
|
517
|
+
* to be freed with `pactffi_string_delete`.
|
|
503
518
|
*
|
|
504
519
|
* Fetches the logs associated with the provided identifier, or uses the "global" one if the
|
|
505
520
|
* identifier is not specified (i.e. NULL).
|
|
@@ -616,6 +631,21 @@ void pactffi_message_delete(Message *message);
|
|
|
616
631
|
*/
|
|
617
632
|
const char *pactffi_message_get_contents(const Message *message);
|
|
618
633
|
|
|
634
|
+
/**
|
|
635
|
+
* Sets the contents of the message.
|
|
636
|
+
*
|
|
637
|
+
* # Safety
|
|
638
|
+
*
|
|
639
|
+
* The message contents and content type must either be NULL pointers, or point to valid
|
|
640
|
+
* UTF-8 encoded NULL-terminated strings. Otherwise behaviour is undefined.
|
|
641
|
+
*
|
|
642
|
+
* # Error Handling
|
|
643
|
+
*
|
|
644
|
+
* If the contents is a NULL pointer, it will set the message contents as null. If the content
|
|
645
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
646
|
+
*/
|
|
647
|
+
void pactffi_message_set_contents(Message *message, const char *contents, const char *content_type);
|
|
648
|
+
|
|
619
649
|
/**
|
|
620
650
|
* Get the length of the contents of a `Message`.
|
|
621
651
|
*
|
|
@@ -646,6 +676,24 @@ size_t pactffi_message_get_contents_length(const Message *message);
|
|
|
646
676
|
*/
|
|
647
677
|
const unsigned char *pactffi_message_get_contents_bin(const Message *message);
|
|
648
678
|
|
|
679
|
+
/**
|
|
680
|
+
* Sets the contents of the message as an array of bytes.
|
|
681
|
+
*
|
|
682
|
+
* # Safety
|
|
683
|
+
*
|
|
684
|
+
* The contents pointer must be valid for reads of `len` bytes, and it must be properly aligned
|
|
685
|
+
* and consecutive. Otherwise behaviour is undefined.
|
|
686
|
+
*
|
|
687
|
+
* # Error Handling
|
|
688
|
+
*
|
|
689
|
+
* If the contents is a NULL pointer, it will set the message contents as null. If the content
|
|
690
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
691
|
+
*/
|
|
692
|
+
void pactffi_message_set_contents_bin(Message *message,
|
|
693
|
+
const unsigned char *contents,
|
|
694
|
+
size_t len,
|
|
695
|
+
const char *content_type);
|
|
696
|
+
|
|
649
697
|
/**
|
|
650
698
|
* Get a copy of the description.
|
|
651
699
|
*
|
|
@@ -1089,6 +1137,8 @@ void pactffi_pact_message_iter_delete(PactMessageIterator *iter);
|
|
|
1089
1137
|
* iterator, they do not need to be deleted but will be cleaned up when the iterator is
|
|
1090
1138
|
* deleted.
|
|
1091
1139
|
*
|
|
1140
|
+
* Will return a NULL pointer when the iterator has advanced past the end of the list.
|
|
1141
|
+
*
|
|
1092
1142
|
* # Safety
|
|
1093
1143
|
*
|
|
1094
1144
|
* This function is safe.
|
|
@@ -1106,6 +1156,8 @@ Message *pactffi_pact_message_iter_next(PactMessageIterator *iter);
|
|
|
1106
1156
|
* iterator, they do not need to be deleted but will be cleaned up when the iterator is
|
|
1107
1157
|
* deleted.
|
|
1108
1158
|
*
|
|
1159
|
+
* Will return a NULL pointer when the iterator has advanced past the end of the list.
|
|
1160
|
+
*
|
|
1109
1161
|
* # Safety
|
|
1110
1162
|
*
|
|
1111
1163
|
* This function is safe.
|
|
@@ -1123,6 +1175,43 @@ SynchronousMessage *pactffi_pact_sync_message_iter_next(PactSyncMessageIterator
|
|
|
1123
1175
|
*/
|
|
1124
1176
|
void pactffi_pact_sync_message_iter_delete(PactSyncMessageIterator *iter);
|
|
1125
1177
|
|
|
1178
|
+
/**
|
|
1179
|
+
* Get the next synchronous HTTP request/response interaction from the pact. As the
|
|
1180
|
+
* interactions returned are owned by the iterator, they do not need to be deleted but
|
|
1181
|
+
* will be cleaned up when the iterator is deleted.
|
|
1182
|
+
*
|
|
1183
|
+
* Will return a NULL pointer when the iterator has advanced past the end of the list.
|
|
1184
|
+
*
|
|
1185
|
+
* # Safety
|
|
1186
|
+
*
|
|
1187
|
+
* This function is safe.
|
|
1188
|
+
*
|
|
1189
|
+
* Deleting an interaction returned by the iterator can lead to undefined behaviour.
|
|
1190
|
+
*
|
|
1191
|
+
* # Error Handling
|
|
1192
|
+
*
|
|
1193
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
1194
|
+
*/
|
|
1195
|
+
SynchronousHttp *pactffi_pact_sync_http_iter_next(PactSyncHttpIterator *iter);
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* Free the iterator when you're done using it.
|
|
1199
|
+
*/
|
|
1200
|
+
void pactffi_pact_sync_http_iter_delete(PactSyncHttpIterator *iter);
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* Get a mutable pointer to a newly-created default message on the heap.
|
|
1204
|
+
*
|
|
1205
|
+
* # Safety
|
|
1206
|
+
*
|
|
1207
|
+
* This function is safe.
|
|
1208
|
+
*
|
|
1209
|
+
* # Error Handling
|
|
1210
|
+
*
|
|
1211
|
+
* Returns NULL on error.
|
|
1212
|
+
*/
|
|
1213
|
+
SynchronousMessage *pactffi_sync_message_new();
|
|
1214
|
+
|
|
1126
1215
|
/**
|
|
1127
1216
|
* Destroy the `Message` being pointed to.
|
|
1128
1217
|
*/
|
|
@@ -1146,6 +1235,27 @@ void pactffi_sync_message_delete(SynchronousMessage *message);
|
|
|
1146
1235
|
*/
|
|
1147
1236
|
const char *pactffi_sync_message_get_request_contents(const SynchronousMessage *message);
|
|
1148
1237
|
|
|
1238
|
+
/**
|
|
1239
|
+
* Sets the request contents of the message.
|
|
1240
|
+
*
|
|
1241
|
+
* * `message` - the message to set the request contents for
|
|
1242
|
+
* * `contents` - pointer to contents to copy from. Must be a valid NULL-terminated UTF-8 string pointer.
|
|
1243
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
1244
|
+
*
|
|
1245
|
+
* # Safety
|
|
1246
|
+
*
|
|
1247
|
+
* The message contents and content type must either be NULL pointers, or point to valid
|
|
1248
|
+
* UTF-8 encoded NULL-terminated strings. Otherwise behaviour is undefined.
|
|
1249
|
+
*
|
|
1250
|
+
* # Error Handling
|
|
1251
|
+
*
|
|
1252
|
+
* If the contents is a NULL pointer, it will set the message contents as null. If the content
|
|
1253
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1254
|
+
*/
|
|
1255
|
+
void pactffi_sync_message_set_request_contents(SynchronousMessage *message,
|
|
1256
|
+
const char *contents,
|
|
1257
|
+
const char *content_type);
|
|
1258
|
+
|
|
1149
1259
|
/**
|
|
1150
1260
|
* Get the length of the request contents of a `SynchronousMessage`.
|
|
1151
1261
|
*
|
|
@@ -1176,6 +1286,29 @@ size_t pactffi_sync_message_get_request_contents_length(const SynchronousMessage
|
|
|
1176
1286
|
*/
|
|
1177
1287
|
const unsigned char *pactffi_sync_message_get_request_contents_bin(const SynchronousMessage *message);
|
|
1178
1288
|
|
|
1289
|
+
/**
|
|
1290
|
+
* Sets the request contents of the message as an array of bytes.
|
|
1291
|
+
*
|
|
1292
|
+
* * `message` - the message to set the request contents for
|
|
1293
|
+
* * `contents` - pointer to contents to copy from
|
|
1294
|
+
* * `len` - number of bytes to copy from the contents pointer
|
|
1295
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
1296
|
+
*
|
|
1297
|
+
* # Safety
|
|
1298
|
+
*
|
|
1299
|
+
* The contents pointer must be valid for reads of `len` bytes, and it must be properly aligned
|
|
1300
|
+
* and consecutive. Otherwise behaviour is undefined.
|
|
1301
|
+
*
|
|
1302
|
+
* # Error Handling
|
|
1303
|
+
*
|
|
1304
|
+
* If the contents is a NULL pointer, it will set the message contents as null. If the content
|
|
1305
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1306
|
+
*/
|
|
1307
|
+
void pactffi_sync_message_set_request_contents_bin(SynchronousMessage *message,
|
|
1308
|
+
const unsigned char *contents,
|
|
1309
|
+
size_t len,
|
|
1310
|
+
const char *content_type);
|
|
1311
|
+
|
|
1179
1312
|
/**
|
|
1180
1313
|
* Get the number of response messages in the `SynchronousMessage`.
|
|
1181
1314
|
*
|
|
@@ -1209,6 +1342,30 @@ size_t pactffi_sync_message_get_number_responses(const SynchronousMessage *messa
|
|
|
1209
1342
|
const char *pactffi_sync_message_get_response_contents(const SynchronousMessage *message,
|
|
1210
1343
|
size_t index);
|
|
1211
1344
|
|
|
1345
|
+
/**
|
|
1346
|
+
* Sets the response contents of the message. If index is greater than the number of responses
|
|
1347
|
+
* in the message, the responses will be padded with default values.
|
|
1348
|
+
*
|
|
1349
|
+
* * `message` - the message to set the response contents for
|
|
1350
|
+
* * `index` - index of the response to set. 0 is the first response.
|
|
1351
|
+
* * `contents` - pointer to contents to copy from. Must be a valid NULL-terminated UTF-8 string pointer.
|
|
1352
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
1353
|
+
*
|
|
1354
|
+
* # Safety
|
|
1355
|
+
*
|
|
1356
|
+
* The message contents and content type must either be NULL pointers, or point to valid
|
|
1357
|
+
* UTF-8 encoded NULL-terminated strings. Otherwise behaviour is undefined.
|
|
1358
|
+
*
|
|
1359
|
+
* # Error Handling
|
|
1360
|
+
*
|
|
1361
|
+
* If the contents is a NULL pointer, it will set the response contents as null. If the content
|
|
1362
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1363
|
+
*/
|
|
1364
|
+
void pactffi_sync_message_set_response_contents(SynchronousMessage *message,
|
|
1365
|
+
size_t index,
|
|
1366
|
+
const char *contents,
|
|
1367
|
+
const char *content_type);
|
|
1368
|
+
|
|
1212
1369
|
/**
|
|
1213
1370
|
* Get the length of the response contents of a `SynchronousMessage`.
|
|
1214
1371
|
*
|
|
@@ -1241,6 +1398,33 @@ size_t pactffi_sync_message_get_response_contents_length(const SynchronousMessag
|
|
|
1241
1398
|
const unsigned char *pactffi_sync_message_get_response_contents_bin(const SynchronousMessage *message,
|
|
1242
1399
|
size_t index);
|
|
1243
1400
|
|
|
1401
|
+
/**
|
|
1402
|
+
* Sets the response contents of the message at the given index as an array of bytes. If index
|
|
1403
|
+
* is greater than the number of responses in the message, the responses will be padded with
|
|
1404
|
+
* default values.
|
|
1405
|
+
*
|
|
1406
|
+
* * `message` - the message to set the response contents for
|
|
1407
|
+
* * `index` - index of the response to set. 0 is the first response
|
|
1408
|
+
* * `contents` - pointer to contents to copy from
|
|
1409
|
+
* * `len` - number of bytes to copy
|
|
1410
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
1411
|
+
*
|
|
1412
|
+
* # Safety
|
|
1413
|
+
*
|
|
1414
|
+
* The contents pointer must be valid for reads of `len` bytes, and it must be properly aligned
|
|
1415
|
+
* and consecutive. Otherwise behaviour is undefined.
|
|
1416
|
+
*
|
|
1417
|
+
* # Error Handling
|
|
1418
|
+
*
|
|
1419
|
+
* If the contents is a NULL pointer, it will set the message contents as null. If the content
|
|
1420
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1421
|
+
*/
|
|
1422
|
+
void pactffi_sync_message_set_response_contents_bin(SynchronousMessage *message,
|
|
1423
|
+
size_t index,
|
|
1424
|
+
const unsigned char *contents,
|
|
1425
|
+
size_t len,
|
|
1426
|
+
const char *content_type);
|
|
1427
|
+
|
|
1244
1428
|
/**
|
|
1245
1429
|
* Get a copy of the description.
|
|
1246
1430
|
*
|
|
@@ -1310,23 +1494,301 @@ const ProviderState *pactffi_sync_message_get_provider_state(const SynchronousMe
|
|
|
1310
1494
|
*/
|
|
1311
1495
|
ProviderStateIterator *pactffi_sync_message_get_provider_state_iter(SynchronousMessage *message);
|
|
1312
1496
|
|
|
1497
|
+
/**
|
|
1498
|
+
* Get a mutable pointer to a newly-created default interaction on the heap.
|
|
1499
|
+
*
|
|
1500
|
+
* # Safety
|
|
1501
|
+
*
|
|
1502
|
+
* This function is safe.
|
|
1503
|
+
*
|
|
1504
|
+
* # Error Handling
|
|
1505
|
+
*
|
|
1506
|
+
* Returns NULL on error.
|
|
1507
|
+
*/
|
|
1508
|
+
SynchronousHttp *pactffi_sync_http_new();
|
|
1509
|
+
|
|
1510
|
+
/**
|
|
1511
|
+
* Destroy the `SynchronousHttp` interaction being pointed to.
|
|
1512
|
+
*/
|
|
1513
|
+
void pactffi_sync_http_delete(SynchronousHttp *interaction);
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* Get the request contents of a `SynchronousHttp` interaction in string form.
|
|
1517
|
+
*
|
|
1518
|
+
* # Safety
|
|
1519
|
+
*
|
|
1520
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1521
|
+
*
|
|
1522
|
+
* The returned string can outlive the interaction.
|
|
1523
|
+
*
|
|
1524
|
+
* # Error Handling
|
|
1525
|
+
*
|
|
1526
|
+
* If the interaction is NULL, returns NULL. If the body of the request
|
|
1527
|
+
* is missing, then this function also returns NULL. This means there's
|
|
1528
|
+
* no mechanism to differentiate with this function call alone between
|
|
1529
|
+
* a NULL body and a missing body.
|
|
1530
|
+
*/
|
|
1531
|
+
const char *pactffi_sync_http_get_request_contents(const SynchronousHttp *interaction);
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* Sets the request contents of the interaction.
|
|
1535
|
+
*
|
|
1536
|
+
* * `interaction` - the interaction to set the request contents for
|
|
1537
|
+
* * `contents` - pointer to contents to copy from. Must be a valid NULL-terminated UTF-8 string pointer.
|
|
1538
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
1539
|
+
*
|
|
1540
|
+
* # Safety
|
|
1541
|
+
*
|
|
1542
|
+
* The request contents and content type must either be NULL pointers, or point to valid
|
|
1543
|
+
* UTF-8 encoded NULL-terminated strings. Otherwise behaviour is undefined.
|
|
1544
|
+
*
|
|
1545
|
+
* # Error Handling
|
|
1546
|
+
*
|
|
1547
|
+
* If the contents is a NULL pointer, it will set the request contents as null. If the content
|
|
1548
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1549
|
+
*/
|
|
1550
|
+
void pactffi_sync_http_set_request_contents(SynchronousHttp *interaction,
|
|
1551
|
+
const char *contents,
|
|
1552
|
+
const char *content_type);
|
|
1553
|
+
|
|
1554
|
+
/**
|
|
1555
|
+
* Get the length of the request contents of a `SynchronousHttp` interaction.
|
|
1556
|
+
*
|
|
1557
|
+
* # Safety
|
|
1558
|
+
*
|
|
1559
|
+
* This function is safe.
|
|
1560
|
+
*
|
|
1561
|
+
* # Error Handling
|
|
1562
|
+
*
|
|
1563
|
+
* If the interaction is NULL, returns 0. If the body of the request
|
|
1564
|
+
* is missing, then this function also returns 0.
|
|
1565
|
+
*/
|
|
1566
|
+
size_t pactffi_sync_http_get_request_contents_length(const SynchronousHttp *interaction);
|
|
1567
|
+
|
|
1568
|
+
/**
|
|
1569
|
+
* Get the request contents of a `SynchronousHttp` interaction as a pointer to an array of bytes.
|
|
1570
|
+
*
|
|
1571
|
+
* # Safety
|
|
1572
|
+
*
|
|
1573
|
+
* The number of bytes in the buffer will be returned by `pactffi_sync_http_get_request_contents_length`.
|
|
1574
|
+
* It is safe to use the pointer while the interaction is not deleted or changed. Using the pointer
|
|
1575
|
+
* after the interaction is mutated or deleted may lead to undefined behaviour.
|
|
1576
|
+
*
|
|
1577
|
+
* # Error Handling
|
|
1578
|
+
*
|
|
1579
|
+
* If the interaction is NULL, returns NULL. If the body of the request
|
|
1580
|
+
* is missing, then this function also returns NULL.
|
|
1581
|
+
*/
|
|
1582
|
+
const unsigned char *pactffi_sync_http_get_request_contents_bin(const SynchronousHttp *interaction);
|
|
1583
|
+
|
|
1584
|
+
/**
|
|
1585
|
+
* Sets the request contents of the interaction as an array of bytes.
|
|
1586
|
+
*
|
|
1587
|
+
* * `interaction` - the interaction to set the request contents for
|
|
1588
|
+
* * `contents` - pointer to contents to copy from
|
|
1589
|
+
* * `len` - number of bytes to copy from the contents pointer
|
|
1590
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
1591
|
+
*
|
|
1592
|
+
* # Safety
|
|
1593
|
+
*
|
|
1594
|
+
* The contents pointer must be valid for reads of `len` bytes, and it must be properly aligned
|
|
1595
|
+
* and consecutive. Otherwise behaviour is undefined.
|
|
1596
|
+
*
|
|
1597
|
+
* # Error Handling
|
|
1598
|
+
*
|
|
1599
|
+
* If the contents is a NULL pointer, it will set the request contents as null. If the content
|
|
1600
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1601
|
+
*/
|
|
1602
|
+
void pactffi_sync_http_set_request_contents_bin(SynchronousHttp *interaction,
|
|
1603
|
+
const unsigned char *contents,
|
|
1604
|
+
size_t len,
|
|
1605
|
+
const char *content_type);
|
|
1606
|
+
|
|
1607
|
+
/**
|
|
1608
|
+
* Get the response contents of a `SynchronousHttp` interaction in string form.
|
|
1609
|
+
*
|
|
1610
|
+
* # Safety
|
|
1611
|
+
*
|
|
1612
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1613
|
+
*
|
|
1614
|
+
* The returned string can outlive the interaction.
|
|
1615
|
+
*
|
|
1616
|
+
* # Error Handling
|
|
1617
|
+
*
|
|
1618
|
+
* If the interaction is NULL, returns NULL.
|
|
1619
|
+
*
|
|
1620
|
+
* If the body of the response is missing, then this function also returns NULL.
|
|
1621
|
+
* This means there's no mechanism to differentiate with this function call alone between
|
|
1622
|
+
* a NULL body and a missing body.
|
|
1623
|
+
*/
|
|
1624
|
+
const char *pactffi_sync_http_get_response_contents(const SynchronousHttp *interaction);
|
|
1625
|
+
|
|
1626
|
+
/**
|
|
1627
|
+
* Sets the response contents of the interaction.
|
|
1628
|
+
*
|
|
1629
|
+
* * `interaction` - the interaction to set the response contents for
|
|
1630
|
+
* * `contents` - pointer to contents to copy from. Must be a valid NULL-terminated UTF-8 string pointer.
|
|
1631
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
1632
|
+
*
|
|
1633
|
+
* # Safety
|
|
1634
|
+
*
|
|
1635
|
+
* The response contents and content type must either be NULL pointers, or point to valid
|
|
1636
|
+
* UTF-8 encoded NULL-terminated strings. Otherwise behaviour is undefined.
|
|
1637
|
+
*
|
|
1638
|
+
* # Error Handling
|
|
1639
|
+
*
|
|
1640
|
+
* If the contents is a NULL pointer, it will set the response contents as null. If the content
|
|
1641
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1642
|
+
*/
|
|
1643
|
+
void pactffi_sync_http_set_response_contents(SynchronousHttp *interaction,
|
|
1644
|
+
const char *contents,
|
|
1645
|
+
const char *content_type);
|
|
1646
|
+
|
|
1647
|
+
/**
|
|
1648
|
+
* Get the length of the response contents of a `SynchronousHttp` interaction.
|
|
1649
|
+
*
|
|
1650
|
+
* # Safety
|
|
1651
|
+
*
|
|
1652
|
+
* This function is safe.
|
|
1653
|
+
*
|
|
1654
|
+
* # Error Handling
|
|
1655
|
+
*
|
|
1656
|
+
* If the interaction is NULL or the index is not valid, returns 0. If the body of the response
|
|
1657
|
+
* is missing, then this function also returns 0.
|
|
1658
|
+
*/
|
|
1659
|
+
size_t pactffi_sync_http_get_response_contents_length(const SynchronousHttp *interaction);
|
|
1660
|
+
|
|
1661
|
+
/**
|
|
1662
|
+
* Get the response contents of a `SynchronousHttp` interaction as a pointer to an array of bytes.
|
|
1663
|
+
*
|
|
1664
|
+
* # Safety
|
|
1665
|
+
*
|
|
1666
|
+
* The number of bytes in the buffer will be returned by `pactffi_sync_http_get_response_contents_length`.
|
|
1667
|
+
* It is safe to use the pointer while the interaction is not deleted or changed. Using the pointer
|
|
1668
|
+
* after the interaction is mutated or deleted may lead to undefined behaviour.
|
|
1669
|
+
*
|
|
1670
|
+
* # Error Handling
|
|
1671
|
+
*
|
|
1672
|
+
* If the interaction is NULL, returns NULL. If the body of the response
|
|
1673
|
+
* is missing, then this function also returns NULL.
|
|
1674
|
+
*/
|
|
1675
|
+
const unsigned char *pactffi_sync_http_get_response_contents_bin(const SynchronousHttp *interaction);
|
|
1676
|
+
|
|
1677
|
+
/**
|
|
1678
|
+
* Sets the response contents of the `SynchronousHttp` interaction as an array of bytes.
|
|
1679
|
+
*
|
|
1680
|
+
* * `interaction` - the interaction to set the response contents for
|
|
1681
|
+
* * `contents` - pointer to contents to copy from
|
|
1682
|
+
* * `len` - number of bytes to copy
|
|
1683
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
1684
|
+
*
|
|
1685
|
+
* # Safety
|
|
1686
|
+
*
|
|
1687
|
+
* The contents pointer must be valid for reads of `len` bytes, and it must be properly aligned
|
|
1688
|
+
* and consecutive. Otherwise behaviour is undefined.
|
|
1689
|
+
*
|
|
1690
|
+
* # Error Handling
|
|
1691
|
+
*
|
|
1692
|
+
* If the contents is a NULL pointer, it will set the response contents as null. If the content
|
|
1693
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1694
|
+
*/
|
|
1695
|
+
void pactffi_sync_http_set_response_contents_bin(SynchronousHttp *interaction,
|
|
1696
|
+
const unsigned char *contents,
|
|
1697
|
+
size_t len,
|
|
1698
|
+
const char *content_type);
|
|
1699
|
+
|
|
1700
|
+
/**
|
|
1701
|
+
* Get a copy of the description.
|
|
1702
|
+
*
|
|
1703
|
+
* # Safety
|
|
1704
|
+
*
|
|
1705
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1706
|
+
*
|
|
1707
|
+
* Since it is a copy, the returned string may safely outlive
|
|
1708
|
+
* the `SynchronousHttp` interaction.
|
|
1709
|
+
*
|
|
1710
|
+
* # Errors
|
|
1711
|
+
*
|
|
1712
|
+
* On failure, this function will return a NULL pointer.
|
|
1713
|
+
*
|
|
1714
|
+
* This function may fail if the Rust string contains embedded
|
|
1715
|
+
* null ('\0') bytes.
|
|
1716
|
+
*/
|
|
1717
|
+
const char *pactffi_sync_http_get_description(const SynchronousHttp *interaction);
|
|
1718
|
+
|
|
1719
|
+
/**
|
|
1720
|
+
* Write the `description` field on the `SynchronousHttp`.
|
|
1721
|
+
*
|
|
1722
|
+
* # Safety
|
|
1723
|
+
*
|
|
1724
|
+
* `description` must contain valid UTF-8. Invalid UTF-8
|
|
1725
|
+
* will be replaced with U+FFFD REPLACEMENT CHARACTER.
|
|
1726
|
+
*
|
|
1727
|
+
* This function will only reallocate if the new string
|
|
1728
|
+
* does not fit in the existing buffer.
|
|
1729
|
+
*
|
|
1730
|
+
* # Error Handling
|
|
1731
|
+
*
|
|
1732
|
+
* Errors will be reported with a non-zero return value.
|
|
1733
|
+
*/
|
|
1734
|
+
int pactffi_sync_http_set_description(SynchronousHttp *interaction, const char *description);
|
|
1735
|
+
|
|
1736
|
+
/**
|
|
1737
|
+
* Get a copy of the provider state at the given index from this interaction.
|
|
1738
|
+
*
|
|
1739
|
+
* # Safety
|
|
1740
|
+
*
|
|
1741
|
+
* The returned structure must be deleted with `provider_state_delete`.
|
|
1742
|
+
*
|
|
1743
|
+
* Since it is a copy, the returned structure may safely outlive
|
|
1744
|
+
* the `SynchronousHttp`.
|
|
1745
|
+
*
|
|
1746
|
+
* # Error Handling
|
|
1747
|
+
*
|
|
1748
|
+
* On failure, this function will return a variant other than Success.
|
|
1749
|
+
*
|
|
1750
|
+
* This function may fail if the index requested is out of bounds,
|
|
1751
|
+
* or if any of the Rust strings contain embedded null ('\0') bytes.
|
|
1752
|
+
*/
|
|
1753
|
+
const ProviderState *pactffi_sync_http_get_provider_state(const SynchronousHttp *interaction,
|
|
1754
|
+
unsigned int index);
|
|
1755
|
+
|
|
1756
|
+
/**
|
|
1757
|
+
* Get an iterator over provider states.
|
|
1758
|
+
*
|
|
1759
|
+
* # Safety
|
|
1760
|
+
*
|
|
1761
|
+
* The underlying data must not change during iteration.
|
|
1762
|
+
*
|
|
1763
|
+
* # Error Handling
|
|
1764
|
+
*
|
|
1765
|
+
* Returns NULL if an error occurs.
|
|
1766
|
+
*/
|
|
1767
|
+
ProviderStateIterator *pactffi_sync_http_get_provider_state_iter(SynchronousHttp *interaction);
|
|
1768
|
+
|
|
1313
1769
|
/**
|
|
1314
1770
|
* Delete a string previously returned by this FFI.
|
|
1315
1771
|
*
|
|
1316
1772
|
* It is explicitly allowed to pass a null pointer to this function;
|
|
1317
1773
|
* in that case the function will do nothing.
|
|
1774
|
+
*
|
|
1775
|
+
* # Safety
|
|
1776
|
+
* Passing an invalid pointer, or one that was not returned by a FFI function can result in
|
|
1777
|
+
* undefined behaviour.
|
|
1318
1778
|
*/
|
|
1319
1779
|
void pactffi_string_delete(char *string);
|
|
1320
1780
|
|
|
1321
1781
|
/**
|
|
1322
|
-
* External interface to create a mock server. A pointer to the pact JSON as a C
|
|
1323
|
-
* as well as the port for the mock server to run on. A value of 0 for the
|
|
1324
|
-
* port being allocated by the operating system. The port of the mock server is returned.
|
|
1782
|
+
* [DEPRECATED] External interface to create a HTTP mock server. A pointer to the pact JSON as a NULL-terminated C
|
|
1783
|
+
* string is passed in, as well as the port for the mock server to run on. A value of 0 for the
|
|
1784
|
+
* port will result in a port being allocated by the operating system. The port of the mock server is returned.
|
|
1325
1785
|
*
|
|
1326
1786
|
* * `pact_str` - Pact JSON
|
|
1327
1787
|
* * `addr_str` - Address to bind to in the form name:port (i.e. 127.0.0.1:0)
|
|
1328
1788
|
* * `tls` - boolean flag to indicate of the mock server should use TLS (using a self-signed certificate)
|
|
1329
1789
|
*
|
|
1790
|
+
* This function is deprecated and replaced with `pactffi_create_mock_server_for_transport`.
|
|
1791
|
+
*
|
|
1330
1792
|
* # Errors
|
|
1331
1793
|
*
|
|
1332
1794
|
* Errors are returned as negative values.
|
|
@@ -1349,30 +1811,32 @@ int32_t pactffi_create_mock_server(const char *pact_str,
|
|
|
1349
1811
|
* Fetch the CA Certificate used to generate the self-signed certificate for the TLS mock server.
|
|
1350
1812
|
*
|
|
1351
1813
|
* **NOTE:** The string for the result is allocated on the heap, and will have to be freed
|
|
1352
|
-
* by the caller using
|
|
1814
|
+
* by the caller using pactffi_string_delete.
|
|
1353
1815
|
*
|
|
1354
1816
|
* # Errors
|
|
1355
1817
|
*
|
|
1356
|
-
* An empty string indicates an error reading the pem file
|
|
1818
|
+
* An empty string indicates an error reading the pem file.
|
|
1357
1819
|
*/
|
|
1358
1820
|
char *pactffi_get_tls_ca_certificate();
|
|
1359
1821
|
|
|
1360
1822
|
/**
|
|
1361
|
-
* External interface to create a mock server. A Pact handle is passed in,
|
|
1823
|
+
* [DEPRECATED] External interface to create a HTTP mock server. A Pact handle is passed in,
|
|
1362
1824
|
* as well as the port for the mock server to run on. A value of 0 for the port will result in a
|
|
1363
1825
|
* port being allocated by the operating system. The port of the mock server is returned.
|
|
1364
1826
|
*
|
|
1365
|
-
* * `pact` - Handle to a Pact model
|
|
1366
|
-
* * `addr_str` - Address to bind to in the form name:port (i.e. 127.0.0.1:0)
|
|
1827
|
+
* * `pact` - Handle to a Pact model created with created with `pactffi_new_pact`.
|
|
1828
|
+
* * `addr_str` - Address to bind to in the form name:port (i.e. 127.0.0.1:0). Must be a valid UTF-8 NULL-terminated string.
|
|
1367
1829
|
* * `tls` - boolean flag to indicate of the mock server should use TLS (using a self-signed certificate)
|
|
1368
1830
|
*
|
|
1831
|
+
* This function is deprecated and replaced with `pactffi_create_mock_server_for_transport`.
|
|
1832
|
+
*
|
|
1369
1833
|
* # Errors
|
|
1370
1834
|
*
|
|
1371
1835
|
* Errors are returned as negative values.
|
|
1372
1836
|
*
|
|
1373
1837
|
* | Error | Description |
|
|
1374
1838
|
* |-------|-------------|
|
|
1375
|
-
* | -1 | An invalid handle was received |
|
|
1839
|
+
* | -1 | An invalid handle was received. Handles should be created with `pactffi_new_pact` |
|
|
1376
1840
|
* | -3 | The mock server could not be started |
|
|
1377
1841
|
* | -4 | The method panicked |
|
|
1378
1842
|
* | -5 | The address is not valid |
|
|
@@ -1383,6 +1847,44 @@ int32_t pactffi_create_mock_server_for_pact(PactHandle pact,
|
|
|
1383
1847
|
const char *addr_str,
|
|
1384
1848
|
bool tls);
|
|
1385
1849
|
|
|
1850
|
+
/**
|
|
1851
|
+
* Create a mock server for the provided Pact handle and transport. If the transport is not
|
|
1852
|
+
* provided (it is a NULL pointer or an empty string), will default to an HTTP transport. The
|
|
1853
|
+
* address is the interface bind to, and will default to the loopback adapter if not specified.
|
|
1854
|
+
* Specifying a value of zero for the port will result in the operating system allocating the port.
|
|
1855
|
+
*
|
|
1856
|
+
* Parameters:
|
|
1857
|
+
* * `pact` - Handle to a Pact model created with created with `pactffi_new_pact`.
|
|
1858
|
+
* * `addr` - Address to bind to (i.e. `127.0.0.1` or `[::1]`). Must be a valid UTF-8 NULL-terminated string, or NULL or empty, in which case the loopback adapter is used.
|
|
1859
|
+
* * `port` - Port number to bind to. A value of zero will result in the operating system allocating an available port.
|
|
1860
|
+
* * `transport` - The transport to use (i.e. http, https, grpc). Must be a valid UTF-8 NULL-terminated string, or NULL or empty, in which case http will be used.
|
|
1861
|
+
* * `transport_config` - (OPTIONAL) Configuration for the transport as a valid JSON string. Set to NULL or empty if not required.
|
|
1862
|
+
*
|
|
1863
|
+
* The port of the mock server is returned.
|
|
1864
|
+
*
|
|
1865
|
+
* # Safety
|
|
1866
|
+
* NULL pointers or empty strings can be passed in for the address, transport and transport_config,
|
|
1867
|
+
* in which case a default value will be used. Passing in an invalid pointer will result in undefined behaviour.
|
|
1868
|
+
*
|
|
1869
|
+
* # Errors
|
|
1870
|
+
*
|
|
1871
|
+
* Errors are returned as negative values.
|
|
1872
|
+
*
|
|
1873
|
+
* | Error | Description |
|
|
1874
|
+
* |-------|-------------|
|
|
1875
|
+
* | -1 | An invalid handle was received. Handles should be created with `pactffi_new_pact` |
|
|
1876
|
+
* | -2 | transport_config is not valid JSON |
|
|
1877
|
+
* | -3 | The mock server could not be started |
|
|
1878
|
+
* | -4 | The method panicked |
|
|
1879
|
+
* | -5 | The address is not valid |
|
|
1880
|
+
*
|
|
1881
|
+
*/
|
|
1882
|
+
int32_t pactffi_create_mock_server_for_transport(PactHandle pact,
|
|
1883
|
+
const char *addr,
|
|
1884
|
+
uint16_t port,
|
|
1885
|
+
const char *transport,
|
|
1886
|
+
const char *transport_config);
|
|
1887
|
+
|
|
1386
1888
|
/**
|
|
1387
1889
|
* External interface to check if a mock server has matched all its requests. The port number is
|
|
1388
1890
|
* passed in, and if all requests have been matched, true is returned. False is returned if there
|
|
@@ -1449,41 +1951,46 @@ const char *pactffi_mock_server_logs(int32_t mock_server_port);
|
|
|
1449
1951
|
|
|
1450
1952
|
/**
|
|
1451
1953
|
* Generates a datetime value from the provided format string, using the current system date and time
|
|
1452
|
-
* NOTE: The memory for the returned string needs to be freed with the
|
|
1954
|
+
* NOTE: The memory for the returned string needs to be freed with the `pactffi_string_delete` function
|
|
1453
1955
|
*
|
|
1454
1956
|
* # Safety
|
|
1455
1957
|
*
|
|
1456
|
-
*
|
|
1958
|
+
* If the format string pointer is NULL or has invalid UTF-8 characters, an error result will be
|
|
1959
|
+
* returned. If the format string pointer is not a valid pointer or is not a NULL-terminated string,
|
|
1960
|
+
* this will lead to undefined behaviour.
|
|
1457
1961
|
*/
|
|
1458
1962
|
StringResult pactffi_generate_datetime_string(const char *format);
|
|
1459
1963
|
|
|
1460
1964
|
/**
|
|
1461
|
-
* Checks that the example string matches the given regex
|
|
1965
|
+
* Checks that the example string matches the given regex.
|
|
1462
1966
|
*
|
|
1463
1967
|
* # Safety
|
|
1464
1968
|
*
|
|
1465
|
-
*
|
|
1969
|
+
* Both the regex and example pointers must be valid pointers to NULL-terminated strings. Invalid
|
|
1970
|
+
* pointers will result in undefined behaviour.
|
|
1466
1971
|
*/
|
|
1467
1972
|
bool pactffi_check_regex(const char *regex, const char *example);
|
|
1468
1973
|
|
|
1469
1974
|
/**
|
|
1470
1975
|
* Generates an example string based on the provided regex.
|
|
1471
|
-
* NOTE: The memory for the returned string needs to be freed with the
|
|
1976
|
+
* NOTE: The memory for the returned string needs to be freed with the `pactffi_string_delete` function.
|
|
1472
1977
|
*
|
|
1473
1978
|
* # Safety
|
|
1474
1979
|
*
|
|
1475
|
-
*
|
|
1980
|
+
* The regex pointer must be a valid pointer to a NULL-terminated string. Invalid pointers will
|
|
1981
|
+
* result in undefined behaviour.
|
|
1476
1982
|
*/
|
|
1477
1983
|
StringResult pactffi_generate_regex_value(const char *regex);
|
|
1478
1984
|
|
|
1479
1985
|
/**
|
|
1480
1986
|
* [DEPRECATED] Frees the memory allocated to a string by another function
|
|
1481
1987
|
*
|
|
1482
|
-
* This function is deprecated. Use pactffi_string_delete instead.
|
|
1988
|
+
* This function is deprecated. Use `pactffi_string_delete` instead.
|
|
1483
1989
|
*
|
|
1484
1990
|
* # Safety
|
|
1485
1991
|
*
|
|
1486
|
-
*
|
|
1992
|
+
* The string pointer can be NULL (which is a no-op), but if it is not a valid pointer the call
|
|
1993
|
+
* will result in undefined behaviour.
|
|
1487
1994
|
*/
|
|
1488
1995
|
void pactffi_free_string(char *s);
|
|
1489
1996
|
|
|
@@ -1553,7 +2060,7 @@ bool pactffi_given(InteractionHandle interaction, const char *description);
|
|
|
1553
2060
|
*
|
|
1554
2061
|
* * `1` - Function panicked. Error message will be available by calling `pactffi_get_error_message`.
|
|
1555
2062
|
* * `2` - Handle was not valid.
|
|
1556
|
-
* * `3` - Mock server was already started and the
|
|
2063
|
+
* * `3` - Mock server was already started and the integration can not be modified.
|
|
1557
2064
|
* * `4` - Not a V4 interaction.
|
|
1558
2065
|
*/
|
|
1559
2066
|
unsigned int pactffi_interaction_test_name(InteractionHandle interaction,
|
|
@@ -1578,8 +2085,18 @@ bool pactffi_given_with_param(InteractionHandle interaction,
|
|
|
1578
2085
|
*
|
|
1579
2086
|
* * `method` - The request method. Defaults to GET.
|
|
1580
2087
|
* * `path` - The request path. Defaults to `/`.
|
|
2088
|
+
*
|
|
2089
|
+
* To include matching rules for the path (only regex really makes sense to use), include the
|
|
2090
|
+
* matching rule JSON format with the value as a single JSON document. I.e.
|
|
2091
|
+
*
|
|
2092
|
+
* ```c
|
|
2093
|
+
* const char* value = "{\"value\":\"/path/to/100\", \"pact:matcher:type\":\"regex\", \"regex\":\"\\/path\\/to\\/\\\\d+\"}";
|
|
2094
|
+
* pactffi_with_request(handle, "GET", value);
|
|
2095
|
+
*
|
|
1581
2096
|
*/
|
|
1582
|
-
bool pactffi_with_request(InteractionHandle interaction,
|
|
2097
|
+
bool pactffi_with_request(InteractionHandle interaction,
|
|
2098
|
+
const char *method,
|
|
2099
|
+
const char *path);
|
|
1583
2100
|
|
|
1584
2101
|
/**
|
|
1585
2102
|
* Configures a query parameter for the Interaction. Returns false if the interaction or Pact can't be
|
|
@@ -1588,15 +2105,57 @@ bool pactffi_with_request(InteractionHandle interaction, const char *method, con
|
|
|
1588
2105
|
* * `name` - the query parameter name.
|
|
1589
2106
|
* * `value` - the query parameter value.
|
|
1590
2107
|
* * `index` - the index of the value (starts at 0). You can use this to create a query parameter with multiple values
|
|
2108
|
+
*
|
|
2109
|
+
* **DEPRECATED:** Use `pactffi_with_query_parameter_v2`, which deals with multiple values correctly
|
|
1591
2110
|
*/
|
|
1592
2111
|
bool pactffi_with_query_parameter(InteractionHandle interaction,
|
|
1593
2112
|
const char *name,
|
|
1594
2113
|
size_t index,
|
|
1595
2114
|
const char *value);
|
|
1596
2115
|
|
|
2116
|
+
/**
|
|
2117
|
+
* Configures a query parameter for the Interaction. Returns false if the interaction or Pact can't be
|
|
2118
|
+
* modified (i.e. the mock server for it has already started)
|
|
2119
|
+
*
|
|
2120
|
+
* * `name` - the query parameter name.
|
|
2121
|
+
* * `value` - the query parameter value. Either a simple string or a JSON document.
|
|
2122
|
+
* * `index` - the index of the value (starts at 0). You can use this to create a query parameter with multiple values
|
|
2123
|
+
*
|
|
2124
|
+
* To setup a query parameter with multiple values, you can either call this function multiple times
|
|
2125
|
+
* with a different index value, i.e. to create `id=2&id=3`
|
|
2126
|
+
*
|
|
2127
|
+
* ```c
|
|
2128
|
+
* pactffi_with_query_parameter_v2(handle, "id", 0, "2");
|
|
2129
|
+
* pactffi_with_query_parameter_v2(handle, "id", 1, "3");
|
|
2130
|
+
* ```
|
|
2131
|
+
*
|
|
2132
|
+
* Or you can call it once with a JSON value that contains multiple values:
|
|
2133
|
+
*
|
|
2134
|
+
* ```c
|
|
2135
|
+
* const char* value = "{\"value\": [\"2\",\"3\"]}";
|
|
2136
|
+
* pactffi_with_query_parameter_v2(handle, "id", 0, value);
|
|
2137
|
+
* ```
|
|
2138
|
+
*
|
|
2139
|
+
* To include matching rules for the query parameter, include the matching rule JSON format with
|
|
2140
|
+
* the value as a single JSON document. I.e.
|
|
2141
|
+
*
|
|
2142
|
+
* ```c
|
|
2143
|
+
* const char* value = "{\"value\":\"2\", \"pact:matcher:type\":\"regex\", \"regex\":\"\\\\d+\"}";
|
|
2144
|
+
* pactffi_with_query_parameter_v2(handle, "id", 0, value);
|
|
2145
|
+
* ```
|
|
2146
|
+
*
|
|
2147
|
+
* # Safety
|
|
2148
|
+
* The name and value parameters must be valid pointers to NULL terminated strings.
|
|
2149
|
+
* ```
|
|
2150
|
+
*/
|
|
2151
|
+
bool pactffi_with_query_parameter_v2(InteractionHandle interaction,
|
|
2152
|
+
const char *name,
|
|
2153
|
+
size_t index,
|
|
2154
|
+
const char *value);
|
|
2155
|
+
|
|
1597
2156
|
/**
|
|
1598
2157
|
* Sets the specification version for a given Pact model. Returns false if the interaction or Pact can't be
|
|
1599
|
-
* modified (i.e. the mock server for it has already started) or the version is invalid
|
|
2158
|
+
* modified (i.e. the mock server for it has already started) or the version is invalid.
|
|
1600
2159
|
*
|
|
1601
2160
|
* * `pact` - Handle to a Pact model
|
|
1602
2161
|
* * `version` - the spec version to use
|
|
@@ -1626,6 +2185,8 @@ bool pactffi_with_pact_metadata(PactHandle pact,
|
|
|
1626
2185
|
* * `name` - the header name.
|
|
1627
2186
|
* * `value` - the header value.
|
|
1628
2187
|
* * `index` - the index of the value (starts at 0). You can use this to create a header with multiple values
|
|
2188
|
+
*
|
|
2189
|
+
* **DEPRECATED:** Use `pactffi_with_header_v2`, which deals with multiple values correctly
|
|
1629
2190
|
*/
|
|
1630
2191
|
bool pactffi_with_header(InteractionHandle interaction,
|
|
1631
2192
|
InteractionPart part,
|
|
@@ -1633,6 +2194,47 @@ bool pactffi_with_header(InteractionHandle interaction,
|
|
|
1633
2194
|
size_t index,
|
|
1634
2195
|
const char *value);
|
|
1635
2196
|
|
|
2197
|
+
/**
|
|
2198
|
+
* Configures a header for the Interaction. Returns false if the interaction or Pact can't be
|
|
2199
|
+
* modified (i.e. the mock server for it has already started)
|
|
2200
|
+
*
|
|
2201
|
+
* * `part` - The part of the interaction to add the header to (Request or Response).
|
|
2202
|
+
* * `name` - the header name.
|
|
2203
|
+
* * `value` - the header value.
|
|
2204
|
+
* * `index` - the index of the value (starts at 0). You can use this to create a header with multiple values
|
|
2205
|
+
*
|
|
2206
|
+
* To setup a header with multiple values, you can either call this function multiple times
|
|
2207
|
+
* with a different index value, i.e. to create `x-id=2, 3`
|
|
2208
|
+
*
|
|
2209
|
+
* ```c
|
|
2210
|
+
* pactffi_with_header_v2(handle, InteractionPart::Request, "x-id", 0, "2");
|
|
2211
|
+
* pactffi_with_header_v2(handle, InteractionPart::Request, "x-id", 1, "3");
|
|
2212
|
+
* ```
|
|
2213
|
+
*
|
|
2214
|
+
* Or you can call it once with a JSON value that contains multiple values:
|
|
2215
|
+
*
|
|
2216
|
+
* ```c
|
|
2217
|
+
* const char* value = "{\"value\": [\"2\",\"3\"]}";
|
|
2218
|
+
* pactffi_with_header_v2(handle, InteractionPart::Request, "x-id", 0, value);
|
|
2219
|
+
* ```
|
|
2220
|
+
*
|
|
2221
|
+
* To include matching rules for the header, include the matching rule JSON format with
|
|
2222
|
+
* the value as a single JSON document. I.e.
|
|
2223
|
+
*
|
|
2224
|
+
* ```c
|
|
2225
|
+
* const char* value = "{\"value\":\"2\", \"pact:matcher:type\":\"regex\", \"regex\":\"\\\\d+\"}";
|
|
2226
|
+
* pactffi_with_header_v2(handle, InteractionPart::Request, "id", 0, value);
|
|
2227
|
+
* ```
|
|
2228
|
+
*
|
|
2229
|
+
* # Safety
|
|
2230
|
+
* The name and value parameters must be valid pointers to NULL terminated strings.
|
|
2231
|
+
*/
|
|
2232
|
+
bool pactffi_with_header_v2(InteractionHandle interaction,
|
|
2233
|
+
InteractionPart part,
|
|
2234
|
+
const char *name,
|
|
2235
|
+
size_t index,
|
|
2236
|
+
const char *value);
|
|
2237
|
+
|
|
1636
2238
|
/**
|
|
1637
2239
|
* Configures the response for the Interaction. Returns false if the interaction or Pact can't be
|
|
1638
2240
|
* modified (i.e. the mock server for it has already started)
|
|
@@ -1649,6 +2251,22 @@ bool pactffi_response_status(InteractionHandle interaction, unsigned short statu
|
|
|
1649
2251
|
* * `content_type` - The content type of the body. Defaults to `text/plain`. Will be ignored if a content type
|
|
1650
2252
|
* header is already set.
|
|
1651
2253
|
* * `body` - The body contents. For JSON payloads, matching rules can be embedded in the body.
|
|
2254
|
+
*
|
|
2255
|
+
* For HTTP and async message interactions, this will overwrite the body. With asynchronous messages, the
|
|
2256
|
+
* part parameter will be ignored. With synchronous messages, the request contents will be overwritten,
|
|
2257
|
+
* while a new response will be appended to the message.
|
|
2258
|
+
*
|
|
2259
|
+
* # Safety
|
|
2260
|
+
*
|
|
2261
|
+
* The interaction contents and content type must either be NULL pointers, or point to valid
|
|
2262
|
+
* UTF-8 encoded NULL-terminated strings. Otherwise, behaviour is undefined.
|
|
2263
|
+
*
|
|
2264
|
+
* # Error Handling
|
|
2265
|
+
*
|
|
2266
|
+
* If the contents is a NULL pointer, it will set the body contents as null. If the content
|
|
2267
|
+
* type is a null pointer, or can't be parsed, it will set the content type as TEXT.
|
|
2268
|
+
* Returns false if the interaction or Pact can't be modified (i.e. the mock server for it has
|
|
2269
|
+
* already started) or an error has occurred.
|
|
1652
2270
|
*/
|
|
1653
2271
|
bool pactffi_with_body(InteractionHandle interaction,
|
|
1654
2272
|
InteractionPart part,
|
|
@@ -1665,6 +2283,22 @@ bool pactffi_with_body(InteractionHandle interaction,
|
|
|
1665
2283
|
* * `content_type` - Expected content type.
|
|
1666
2284
|
* * `body` - example body contents in bytes
|
|
1667
2285
|
* * `size` - number of bytes in the body
|
|
2286
|
+
*
|
|
2287
|
+
* For HTTP and async message interactions, this will overwrite the body. With asynchronous messages, the
|
|
2288
|
+
* part parameter will be ignored. With synchronous messages, the request contents will be overwritten,
|
|
2289
|
+
* while a new response will be appended to the message.
|
|
2290
|
+
*
|
|
2291
|
+
* # Safety
|
|
2292
|
+
*
|
|
2293
|
+
* The content type must be a valid UTF-8 encoded NULL-terminated string. The body pointer must
|
|
2294
|
+
* be valid for reads of `size` bytes, and it must be properly aligned and consecutive.
|
|
2295
|
+
*
|
|
2296
|
+
* # Error Handling
|
|
2297
|
+
*
|
|
2298
|
+
* If the body is a NULL pointer, it will set the body contents as null. If the content
|
|
2299
|
+
* type is a null pointer, or can't be parsed, it will return false.
|
|
2300
|
+
* Returns false if the interaction or Pact can't be modified (i.e. the mock server for it has
|
|
2301
|
+
* already started) or an error has occurred.
|
|
1668
2302
|
*/
|
|
1669
2303
|
bool pactffi_with_binary_file(InteractionHandle interaction,
|
|
1670
2304
|
InteractionPart part,
|
|
@@ -1675,13 +2309,27 @@ bool pactffi_with_binary_file(InteractionHandle interaction,
|
|
|
1675
2309
|
/**
|
|
1676
2310
|
* Adds a binary file as the body as a MIME multipart with the expected content type and example contents. Will use
|
|
1677
2311
|
* a mime type matcher to match the body. Returns an error if the interaction or Pact can't be
|
|
1678
|
-
* modified (i.e. the mock server for it has already started)
|
|
2312
|
+
* modified (i.e. the mock server for it has already started) or an error occurs.
|
|
1679
2313
|
*
|
|
1680
2314
|
* * `interaction` - Interaction handle to set the body for.
|
|
1681
2315
|
* * `part` - Request or response part.
|
|
1682
2316
|
* * `content_type` - Expected content type of the file.
|
|
1683
2317
|
* * `file` - path to the example file
|
|
1684
2318
|
* * `part_name` - name for the mime part
|
|
2319
|
+
*
|
|
2320
|
+
* # Safety
|
|
2321
|
+
*
|
|
2322
|
+
* The content type, file path and part name must be valid pointers to UTF-8 encoded NULL-terminated strings.
|
|
2323
|
+
* Passing invalid pointers or pointers to strings that are not NULL terminated will lead to undefined
|
|
2324
|
+
* behaviour.
|
|
2325
|
+
*
|
|
2326
|
+
* # Error Handling
|
|
2327
|
+
*
|
|
2328
|
+
* If the file path is a NULL pointer, it will set the body contents as as an empty mime-part.
|
|
2329
|
+
* If the file path does not point to a valid file, or is not able to be read, it will return an
|
|
2330
|
+
* error result. If the content type is a null pointer, or can't be parsed, it will return an error result.
|
|
2331
|
+
* Returns an error if the interaction or Pact can't be modified (i.e. the mock server for it has
|
|
2332
|
+
* already started), the interaction is not an HTTP interaction or some other error occurs.
|
|
1685
2333
|
*/
|
|
1686
2334
|
StringResult pactffi_with_multipart_file(InteractionHandle interaction,
|
|
1687
2335
|
InteractionPart part,
|
|
@@ -1723,6 +2371,23 @@ PactMessageIterator *pactffi_pact_handle_get_message_iter(PactHandle pact);
|
|
|
1723
2371
|
*/
|
|
1724
2372
|
PactSyncMessageIterator *pactffi_pact_handle_get_sync_message_iter(PactHandle pact);
|
|
1725
2373
|
|
|
2374
|
+
/**
|
|
2375
|
+
* Get an iterator over all the synchronous HTTP request/response interactions of the Pact.
|
|
2376
|
+
* The returned iterator needs to be freed with `pactffi_pact_sync_http_iter_delete`.
|
|
2377
|
+
*
|
|
2378
|
+
* # Safety
|
|
2379
|
+
*
|
|
2380
|
+
* The iterator contains a copy of the Pact, so it is always safe to use.
|
|
2381
|
+
*
|
|
2382
|
+
* # Error Handling
|
|
2383
|
+
*
|
|
2384
|
+
* On failure, this function will return a NULL pointer.
|
|
2385
|
+
*
|
|
2386
|
+
* This function may fail if any of the Rust strings contain embedded
|
|
2387
|
+
* null ('\0') bytes.
|
|
2388
|
+
*/
|
|
2389
|
+
PactSyncHttpIterator *pactffi_pact_handle_get_sync_http_iter(PactHandle pact);
|
|
2390
|
+
|
|
1726
2391
|
/**
|
|
1727
2392
|
* Creates a new Pact Message model and returns a handle to it.
|
|
1728
2393
|
*
|
|
@@ -1930,7 +2595,7 @@ int32_t pactffi_verify(const char *args);
|
|
|
1930
2595
|
* Get a Handle to a newly created verifier. You should call `pactffi_verifier_shutdown` when
|
|
1931
2596
|
* done with the verifier to free all allocated resources.
|
|
1932
2597
|
*
|
|
1933
|
-
* This function is deprecated. Use `pactffi_verifier_new_for_application` which allows the
|
|
2598
|
+
* Deprecated: This function is deprecated. Use `pactffi_verifier_new_for_application` which allows the
|
|
1934
2599
|
* calling application/framework name and version to be specified.
|
|
1935
2600
|
*
|
|
1936
2601
|
* # Safety
|
|
@@ -2029,6 +2694,19 @@ int pactffi_verifier_set_verification_options(VerifierHandle *handle,
|
|
|
2029
2694
|
unsigned char disable_ssl_verification,
|
|
2030
2695
|
unsigned long request_timeout);
|
|
2031
2696
|
|
|
2697
|
+
/**
|
|
2698
|
+
* Enables or disables coloured output using ANSI escape codes in the verifier output. By default,
|
|
2699
|
+
* coloured output is enabled.
|
|
2700
|
+
*
|
|
2701
|
+
* `coloured_output` is a boolean value. Set it to greater than zero to turn the option on.
|
|
2702
|
+
*
|
|
2703
|
+
* # Safety
|
|
2704
|
+
*
|
|
2705
|
+
* This function is safe as long as the handle pointer points to a valid handle.
|
|
2706
|
+
*
|
|
2707
|
+
*/
|
|
2708
|
+
int pactffi_verifier_set_coloured_output(VerifierHandle *handle, unsigned char coloured_output);
|
|
2709
|
+
|
|
2032
2710
|
/**
|
|
2033
2711
|
* Set the options used when publishing verification results to the Pact Broker
|
|
2034
2712
|
*
|
|
@@ -2282,12 +2960,13 @@ const char *pactffi_verifier_json(const VerifierHandle *handle);
|
|
|
2282
2960
|
* Returns zero on success, and a positive integer value on failure.
|
|
2283
2961
|
*
|
|
2284
2962
|
* Note that plugins run as separate processes, so will need to be cleaned up afterwards by
|
|
2285
|
-
* calling `pactffi_cleanup_plugins` otherwise you have plugin processes left running.
|
|
2963
|
+
* calling `pactffi_cleanup_plugins` otherwise you will have plugin processes left running.
|
|
2286
2964
|
*
|
|
2287
2965
|
* # Safety
|
|
2288
2966
|
*
|
|
2289
2967
|
* `plugin_name` must be a valid pointer to a NULL terminated string. `plugin_version` may be null,
|
|
2290
|
-
* and if not NULL must also be a valid pointer to a NULL terminated string.
|
|
2968
|
+
* and if not NULL must also be a valid pointer to a NULL terminated string. Invalid
|
|
2969
|
+
* pointers will result in undefined behaviour.
|
|
2291
2970
|
*
|
|
2292
2971
|
* # Errors
|
|
2293
2972
|
*
|
|
@@ -2321,7 +3000,8 @@ void pactffi_cleanup_plugins(PactHandle pact);
|
|
|
2321
3000
|
*
|
|
2322
3001
|
* # Safety
|
|
2323
3002
|
*
|
|
2324
|
-
* `content_type` and `contents` must be a valid pointers to NULL terminated strings.
|
|
3003
|
+
* `content_type` and `contents` must be a valid pointers to NULL terminated strings. Invalid
|
|
3004
|
+
* pointers will result in undefined behaviour.
|
|
2325
3005
|
*
|
|
2326
3006
|
* # Errors
|
|
2327
3007
|
*
|