@pact-foundation/pact-core 13.4.1-beta.2 → 13.4.1-beta.4
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/binding.gyp +4 -8
- package/build/Makefile +5 -5
- package/build/gyp-mac-tool +626 -464
- package/build/pact.target.mk +20 -20
- package/build/set_osx_install_name.target.mk +2 -1
- package/ffi/libpact_ffi.dylib +0 -0
- package/ffi/libpact_ffi.so +0 -0
- package/ffi/osxaarch64/libpact_ffi.dylib +0 -0
- package/ffi/pact.h +599 -108
- package/ffi/pact_ffi.dll +0 -0
- package/ffi/pact_ffi.dll.lib +0 -0
- package/native/consumer.cc +88 -32
- package/package.json +4 -4
- package/src/consumer/__testoutput__/foo-consumer-bar-provider.json +255 -0
- package/src/consumer/checkErrors.d.ts +7 -0
- package/src/consumer/checkErrors.js +41 -0
- package/src/consumer/checkErrors.js.map +1 -0
- package/src/consumer/index.d.ts +3 -0
- package/src/consumer/index.js +135 -0
- package/src/consumer/index.js.map +1 -0
- package/src/consumer/types.d.ts +110 -0
- package/src/consumer/types.js +3 -0
- package/src/consumer/types.js.map +1 -0
- package/src/ffi/index.d.ts +1 -0
- package/src/ffi/index.js +3 -0
- package/src/ffi/index.js.map +1 -1
- package/src/ffi/types.d.ts +27 -0
- package/src/ffi/types.js +42 -0
- package/src/ffi/types.js.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/logger/index.d.ts +5 -2
- package/src/logger/index.js +15 -2
- package/src/logger/index.js.map +1 -1
- package/ffi/libpact_ffi.so.gz +0 -0
- package/native/consumer.c +0 -210
- package/src/ffi/declarations.d.ts +0 -136
- package/src/ffi/declarations.js +0 -92
- package/src/ffi/declarations.js.map +0 -1
package/ffi/pact.h
CHANGED
|
@@ -128,6 +128,16 @@ typedef struct Mismatches Mismatches;
|
|
|
128
128
|
*/
|
|
129
129
|
typedef struct MismatchesIterator MismatchesIterator;
|
|
130
130
|
|
|
131
|
+
/**
|
|
132
|
+
* An iterator over messages in a pact.
|
|
133
|
+
*/
|
|
134
|
+
typedef struct PactMessageIterator PactMessageIterator;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* An iterator over synchronous request/response messages in a pact.
|
|
138
|
+
*/
|
|
139
|
+
typedef struct PactSyncMessageIterator PactSyncMessageIterator;
|
|
140
|
+
|
|
131
141
|
/**
|
|
132
142
|
* Struct that defines a provider of a pact.
|
|
133
143
|
*/
|
|
@@ -151,6 +161,11 @@ typedef struct ProviderStateIterator ProviderStateIterator;
|
|
|
151
161
|
*/
|
|
152
162
|
typedef struct ProviderStateParamIterator ProviderStateParamIterator;
|
|
153
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Synchronous interactions as a request message to a sequence of response messages
|
|
166
|
+
*/
|
|
167
|
+
typedef struct SynchronousMessage SynchronousMessage;
|
|
168
|
+
|
|
154
169
|
/**
|
|
155
170
|
* Wraps a Pact verifier
|
|
156
171
|
*/
|
|
@@ -205,26 +220,7 @@ typedef struct ProviderStateParamPair {
|
|
|
205
220
|
/**
|
|
206
221
|
* Wraps a Pact model struct
|
|
207
222
|
*/
|
|
208
|
-
typedef
|
|
209
|
-
/**
|
|
210
|
-
* Pact reference
|
|
211
|
-
*/
|
|
212
|
-
uintptr_t pact;
|
|
213
|
-
} PactHandle;
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Wraps a Pact model struct
|
|
217
|
-
*/
|
|
218
|
-
typedef struct InteractionHandle {
|
|
219
|
-
/**
|
|
220
|
-
* Pact reference
|
|
221
|
-
*/
|
|
222
|
-
uintptr_t pact;
|
|
223
|
-
/**
|
|
224
|
-
* Interaction reference
|
|
225
|
-
*/
|
|
226
|
-
uintptr_t interaction;
|
|
227
|
-
} InteractionHandle;
|
|
223
|
+
typedef uint16_t PactHandle;
|
|
228
224
|
|
|
229
225
|
/**
|
|
230
226
|
* Result of wrapping a string value
|
|
@@ -255,26 +251,17 @@ typedef struct StringResult {
|
|
|
255
251
|
/**
|
|
256
252
|
* Wraps a Pact model struct
|
|
257
253
|
*/
|
|
258
|
-
typedef
|
|
259
|
-
/**
|
|
260
|
-
* Pact reference
|
|
261
|
-
*/
|
|
262
|
-
uintptr_t pact;
|
|
263
|
-
} MessagePactHandle;
|
|
254
|
+
typedef uint32_t InteractionHandle;
|
|
264
255
|
|
|
265
256
|
/**
|
|
266
257
|
* Wraps a Pact model struct
|
|
267
258
|
*/
|
|
268
|
-
typedef
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
* Interaction reference
|
|
275
|
-
*/
|
|
276
|
-
uintptr_t message;
|
|
277
|
-
} MessageHandle;
|
|
259
|
+
typedef uint16_t MessagePactHandle;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Wraps a Pact model struct
|
|
263
|
+
*/
|
|
264
|
+
typedef uint32_t MessageHandle;
|
|
278
265
|
|
|
279
266
|
/**
|
|
280
267
|
* Get the current library version
|
|
@@ -597,7 +584,7 @@ struct Message *pactffi_message_new_from_body(const char *body, const char *cont
|
|
|
597
584
|
void pactffi_message_delete(struct Message *message);
|
|
598
585
|
|
|
599
586
|
/**
|
|
600
|
-
* Get the contents of a `Message
|
|
587
|
+
* Get the contents of a `Message` in string form.
|
|
601
588
|
*
|
|
602
589
|
* # Safety
|
|
603
590
|
*
|
|
@@ -614,6 +601,36 @@ void pactffi_message_delete(struct Message *message);
|
|
|
614
601
|
*/
|
|
615
602
|
const char *pactffi_message_get_contents(const struct Message *message);
|
|
616
603
|
|
|
604
|
+
/**
|
|
605
|
+
* Get the length of the contents of a `Message`.
|
|
606
|
+
*
|
|
607
|
+
* # Safety
|
|
608
|
+
*
|
|
609
|
+
* This function is safe.
|
|
610
|
+
*
|
|
611
|
+
* # Error Handling
|
|
612
|
+
*
|
|
613
|
+
* If the message is NULL, returns 0. If the body of the message
|
|
614
|
+
* is missing, then this function also returns 0.
|
|
615
|
+
*/
|
|
616
|
+
size_t pactffi_message_get_contents_length(const struct Message *message);
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Get the contents of a `Message` as a pointer to an array of bytes.
|
|
620
|
+
*
|
|
621
|
+
* # Safety
|
|
622
|
+
*
|
|
623
|
+
* The number of bytes in the buffer will be returned by `pactffi_message_get_contents_length`.
|
|
624
|
+
* It is safe to use the pointer while the message is not deleted or changed. Using the pointer
|
|
625
|
+
* after the message is mutated or deleted may lead to undefined behaviour.
|
|
626
|
+
*
|
|
627
|
+
* # Error Handling
|
|
628
|
+
*
|
|
629
|
+
* If the message is NULL, returns NULL. If the body of the message
|
|
630
|
+
* is missing, then this function also returns NULL.
|
|
631
|
+
*/
|
|
632
|
+
const unsigned char *pactffi_message_get_contents_bin(const struct Message *message);
|
|
633
|
+
|
|
617
634
|
/**
|
|
618
635
|
* Get a copy of the description.
|
|
619
636
|
*
|
|
@@ -690,6 +707,9 @@ struct ProviderStateIterator *pactffi_message_get_provider_state_iter(struct Mes
|
|
|
690
707
|
*
|
|
691
708
|
* The underlying data must not change during iteration.
|
|
692
709
|
*
|
|
710
|
+
* If a previous call panicked, then the internal mutex will have been poisoned and this
|
|
711
|
+
* function will return NULL.
|
|
712
|
+
*
|
|
693
713
|
* # Error Handling
|
|
694
714
|
*
|
|
695
715
|
* Returns NULL if an error occurs.
|
|
@@ -1045,6 +1065,238 @@ void pactffi_provider_state_param_iter_delete(struct ProviderStateParamIterator
|
|
|
1045
1065
|
*/
|
|
1046
1066
|
void pactffi_provider_state_param_pair_delete(struct ProviderStateParamPair *pair);
|
|
1047
1067
|
|
|
1068
|
+
/**
|
|
1069
|
+
* Free the iterator when you're done using it.
|
|
1070
|
+
*/
|
|
1071
|
+
void pactffi_pact_message_iter_delete(struct PactMessageIterator *iter);
|
|
1072
|
+
|
|
1073
|
+
/**
|
|
1074
|
+
* Get the next message from the message pact. As the messages returned are owned by the
|
|
1075
|
+
* iterator, they do not need to be deleted but will be cleaned up when the iterator is
|
|
1076
|
+
* deleted.
|
|
1077
|
+
*
|
|
1078
|
+
* # Safety
|
|
1079
|
+
*
|
|
1080
|
+
* This function is safe.
|
|
1081
|
+
*
|
|
1082
|
+
* Deleting a message returned by the iterator can lead to undefined behaviour.
|
|
1083
|
+
*
|
|
1084
|
+
* # Error Handling
|
|
1085
|
+
*
|
|
1086
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
1087
|
+
*/
|
|
1088
|
+
struct Message *pactffi_pact_message_iter_next(struct PactMessageIterator *iter);
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* Get the next synchronous request/response message from the pact. As the messages returned are owned by the
|
|
1092
|
+
* iterator, they do not need to be deleted but will be cleaned up when the iterator is
|
|
1093
|
+
* deleted.
|
|
1094
|
+
*
|
|
1095
|
+
* # Safety
|
|
1096
|
+
*
|
|
1097
|
+
* This function is safe.
|
|
1098
|
+
*
|
|
1099
|
+
* Deleting a message returned by the iterator can lead to undefined behaviour.
|
|
1100
|
+
*
|
|
1101
|
+
* # Error Handling
|
|
1102
|
+
*
|
|
1103
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
1104
|
+
*/
|
|
1105
|
+
struct SynchronousMessage *pactffi_pact_sync_message_iter_next(struct PactSyncMessageIterator *iter);
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* Free the iterator when you're done using it.
|
|
1109
|
+
*/
|
|
1110
|
+
void pactffi_pact_sync_message_iter_delete(struct PactSyncMessageIterator *iter);
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* Destroy the `Message` being pointed to.
|
|
1114
|
+
*/
|
|
1115
|
+
void pactffi_sync_message_delete(struct SynchronousMessage *message);
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* Get the request contents of a `SynchronousMessage` in string form.
|
|
1119
|
+
*
|
|
1120
|
+
* # Safety
|
|
1121
|
+
*
|
|
1122
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1123
|
+
*
|
|
1124
|
+
* The returned string can outlive the message.
|
|
1125
|
+
*
|
|
1126
|
+
* # Error Handling
|
|
1127
|
+
*
|
|
1128
|
+
* If the message is NULL, returns NULL. If the body of the request message
|
|
1129
|
+
* is missing, then this function also returns NULL. This means there's
|
|
1130
|
+
* no mechanism to differentiate with this function call alone between
|
|
1131
|
+
* a NULL message and a missing message body.
|
|
1132
|
+
*/
|
|
1133
|
+
const char *pactffi_sync_message_get_request_contents(const struct SynchronousMessage *message);
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* Get the length of the request contents of a `SynchronousMessage`.
|
|
1137
|
+
*
|
|
1138
|
+
* # Safety
|
|
1139
|
+
*
|
|
1140
|
+
* This function is safe.
|
|
1141
|
+
*
|
|
1142
|
+
* # Error Handling
|
|
1143
|
+
*
|
|
1144
|
+
* If the message is NULL, returns 0. If the body of the request
|
|
1145
|
+
* is missing, then this function also returns 0.
|
|
1146
|
+
*/
|
|
1147
|
+
size_t pactffi_sync_message_get_request_contents_length(const struct SynchronousMessage *message);
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Get the request contents of a `SynchronousMessage` as a pointer to an array of bytes.
|
|
1151
|
+
*
|
|
1152
|
+
* # Safety
|
|
1153
|
+
*
|
|
1154
|
+
* The number of bytes in the buffer will be returned by `pactffi_sync_message_get_request_contents_length`.
|
|
1155
|
+
* It is safe to use the pointer while the message is not deleted or changed. Using the pointer
|
|
1156
|
+
* after the message is mutated or deleted may lead to undefined behaviour.
|
|
1157
|
+
*
|
|
1158
|
+
* # Error Handling
|
|
1159
|
+
*
|
|
1160
|
+
* If the message is NULL, returns NULL. If the body of the message
|
|
1161
|
+
* is missing, then this function also returns NULL.
|
|
1162
|
+
*/
|
|
1163
|
+
const unsigned char *pactffi_sync_message_get_request_contents_bin(const struct SynchronousMessage *message);
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Get the number of response messages in the `SynchronousMessage`.
|
|
1167
|
+
*
|
|
1168
|
+
* # Safety
|
|
1169
|
+
*
|
|
1170
|
+
* The message pointer must point to a valid SynchronousMessage.
|
|
1171
|
+
*
|
|
1172
|
+
* # Error Handling
|
|
1173
|
+
*
|
|
1174
|
+
* If the message is NULL, returns 0.
|
|
1175
|
+
*/
|
|
1176
|
+
size_t pactffi_sync_message_get_number_responses(const struct SynchronousMessage *message);
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* Get the response contents of a `SynchronousMessage` in string form.
|
|
1180
|
+
*
|
|
1181
|
+
* # Safety
|
|
1182
|
+
*
|
|
1183
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1184
|
+
*
|
|
1185
|
+
* The returned string can outlive the message.
|
|
1186
|
+
*
|
|
1187
|
+
* # Error Handling
|
|
1188
|
+
*
|
|
1189
|
+
* If the message is NULL or the index is not valid, returns NULL.
|
|
1190
|
+
*
|
|
1191
|
+
* If the body of the response message is missing, then this function also returns NULL.
|
|
1192
|
+
* This means there's no mechanism to differentiate with this function call alone between
|
|
1193
|
+
* a NULL message and a missing message body.
|
|
1194
|
+
*/
|
|
1195
|
+
const char *pactffi_sync_message_get_response_contents(const struct SynchronousMessage *message,
|
|
1196
|
+
size_t index);
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* Get the length of the response contents of a `SynchronousMessage`.
|
|
1200
|
+
*
|
|
1201
|
+
* # Safety
|
|
1202
|
+
*
|
|
1203
|
+
* This function is safe.
|
|
1204
|
+
*
|
|
1205
|
+
* # Error Handling
|
|
1206
|
+
*
|
|
1207
|
+
* If the message is NULL or the index is not valid, returns 0. If the body of the request
|
|
1208
|
+
* is missing, then this function also returns 0.
|
|
1209
|
+
*/
|
|
1210
|
+
size_t pactffi_sync_message_get_response_contents_length(const struct SynchronousMessage *message,
|
|
1211
|
+
size_t index);
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* Get the response contents of a `SynchronousMessage` as a pointer to an array of bytes.
|
|
1215
|
+
*
|
|
1216
|
+
* # Safety
|
|
1217
|
+
*
|
|
1218
|
+
* The number of bytes in the buffer will be returned by `pactffi_sync_message_get_response_contents_length`.
|
|
1219
|
+
* It is safe to use the pointer while the message is not deleted or changed. Using the pointer
|
|
1220
|
+
* after the message is mutated or deleted may lead to undefined behaviour.
|
|
1221
|
+
*
|
|
1222
|
+
* # Error Handling
|
|
1223
|
+
*
|
|
1224
|
+
* If the message is NULL or the index is not valid, returns NULL. If the body of the message
|
|
1225
|
+
* is missing, then this function also returns NULL.
|
|
1226
|
+
*/
|
|
1227
|
+
const unsigned char *pactffi_sync_message_get_response_contents_bin(const struct SynchronousMessage *message,
|
|
1228
|
+
size_t index);
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* Get a copy of the description.
|
|
1232
|
+
*
|
|
1233
|
+
* # Safety
|
|
1234
|
+
*
|
|
1235
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1236
|
+
*
|
|
1237
|
+
* Since it is a copy, the returned string may safely outlive
|
|
1238
|
+
* the `SynchronousMessage`.
|
|
1239
|
+
*
|
|
1240
|
+
* # Errors
|
|
1241
|
+
*
|
|
1242
|
+
* On failure, this function will return a NULL pointer.
|
|
1243
|
+
*
|
|
1244
|
+
* This function may fail if the Rust string contains embedded
|
|
1245
|
+
* null ('\0') bytes.
|
|
1246
|
+
*/
|
|
1247
|
+
const char *pactffi_sync_message_get_description(const struct SynchronousMessage *message);
|
|
1248
|
+
|
|
1249
|
+
/**
|
|
1250
|
+
* Write the `description` field on the `SynchronousMessage`.
|
|
1251
|
+
*
|
|
1252
|
+
* # Safety
|
|
1253
|
+
*
|
|
1254
|
+
* `description` must contain valid UTF-8. Invalid UTF-8
|
|
1255
|
+
* will be replaced with U+FFFD REPLACEMENT CHARACTER.
|
|
1256
|
+
*
|
|
1257
|
+
* This function will only reallocate if the new string
|
|
1258
|
+
* does not fit in the existing buffer.
|
|
1259
|
+
*
|
|
1260
|
+
* # Error Handling
|
|
1261
|
+
*
|
|
1262
|
+
* Errors will be reported with a non-zero return value.
|
|
1263
|
+
*/
|
|
1264
|
+
int pactffi_sync_message_set_description(struct SynchronousMessage *message,
|
|
1265
|
+
const char *description);
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* Get a copy of the provider state at the given index from this message.
|
|
1269
|
+
*
|
|
1270
|
+
* # Safety
|
|
1271
|
+
*
|
|
1272
|
+
* The returned structure must be deleted with `provider_state_delete`.
|
|
1273
|
+
*
|
|
1274
|
+
* Since it is a copy, the returned structure may safely outlive
|
|
1275
|
+
* the `SynchronousMessage`.
|
|
1276
|
+
*
|
|
1277
|
+
* # Error Handling
|
|
1278
|
+
*
|
|
1279
|
+
* On failure, this function will return a variant other than Success.
|
|
1280
|
+
*
|
|
1281
|
+
* This function may fail if the index requested is out of bounds,
|
|
1282
|
+
* or if any of the Rust strings contain embedded null ('\0') bytes.
|
|
1283
|
+
*/
|
|
1284
|
+
const struct ProviderState *pactffi_sync_message_get_provider_state(const struct SynchronousMessage *message,
|
|
1285
|
+
unsigned int index);
|
|
1286
|
+
|
|
1287
|
+
/**
|
|
1288
|
+
* Get an iterator over provider states.
|
|
1289
|
+
*
|
|
1290
|
+
* # Safety
|
|
1291
|
+
*
|
|
1292
|
+
* The underlying data must not change during iteration.
|
|
1293
|
+
*
|
|
1294
|
+
* # Error Handling
|
|
1295
|
+
*
|
|
1296
|
+
* Returns NULL if an error occurs.
|
|
1297
|
+
*/
|
|
1298
|
+
struct ProviderStateIterator *pactffi_sync_message_get_provider_state_iter(struct SynchronousMessage *message);
|
|
1299
|
+
|
|
1048
1300
|
/**
|
|
1049
1301
|
* Delete a string previously returned by this FFI.
|
|
1050
1302
|
*
|
|
@@ -1114,7 +1366,7 @@ char *pactffi_get_tls_ca_certificate(void);
|
|
|
1114
1366
|
* | -6 | Could not create the TLS configuration with the self-signed certificate |
|
|
1115
1367
|
*
|
|
1116
1368
|
*/
|
|
1117
|
-
int32_t pactffi_create_mock_server_for_pact(
|
|
1369
|
+
int32_t pactffi_create_mock_server_for_pact(PactHandle pact,
|
|
1118
1370
|
const char *addr_str,
|
|
1119
1371
|
bool tls);
|
|
1120
1372
|
|
|
@@ -1182,24 +1434,81 @@ int32_t pactffi_write_pact_file(int32_t mock_server_port, const char *directory,
|
|
|
1182
1434
|
*/
|
|
1183
1435
|
const char *pactffi_mock_server_logs(int32_t mock_server_port);
|
|
1184
1436
|
|
|
1437
|
+
/**
|
|
1438
|
+
* Generates a datetime value from the provided format string, using the current system date and time
|
|
1439
|
+
* NOTE: The memory for the returned string needs to be freed with the free_string function
|
|
1440
|
+
*
|
|
1441
|
+
* # Safety
|
|
1442
|
+
*
|
|
1443
|
+
* Exported functions are inherently unsafe.
|
|
1444
|
+
*/
|
|
1445
|
+
struct StringResult pactffi_generate_datetime_string(const char *format);
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* Checks that the example string matches the given regex
|
|
1449
|
+
*
|
|
1450
|
+
* # Safety
|
|
1451
|
+
*
|
|
1452
|
+
* Exported functions are inherently unsafe.
|
|
1453
|
+
*/
|
|
1454
|
+
bool pactffi_check_regex(const char *regex, const char *example);
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* Generates an example string based on the provided regex.
|
|
1458
|
+
* NOTE: The memory for the returned string needs to be freed with the free_string function
|
|
1459
|
+
*
|
|
1460
|
+
* # Safety
|
|
1461
|
+
*
|
|
1462
|
+
* Exported functions are inherently unsafe.
|
|
1463
|
+
*/
|
|
1464
|
+
struct StringResult pactffi_generate_regex_value(const char *regex);
|
|
1465
|
+
|
|
1466
|
+
/**
|
|
1467
|
+
* [DEPRECATED] Frees the memory allocated to a string by another function
|
|
1468
|
+
*
|
|
1469
|
+
* This function is deprecated. Use pactffi_string_delete instead.
|
|
1470
|
+
*
|
|
1471
|
+
* # Safety
|
|
1472
|
+
*
|
|
1473
|
+
* Exported functions are inherently unsafe.
|
|
1474
|
+
*/
|
|
1475
|
+
void pactffi_free_string(char *s);
|
|
1476
|
+
|
|
1185
1477
|
/**
|
|
1186
1478
|
* Creates a new Pact model and returns a handle to it.
|
|
1187
1479
|
*
|
|
1188
1480
|
* * `consumer_name` - The name of the consumer for the pact.
|
|
1189
1481
|
* * `provider_name` - The name of the provider for the pact.
|
|
1190
1482
|
*
|
|
1191
|
-
* Returns a new `PactHandle`.
|
|
1483
|
+
* Returns a new `PactHandle`. The handle will need to be freed with the `pactffi_free_pact_handle`
|
|
1484
|
+
* method to release its resources.
|
|
1485
|
+
*/
|
|
1486
|
+
PactHandle pactffi_new_pact(const char *consumer_name, const char *provider_name);
|
|
1487
|
+
|
|
1488
|
+
/**
|
|
1489
|
+
* Creates a new HTTP Interaction and returns a handle to it.
|
|
1490
|
+
*
|
|
1491
|
+
* * `description` - The interaction description. It needs to be unique for each interaction.
|
|
1492
|
+
*
|
|
1493
|
+
* Returns a new `InteractionHandle`.
|
|
1192
1494
|
*/
|
|
1193
|
-
|
|
1495
|
+
InteractionHandle pactffi_new_interaction(PactHandle pact, const char *description);
|
|
1194
1496
|
|
|
1195
1497
|
/**
|
|
1196
|
-
* Creates a new
|
|
1498
|
+
* Creates a new message interaction and return a handle to it
|
|
1499
|
+
* * `description` - The interaction description. It needs to be unique for each interaction.
|
|
1197
1500
|
*
|
|
1501
|
+
* Returns a new `InteractionHandle`.
|
|
1502
|
+
*/
|
|
1503
|
+
InteractionHandle pactffi_new_message_interaction(PactHandle pact, const char *description);
|
|
1504
|
+
|
|
1505
|
+
/**
|
|
1506
|
+
* Creates a new synchronous message interaction (request/response) and return a handle to it
|
|
1198
1507
|
* * `description` - The interaction description. It needs to be unique for each interaction.
|
|
1199
1508
|
*
|
|
1200
1509
|
* Returns a new `InteractionHandle`.
|
|
1201
1510
|
*/
|
|
1202
|
-
|
|
1511
|
+
InteractionHandle pactffi_new_sync_message_interaction(PactHandle pact, const char *description);
|
|
1203
1512
|
|
|
1204
1513
|
/**
|
|
1205
1514
|
* Sets the description for the Interaction. Returns false if the interaction or Pact can't be
|
|
@@ -1207,7 +1516,7 @@ struct InteractionHandle pactffi_new_interaction(struct PactHandle pact, const c
|
|
|
1207
1516
|
*
|
|
1208
1517
|
* * `description` - The interaction description. It needs to be unique for each interaction.
|
|
1209
1518
|
*/
|
|
1210
|
-
bool pactffi_upon_receiving(
|
|
1519
|
+
bool pactffi_upon_receiving(InteractionHandle interaction, const char *description);
|
|
1211
1520
|
|
|
1212
1521
|
/**
|
|
1213
1522
|
* Adds a provider state to the Interaction. Returns false if the interaction or Pact can't be
|
|
@@ -1215,7 +1524,27 @@ bool pactffi_upon_receiving(struct InteractionHandle interaction, const char *de
|
|
|
1215
1524
|
*
|
|
1216
1525
|
* * `description` - The provider state description. It needs to be unique.
|
|
1217
1526
|
*/
|
|
1218
|
-
bool pactffi_given(
|
|
1527
|
+
bool pactffi_given(InteractionHandle interaction, const char *description);
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* Sets the test name annotation for the interaction. This allows capturing the name of
|
|
1531
|
+
* the test as metadata. This can only be used with V4 interactions.
|
|
1532
|
+
*
|
|
1533
|
+
* # Safety
|
|
1534
|
+
*
|
|
1535
|
+
* The test name parameter must be a valid pointer to a NULL terminated string.
|
|
1536
|
+
*
|
|
1537
|
+
* # Error Handling
|
|
1538
|
+
*
|
|
1539
|
+
* If the test name can not be set, this will return a positive value.
|
|
1540
|
+
*
|
|
1541
|
+
* * `1` - Function panicked. Error message will be available by calling `pactffi_get_error_message`.
|
|
1542
|
+
* * `2` - Handle was not valid.
|
|
1543
|
+
* * `3` - Mock server was already started and the interation can not be modified.
|
|
1544
|
+
* * `4` - Not a V4 interaction.
|
|
1545
|
+
*/
|
|
1546
|
+
unsigned int pactffi_interaction_test_name(InteractionHandle interaction,
|
|
1547
|
+
const char *test_name);
|
|
1219
1548
|
|
|
1220
1549
|
/**
|
|
1221
1550
|
* Adds a provider state to the Interaction with a parameter key and value. Returns false if the interaction or Pact can't be
|
|
@@ -1225,7 +1554,7 @@ bool pactffi_given(struct InteractionHandle interaction, const char *description
|
|
|
1225
1554
|
* * `name` - Parameter name.
|
|
1226
1555
|
* * `value` - Parameter value.
|
|
1227
1556
|
*/
|
|
1228
|
-
bool pactffi_given_with_param(
|
|
1557
|
+
bool pactffi_given_with_param(InteractionHandle interaction,
|
|
1229
1558
|
const char *description,
|
|
1230
1559
|
const char *name,
|
|
1231
1560
|
const char *value);
|
|
@@ -1237,9 +1566,7 @@ bool pactffi_given_with_param(struct InteractionHandle interaction,
|
|
|
1237
1566
|
* * `method` - The request method. Defaults to GET.
|
|
1238
1567
|
* * `path` - The request path. Defaults to `/`.
|
|
1239
1568
|
*/
|
|
1240
|
-
bool pactffi_with_request(
|
|
1241
|
-
const char *method,
|
|
1242
|
-
const char *path);
|
|
1569
|
+
bool pactffi_with_request(InteractionHandle interaction, const char *method, const char *path);
|
|
1243
1570
|
|
|
1244
1571
|
/**
|
|
1245
1572
|
* Configures a query parameter for the Interaction. Returns false if the interaction or Pact can't be
|
|
@@ -1249,7 +1576,7 @@ bool pactffi_with_request(struct InteractionHandle interaction,
|
|
|
1249
1576
|
* * `value` - the query parameter value.
|
|
1250
1577
|
* * `index` - the index of the value (starts at 0). You can use this to create a query parameter with multiple values
|
|
1251
1578
|
*/
|
|
1252
|
-
bool pactffi_with_query_parameter(
|
|
1579
|
+
bool pactffi_with_query_parameter(InteractionHandle interaction,
|
|
1253
1580
|
const char *name,
|
|
1254
1581
|
size_t index,
|
|
1255
1582
|
const char *value);
|
|
@@ -1261,7 +1588,7 @@ bool pactffi_with_query_parameter(struct InteractionHandle interaction,
|
|
|
1261
1588
|
* * `pact` - Handle to a Pact model
|
|
1262
1589
|
* * `version` - the spec version to use
|
|
1263
1590
|
*/
|
|
1264
|
-
bool pactffi_with_specification(
|
|
1591
|
+
bool pactffi_with_specification(PactHandle pact,
|
|
1265
1592
|
enum PactSpecification version);
|
|
1266
1593
|
|
|
1267
1594
|
/**
|
|
@@ -1273,7 +1600,7 @@ bool pactffi_with_specification(struct PactHandle pact,
|
|
|
1273
1600
|
* * `name` - the key to set
|
|
1274
1601
|
* * `value` - the value to set
|
|
1275
1602
|
*/
|
|
1276
|
-
bool pactffi_with_pact_metadata(
|
|
1603
|
+
bool pactffi_with_pact_metadata(PactHandle pact,
|
|
1277
1604
|
const char *namespace_,
|
|
1278
1605
|
const char *name,
|
|
1279
1606
|
const char *value);
|
|
@@ -1287,7 +1614,7 @@ bool pactffi_with_pact_metadata(struct PactHandle pact,
|
|
|
1287
1614
|
* * `value` - the header value.
|
|
1288
1615
|
* * `index` - the index of the value (starts at 0). You can use this to create a header with multiple values
|
|
1289
1616
|
*/
|
|
1290
|
-
bool pactffi_with_header(
|
|
1617
|
+
bool pactffi_with_header(InteractionHandle interaction,
|
|
1291
1618
|
enum InteractionPart part,
|
|
1292
1619
|
const char *name,
|
|
1293
1620
|
size_t index,
|
|
@@ -1299,7 +1626,7 @@ bool pactffi_with_header(struct InteractionHandle interaction,
|
|
|
1299
1626
|
*
|
|
1300
1627
|
* * `status` - the response status. Defaults to 200.
|
|
1301
1628
|
*/
|
|
1302
|
-
bool pactffi_response_status(
|
|
1629
|
+
bool pactffi_response_status(InteractionHandle interaction, unsigned short status);
|
|
1303
1630
|
|
|
1304
1631
|
/**
|
|
1305
1632
|
* Adds the body for the interaction. Returns false if the interaction or Pact can't be
|
|
@@ -1310,49 +1637,11 @@ bool pactffi_response_status(struct InteractionHandle interaction, unsigned shor
|
|
|
1310
1637
|
* header is already set.
|
|
1311
1638
|
* * `body` - The body contents. For JSON payloads, matching rules can be embedded in the body.
|
|
1312
1639
|
*/
|
|
1313
|
-
bool pactffi_with_body(
|
|
1640
|
+
bool pactffi_with_body(InteractionHandle interaction,
|
|
1314
1641
|
enum InteractionPart part,
|
|
1315
1642
|
const char *content_type,
|
|
1316
1643
|
const char *body);
|
|
1317
1644
|
|
|
1318
|
-
/**
|
|
1319
|
-
* Generates a datetime value from the provided format string, using the current system date and time
|
|
1320
|
-
* NOTE: The memory for the returned string needs to be freed with the free_string function
|
|
1321
|
-
*
|
|
1322
|
-
* # Safety
|
|
1323
|
-
*
|
|
1324
|
-
* Exported functions are inherently unsafe.
|
|
1325
|
-
*/
|
|
1326
|
-
struct StringResult pactffi_generate_datetime_string(const char *format);
|
|
1327
|
-
|
|
1328
|
-
/**
|
|
1329
|
-
* Checks that the example string matches the given regex
|
|
1330
|
-
*
|
|
1331
|
-
* # Safety
|
|
1332
|
-
*
|
|
1333
|
-
* Exported functions are inherently unsafe.
|
|
1334
|
-
*/
|
|
1335
|
-
bool pactffi_check_regex(const char *regex, const char *example);
|
|
1336
|
-
|
|
1337
|
-
/**
|
|
1338
|
-
* Generates an example string based on the provided regex.
|
|
1339
|
-
* NOTE: The memory for the returned string needs to be freed with the free_string function
|
|
1340
|
-
*
|
|
1341
|
-
* # Safety
|
|
1342
|
-
*
|
|
1343
|
-
* Exported functions are inherently unsafe.
|
|
1344
|
-
*/
|
|
1345
|
-
struct StringResult pactffi_generate_regex_value(const char *regex);
|
|
1346
|
-
|
|
1347
|
-
/**
|
|
1348
|
-
* Frees the memory allocated to a string by another function
|
|
1349
|
-
*
|
|
1350
|
-
* # Safety
|
|
1351
|
-
*
|
|
1352
|
-
* Exported functions are inherently unsafe.
|
|
1353
|
-
*/
|
|
1354
|
-
void pactffi_free_string(char *s);
|
|
1355
|
-
|
|
1356
1645
|
/**
|
|
1357
1646
|
* Adds a binary file as the body with the expected content type and example contents. Will use
|
|
1358
1647
|
* a mime type matcher to match the body. Returns false if the interaction or Pact can't be
|
|
@@ -1364,7 +1653,7 @@ void pactffi_free_string(char *s);
|
|
|
1364
1653
|
* * `body` - example body contents in bytes
|
|
1365
1654
|
* * `size` - number of bytes in the body
|
|
1366
1655
|
*/
|
|
1367
|
-
bool pactffi_with_binary_file(
|
|
1656
|
+
bool pactffi_with_binary_file(InteractionHandle interaction,
|
|
1368
1657
|
enum InteractionPart part,
|
|
1369
1658
|
const char *content_type,
|
|
1370
1659
|
const uint8_t *body,
|
|
@@ -1381,22 +1670,57 @@ bool pactffi_with_binary_file(struct InteractionHandle interaction,
|
|
|
1381
1670
|
* * `file` - path to the example file
|
|
1382
1671
|
* * `part_name` - name for the mime part
|
|
1383
1672
|
*/
|
|
1384
|
-
struct StringResult pactffi_with_multipart_file(
|
|
1673
|
+
struct StringResult pactffi_with_multipart_file(InteractionHandle interaction,
|
|
1385
1674
|
enum InteractionPart part,
|
|
1386
1675
|
const char *content_type,
|
|
1387
1676
|
const char *file,
|
|
1388
1677
|
const char *part_name);
|
|
1389
1678
|
|
|
1679
|
+
/**
|
|
1680
|
+
* Get an iterator over all the messages of the Pact. The returned iterator needs to be
|
|
1681
|
+
* freed with `pactffi_pact_message_iter_delete`.
|
|
1682
|
+
*
|
|
1683
|
+
* # Safety
|
|
1684
|
+
*
|
|
1685
|
+
* The iterator contains a copy of the Pact, so it is always safe to use.
|
|
1686
|
+
*
|
|
1687
|
+
* # Error Handling
|
|
1688
|
+
*
|
|
1689
|
+
* On failure, this function will return a NULL pointer.
|
|
1690
|
+
*
|
|
1691
|
+
* This function may fail if any of the Rust strings contain embedded
|
|
1692
|
+
* null ('\0') bytes.
|
|
1693
|
+
*/
|
|
1694
|
+
struct PactMessageIterator *pactffi_pact_handle_get_message_iter(PactHandle pact);
|
|
1695
|
+
|
|
1696
|
+
/**
|
|
1697
|
+
* Get an iterator over all the synchronous request/response messages of the Pact.
|
|
1698
|
+
* The returned iterator needs to be freed with `pactffi_pact_sync_message_iter_delete`.
|
|
1699
|
+
*
|
|
1700
|
+
* # Safety
|
|
1701
|
+
*
|
|
1702
|
+
* The iterator contains a copy of the Pact, so it is always safe to use.
|
|
1703
|
+
*
|
|
1704
|
+
* # Error Handling
|
|
1705
|
+
*
|
|
1706
|
+
* On failure, this function will return a NULL pointer.
|
|
1707
|
+
*
|
|
1708
|
+
* This function may fail if any of the Rust strings contain embedded
|
|
1709
|
+
* null ('\0') bytes.
|
|
1710
|
+
*/
|
|
1711
|
+
struct PactSyncMessageIterator *pactffi_pact_handle_get_sync_message_iter(PactHandle pact);
|
|
1712
|
+
|
|
1390
1713
|
/**
|
|
1391
1714
|
* Creates a new Pact Message model and returns a handle to it.
|
|
1392
1715
|
*
|
|
1393
1716
|
* * `consumer_name` - The name of the consumer for the pact.
|
|
1394
1717
|
* * `provider_name` - The name of the provider for the pact.
|
|
1395
1718
|
*
|
|
1396
|
-
* Returns a new `MessagePactHandle`.
|
|
1719
|
+
* Returns a new `MessagePactHandle`. The handle will need to be freed with the `pactffi_free_message_pact_handle`
|
|
1720
|
+
* function to release its resources.
|
|
1397
1721
|
*/
|
|
1398
|
-
|
|
1399
|
-
|
|
1722
|
+
MessagePactHandle pactffi_new_message_pact(const char *consumer_name,
|
|
1723
|
+
const char *provider_name);
|
|
1400
1724
|
|
|
1401
1725
|
/**
|
|
1402
1726
|
* Creates a new Message and returns a handle to it.
|
|
@@ -1405,21 +1729,21 @@ struct MessagePactHandle pactffi_new_message_pact(const char *consumer_name,
|
|
|
1405
1729
|
*
|
|
1406
1730
|
* Returns a new `MessageHandle`.
|
|
1407
1731
|
*/
|
|
1408
|
-
|
|
1732
|
+
MessageHandle pactffi_new_message(MessagePactHandle pact, const char *description);
|
|
1409
1733
|
|
|
1410
1734
|
/**
|
|
1411
1735
|
* Sets the description for the Message.
|
|
1412
1736
|
*
|
|
1413
1737
|
* * `description` - The message description. It needs to be unique for each message.
|
|
1414
1738
|
*/
|
|
1415
|
-
void pactffi_message_expects_to_receive(
|
|
1739
|
+
void pactffi_message_expects_to_receive(MessageHandle message, const char *description);
|
|
1416
1740
|
|
|
1417
1741
|
/**
|
|
1418
1742
|
* Adds a provider state to the Interaction.
|
|
1419
1743
|
*
|
|
1420
1744
|
* * `description` - The provider state description. It needs to be unique for each message
|
|
1421
1745
|
*/
|
|
1422
|
-
void pactffi_message_given(
|
|
1746
|
+
void pactffi_message_given(MessageHandle message, const char *description);
|
|
1423
1747
|
|
|
1424
1748
|
/**
|
|
1425
1749
|
* Adds a provider state to the Message with a parameter key and value.
|
|
@@ -1428,7 +1752,7 @@ void pactffi_message_given(struct MessageHandle message, const char *description
|
|
|
1428
1752
|
* * `name` - Parameter name.
|
|
1429
1753
|
* * `value` - Parameter value.
|
|
1430
1754
|
*/
|
|
1431
|
-
void pactffi_message_given_with_param(
|
|
1755
|
+
void pactffi_message_given_with_param(MessageHandle message,
|
|
1432
1756
|
const char *description,
|
|
1433
1757
|
const char *name,
|
|
1434
1758
|
const char *value);
|
|
@@ -1447,7 +1771,7 @@ void pactffi_message_given_with_param(struct MessageHandle message,
|
|
|
1447
1771
|
* * `content_type` - Expected content type (e.g. application/json, application/octet-stream)
|
|
1448
1772
|
* * `size` - number of bytes in the message body to read. This is not required for text bodies (JSON, XML, etc.).
|
|
1449
1773
|
*/
|
|
1450
|
-
void pactffi_message_with_contents(
|
|
1774
|
+
void pactffi_message_with_contents(MessageHandle message_handle,
|
|
1451
1775
|
const char *content_type,
|
|
1452
1776
|
const uint8_t *body,
|
|
1453
1777
|
size_t size);
|
|
@@ -1458,7 +1782,7 @@ void pactffi_message_with_contents(struct MessageHandle message,
|
|
|
1458
1782
|
* * `key` - metadata key
|
|
1459
1783
|
* * `value` - metadata value.
|
|
1460
1784
|
*/
|
|
1461
|
-
void pactffi_message_with_metadata(
|
|
1785
|
+
void pactffi_message_with_metadata(MessageHandle message_handle,
|
|
1462
1786
|
const char *key,
|
|
1463
1787
|
const char *value);
|
|
1464
1788
|
|
|
@@ -1468,7 +1792,7 @@ void pactffi_message_with_metadata(struct MessageHandle message,
|
|
|
1468
1792
|
* Reification is the process of stripping away any matchers, and returning the original contents.
|
|
1469
1793
|
* NOTE: the returned string needs to be deallocated with the `free_string` function
|
|
1470
1794
|
*/
|
|
1471
|
-
const char *pactffi_message_reify(
|
|
1795
|
+
const char *pactffi_message_reify(MessageHandle message_handle);
|
|
1472
1796
|
|
|
1473
1797
|
/**
|
|
1474
1798
|
* External interface to write out the message pact file. This function should
|
|
@@ -1490,7 +1814,7 @@ const char *pactffi_message_reify(struct MessageHandle message);
|
|
|
1490
1814
|
* | 1 | The pact file was not able to be written |
|
|
1491
1815
|
* | 2 | The message pact for the given handle was not found |
|
|
1492
1816
|
*/
|
|
1493
|
-
int32_t pactffi_write_message_pact_file(
|
|
1817
|
+
int32_t pactffi_write_message_pact_file(MessagePactHandle pact,
|
|
1494
1818
|
const char *directory,
|
|
1495
1819
|
bool overwrite);
|
|
1496
1820
|
|
|
@@ -1502,11 +1826,71 @@ int32_t pactffi_write_message_pact_file(struct MessagePactHandle pact,
|
|
|
1502
1826
|
* * `name` - the key to set
|
|
1503
1827
|
* * `value` - the value to set
|
|
1504
1828
|
*/
|
|
1505
|
-
void pactffi_with_message_pact_metadata(
|
|
1829
|
+
void pactffi_with_message_pact_metadata(MessagePactHandle pact,
|
|
1506
1830
|
const char *namespace_,
|
|
1507
1831
|
const char *name,
|
|
1508
1832
|
const char *value);
|
|
1509
1833
|
|
|
1834
|
+
/**
|
|
1835
|
+
* External interface to write out the pact file. This function should
|
|
1836
|
+
* be called if all the consumer tests have passed. The directory to write the file to is passed
|
|
1837
|
+
* as the second parameter. If a NULL pointer is passed, the current working directory is used.
|
|
1838
|
+
*
|
|
1839
|
+
* If overwrite is true, the file will be overwritten with the contents of the current pact.
|
|
1840
|
+
* Otherwise, it will be merged with any existing pact file.
|
|
1841
|
+
*
|
|
1842
|
+
* Returns 0 if the pact file was successfully written. Returns a positive code if the file can
|
|
1843
|
+
* not be written or the function panics.
|
|
1844
|
+
*
|
|
1845
|
+
* # Safety
|
|
1846
|
+
*
|
|
1847
|
+
* The directory parameter must either be NULL or point to a valid NULL terminated string.
|
|
1848
|
+
*
|
|
1849
|
+
* # Errors
|
|
1850
|
+
*
|
|
1851
|
+
* Errors are returned as positive values.
|
|
1852
|
+
*
|
|
1853
|
+
* | Error | Description |
|
|
1854
|
+
* |-------|-------------|
|
|
1855
|
+
* | 1 | The function panicked. |
|
|
1856
|
+
* | 2 | The pact file was not able to be written. |
|
|
1857
|
+
* | 3 | The pact for the given handle was not found. |
|
|
1858
|
+
*/
|
|
1859
|
+
int32_t pactffi_pact_handle_write_file(PactHandle pact, const char *directory, bool overwrite);
|
|
1860
|
+
|
|
1861
|
+
/**
|
|
1862
|
+
* Creates a new V4 asynchronous message and returns a handle to it.
|
|
1863
|
+
*
|
|
1864
|
+
* * `description` - The message description. It needs to be unique for each Message.
|
|
1865
|
+
*
|
|
1866
|
+
* Returns a new `MessageHandle`.
|
|
1867
|
+
*/
|
|
1868
|
+
MessageHandle pactffi_new_async_message(PactHandle pact, const char *description);
|
|
1869
|
+
|
|
1870
|
+
/**
|
|
1871
|
+
* Delete a Pact handle and free the resources used by it.
|
|
1872
|
+
*
|
|
1873
|
+
* # Error Handling
|
|
1874
|
+
*
|
|
1875
|
+
* On failure, this function will return a positive integer value.
|
|
1876
|
+
*
|
|
1877
|
+
* * `1` - The handle is not valid or does not refer to a valid Pact. Could be that it was previously deleted.
|
|
1878
|
+
*
|
|
1879
|
+
*/
|
|
1880
|
+
unsigned int pactffi_free_pact_handle(PactHandle pact);
|
|
1881
|
+
|
|
1882
|
+
/**
|
|
1883
|
+
* Delete a Pact handle and free the resources used by it.
|
|
1884
|
+
*
|
|
1885
|
+
* # Error Handling
|
|
1886
|
+
*
|
|
1887
|
+
* On failure, this function will return a positive integer value.
|
|
1888
|
+
*
|
|
1889
|
+
* * `1` - The handle is not valid or does not refer to a valid Pact. Could be that it was previously deleted.
|
|
1890
|
+
*
|
|
1891
|
+
*/
|
|
1892
|
+
unsigned int pactffi_free_message_pact_handle(MessagePactHandle pact);
|
|
1893
|
+
|
|
1510
1894
|
/**
|
|
1511
1895
|
* External interface to verifier a provider
|
|
1512
1896
|
*
|
|
@@ -1531,7 +1915,10 @@ int32_t pactffi_verify(const char *args);
|
|
|
1531
1915
|
|
|
1532
1916
|
/**
|
|
1533
1917
|
* Get a Handle to a newly created verifier. You should call `pactffi_verifier_shutdown` when
|
|
1534
|
-
* done with the verifier to free all allocated resources
|
|
1918
|
+
* done with the verifier to free all allocated resources.
|
|
1919
|
+
*
|
|
1920
|
+
* This function is deprecated. Use `pactffi_verifier_new_for_application` which allows the
|
|
1921
|
+
* calling application/framework name and version to be specified.
|
|
1535
1922
|
*
|
|
1536
1923
|
* # Safety
|
|
1537
1924
|
*
|
|
@@ -1543,6 +1930,20 @@ int32_t pactffi_verify(const char *args);
|
|
|
1543
1930
|
*/
|
|
1544
1931
|
struct VerifierHandle *pactffi_verifier_new(void);
|
|
1545
1932
|
|
|
1933
|
+
/**
|
|
1934
|
+
* Get a Handle to a newly created verifier. You should call `pactffi_verifier_shutdown` when
|
|
1935
|
+
* done with the verifier to free all allocated resources
|
|
1936
|
+
*
|
|
1937
|
+
* # Safety
|
|
1938
|
+
*
|
|
1939
|
+
* This function is safe.
|
|
1940
|
+
*
|
|
1941
|
+
* # Error Handling
|
|
1942
|
+
*
|
|
1943
|
+
* Returns NULL on error.
|
|
1944
|
+
*/
|
|
1945
|
+
struct VerifierHandle *pactffi_verifier_new_for_application(const char *name, const char *scheme);
|
|
1946
|
+
|
|
1546
1947
|
/**
|
|
1547
1948
|
* Shutdown the verifier and release all resources
|
|
1548
1949
|
*/
|
|
@@ -1565,6 +1966,24 @@ void pactffi_verifier_set_provider_info(struct VerifierHandle *handle,
|
|
|
1565
1966
|
unsigned short port,
|
|
1566
1967
|
const char *path);
|
|
1567
1968
|
|
|
1969
|
+
/**
|
|
1970
|
+
* Set the filters for the Pact verifier.
|
|
1971
|
+
*
|
|
1972
|
+
* If `filter_description` is not empty, it needs to be as a regular expression.
|
|
1973
|
+
*
|
|
1974
|
+
* `filter_no_state` is a boolean value. Set it to greater than zero to turn the option on.
|
|
1975
|
+
*
|
|
1976
|
+
* # Safety
|
|
1977
|
+
*
|
|
1978
|
+
* All string fields must contain valid UTF-8. Invalid UTF-8
|
|
1979
|
+
* will be replaced with U+FFFD REPLACEMENT CHARACTER.
|
|
1980
|
+
*
|
|
1981
|
+
*/
|
|
1982
|
+
void pactffi_verifier_set_filter_info(struct VerifierHandle *handle,
|
|
1983
|
+
const char *filter_description,
|
|
1984
|
+
const char *filter_state,
|
|
1985
|
+
unsigned char filter_no_state);
|
|
1986
|
+
|
|
1568
1987
|
/**
|
|
1569
1988
|
* Set the provider state for the Pact verifier.
|
|
1570
1989
|
*
|
|
@@ -1707,7 +2126,12 @@ void pactffi_verifier_broker_source_with_selectors(struct VerifierHandle *handle
|
|
|
1707
2126
|
unsigned char enable_pending,
|
|
1708
2127
|
const char *include_wip_pacts_since,
|
|
1709
2128
|
const char *const *provider_tags,
|
|
1710
|
-
unsigned short provider_tags_len
|
|
2129
|
+
unsigned short provider_tags_len,
|
|
2130
|
+
const char *provider_branch,
|
|
2131
|
+
const char *const *consumer_version_selectors,
|
|
2132
|
+
unsigned short consumer_version_selectors_len,
|
|
2133
|
+
const char *const *consumer_version_tags,
|
|
2134
|
+
unsigned short consumer_version_tags_len);
|
|
1711
2135
|
|
|
1712
2136
|
/**
|
|
1713
2137
|
* Runs the verification.
|
|
@@ -1787,4 +2211,71 @@ const char *pactffi_verifier_logs(const struct VerifierHandle *handle);
|
|
|
1787
2211
|
*/
|
|
1788
2212
|
const char *pactffi_verifier_logs_for_provider(const char *provider_name);
|
|
1789
2213
|
|
|
2214
|
+
/**
|
|
2215
|
+
* Add a plugin to be used by the test. The plugin needs to be installed correctly for this
|
|
2216
|
+
* function to work.
|
|
2217
|
+
*
|
|
2218
|
+
* * `plugin_name` is the name of the plugin to load.
|
|
2219
|
+
* * `plugin_version` is the version of the plugin to load. It is optional, and can be NULL.
|
|
2220
|
+
*
|
|
2221
|
+
* Returns zero on success, and a positive integer value on failure.
|
|
2222
|
+
*
|
|
2223
|
+
* Note that plugins run as separate processes, so will need to be cleaned up afterwards by
|
|
2224
|
+
* calling `pactffi_cleanup_plugins` otherwise you have plugin processes left running.
|
|
2225
|
+
*
|
|
2226
|
+
* # Safety
|
|
2227
|
+
*
|
|
2228
|
+
* `plugin_name` must be a valid pointer to a NULL terminated string. `plugin_version` may be null,
|
|
2229
|
+
* and if not NULL must also be a valid pointer to a NULL terminated string.
|
|
2230
|
+
*
|
|
2231
|
+
* # Errors
|
|
2232
|
+
*
|
|
2233
|
+
* * `1` - A general panic was caught.
|
|
2234
|
+
* * `2` - Failed to load the plugin.
|
|
2235
|
+
* * `3` - Pact Handle is not valid.
|
|
2236
|
+
*
|
|
2237
|
+
* When an error errors, LAST_ERROR will contain the error message.
|
|
2238
|
+
*/
|
|
2239
|
+
unsigned int pactffi_using_plugin(PactHandle pact,
|
|
2240
|
+
const char *plugin_name,
|
|
2241
|
+
const char *plugin_version);
|
|
2242
|
+
|
|
2243
|
+
/**
|
|
2244
|
+
* Decrement the access count on any plugins that are loaded for the Pact. This will shutdown
|
|
2245
|
+
* any plugins that are no longer required (access count is zero).
|
|
2246
|
+
*/
|
|
2247
|
+
void pactffi_cleanup_plugins(PactHandle pact);
|
|
2248
|
+
|
|
2249
|
+
/**
|
|
2250
|
+
* Setup the interaction part using a plugin. The contents is a JSON string that will be passed on to
|
|
2251
|
+
* the plugin to configure the interaction part. Refer to the plugin documentation on the format
|
|
2252
|
+
* of the JSON contents.
|
|
2253
|
+
*
|
|
2254
|
+
* Returns zero on success, and a positive integer value on failure.
|
|
2255
|
+
*
|
|
2256
|
+
* * `interaction` - Handle to the interaction to configure.
|
|
2257
|
+
* * `part` - The part of the interaction to configure (request or response). It is ignored for messages.
|
|
2258
|
+
* * `content_type` - NULL terminated C string of the content type of the part.
|
|
2259
|
+
* * `contents` - NULL terminated C string of the JSON contents that gets passed to the plugin.
|
|
2260
|
+
*
|
|
2261
|
+
* # Safety
|
|
2262
|
+
*
|
|
2263
|
+
* `content_type` and `contents` must be a valid pointers to NULL terminated strings.
|
|
2264
|
+
*
|
|
2265
|
+
* # Errors
|
|
2266
|
+
*
|
|
2267
|
+
* * `1` - A general panic was caught.
|
|
2268
|
+
* * `2` - The mock server has already been started.
|
|
2269
|
+
* * `3` - The interaction handle is invalid.
|
|
2270
|
+
* * `4` - The content type is not valid.
|
|
2271
|
+
* * `5` - The contents JSON is not valid JSON.
|
|
2272
|
+
* * `6` - The plugin returned an error.
|
|
2273
|
+
*
|
|
2274
|
+
* When an error errors, LAST_ERROR will contain the error message.
|
|
2275
|
+
*/
|
|
2276
|
+
unsigned int pactffi_interaction_contents(InteractionHandle interaction,
|
|
2277
|
+
enum InteractionPart part,
|
|
2278
|
+
const char *content_type,
|
|
2279
|
+
const char *contents);
|
|
2280
|
+
|
|
1790
2281
|
#endif /* pact_ffi_h */
|