@pact-foundation/pact-core 13.5.1 → 13.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/binding.gyp +141 -0
- package/build/Makefile +334 -0
- package/build/binding.Makefile +6 -0
- package/build/copy_release_artifacts.target.mk +47 -0
- package/build/pact.target.mk +174 -0
- package/build/set_osx_install_name.target.mk +18 -0
- package/ffi/{v0.0.3-libpact_ffi-osx-aarch64-apple-darwin.dylib → libpact_ffi.dylib} +0 -0
- package/ffi/{v0.0.3-libpact_ffi-linux-x86_64.so → libpact_ffi.so} +0 -0
- package/ffi/libpact_ffi.so.gz +0 -0
- package/ffi/{v0.0.3-libpact_ffi-osx-x86_64.dylib → osxaarch64/libpact_ffi.dylib} +0 -0
- package/ffi/pact-cpp.h +2344 -0
- package/ffi/{v0.0.3-pact.h → pact.h} +667 -119
- package/ffi/{v0.0.3-pact_ffi-windows-x86_64.dll → pact_ffi.dll} +0 -0
- package/ffi/pact_ffi.dll.lib +0 -0
- package/native/addon.cc +68 -0
- package/native/consumer.cc +1570 -0
- package/native/consumer.h +124 -0
- package/native/ffi.cc +148 -0
- package/native/ffi.h +18 -0
- package/native/plugin.cc +6 -0
- package/native/plugin.h +7 -0
- package/native/provider.cc +815 -0
- package/native/provider.h +38 -0
- package/package.json +12 -9
- 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 +5 -0
- package/src/consumer/index.js +222 -0
- package/src/consumer/index.js.map +1 -0
- package/src/consumer/types.d.ts +132 -0
- package/src/{ffi/internals → consumer}/types.js +0 -0
- package/src/{ffi/internals → consumer}/types.js.map +0 -0
- package/src/ffi/index.d.ts +4 -3
- package/src/ffi/index.js +6 -9
- package/src/ffi/index.js.map +1 -1
- package/src/ffi/internals/index.d.ts +0 -2
- package/src/ffi/internals/index.js +1 -11
- package/src/ffi/internals/index.js.map +1 -1
- package/src/ffi/types.d.ts +100 -0
- package/src/ffi/types.js +70 -0
- package/src/ffi/types.js.map +1 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -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/src/verifier/argumentMapper/arguments.js +8 -0
- package/src/verifier/argumentMapper/arguments.js.map +1 -1
- package/src/verifier/index.js +1 -7
- package/src/verifier/index.js.map +1 -1
- package/src/verifier/nativeVerifier.js +74 -15
- package/src/verifier/nativeVerifier.js.map +1 -1
- package/src/verifier/types.d.ts +10 -2
- package/test.js +52 -0
- package/src/ffi/declarations.d.ts +0 -136
- package/src/ffi/declarations.js +0 -92
- package/src/ffi/declarations.js.map +0 -1
- package/src/ffi/internals/types.d.ts +0 -23
|
@@ -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
|
|
@@ -287,7 +274,7 @@ const char *pactffi_version(void);
|
|
|
287
274
|
*
|
|
288
275
|
* # Safety
|
|
289
276
|
*
|
|
290
|
-
*
|
|
277
|
+
* log_env_var must be a valid NULL terminated UTF-8 string.
|
|
291
278
|
*/
|
|
292
279
|
void pactffi_init(const char *log_env_var);
|
|
293
280
|
|
|
@@ -300,6 +287,15 @@ void pactffi_init(const char *log_env_var);
|
|
|
300
287
|
*/
|
|
301
288
|
void pactffi_init_with_log_level(const char *level);
|
|
302
289
|
|
|
290
|
+
/**
|
|
291
|
+
* Enable ANSI coloured output on Windows. On non-Windows platforms, this function is a no-op.
|
|
292
|
+
*
|
|
293
|
+
* # Safety
|
|
294
|
+
*
|
|
295
|
+
* This function is safe.
|
|
296
|
+
*/
|
|
297
|
+
void pactffi_enable_ansi_support(void);
|
|
298
|
+
|
|
303
299
|
/**
|
|
304
300
|
* Log using the shared core logging facility.
|
|
305
301
|
*
|
|
@@ -597,7 +593,7 @@ struct Message *pactffi_message_new_from_body(const char *body, const char *cont
|
|
|
597
593
|
void pactffi_message_delete(struct Message *message);
|
|
598
594
|
|
|
599
595
|
/**
|
|
600
|
-
* Get the contents of a `Message
|
|
596
|
+
* Get the contents of a `Message` in string form.
|
|
601
597
|
*
|
|
602
598
|
* # Safety
|
|
603
599
|
*
|
|
@@ -614,6 +610,36 @@ void pactffi_message_delete(struct Message *message);
|
|
|
614
610
|
*/
|
|
615
611
|
const char *pactffi_message_get_contents(const struct Message *message);
|
|
616
612
|
|
|
613
|
+
/**
|
|
614
|
+
* Get the length of the contents of a `Message`.
|
|
615
|
+
*
|
|
616
|
+
* # Safety
|
|
617
|
+
*
|
|
618
|
+
* This function is safe.
|
|
619
|
+
*
|
|
620
|
+
* # Error Handling
|
|
621
|
+
*
|
|
622
|
+
* If the message is NULL, returns 0. If the body of the message
|
|
623
|
+
* is missing, then this function also returns 0.
|
|
624
|
+
*/
|
|
625
|
+
size_t pactffi_message_get_contents_length(const struct Message *message);
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Get the contents of a `Message` as a pointer to an array of bytes.
|
|
629
|
+
*
|
|
630
|
+
* # Safety
|
|
631
|
+
*
|
|
632
|
+
* The number of bytes in the buffer will be returned by `pactffi_message_get_contents_length`.
|
|
633
|
+
* It is safe to use the pointer while the message is not deleted or changed. Using the pointer
|
|
634
|
+
* after the message is mutated or deleted may lead to undefined behaviour.
|
|
635
|
+
*
|
|
636
|
+
* # Error Handling
|
|
637
|
+
*
|
|
638
|
+
* If the message is NULL, returns NULL. If the body of the message
|
|
639
|
+
* is missing, then this function also returns NULL.
|
|
640
|
+
*/
|
|
641
|
+
const unsigned char *pactffi_message_get_contents_bin(const struct Message *message);
|
|
642
|
+
|
|
617
643
|
/**
|
|
618
644
|
* Get a copy of the description.
|
|
619
645
|
*
|
|
@@ -690,6 +716,9 @@ struct ProviderStateIterator *pactffi_message_get_provider_state_iter(struct Mes
|
|
|
690
716
|
*
|
|
691
717
|
* The underlying data must not change during iteration.
|
|
692
718
|
*
|
|
719
|
+
* If a previous call panicked, then the internal mutex will have been poisoned and this
|
|
720
|
+
* function will return NULL.
|
|
721
|
+
*
|
|
693
722
|
* # Error Handling
|
|
694
723
|
*
|
|
695
724
|
* Returns NULL if an error occurs.
|
|
@@ -1045,6 +1074,238 @@ void pactffi_provider_state_param_iter_delete(struct ProviderStateParamIterator
|
|
|
1045
1074
|
*/
|
|
1046
1075
|
void pactffi_provider_state_param_pair_delete(struct ProviderStateParamPair *pair);
|
|
1047
1076
|
|
|
1077
|
+
/**
|
|
1078
|
+
* Free the iterator when you're done using it.
|
|
1079
|
+
*/
|
|
1080
|
+
void pactffi_pact_message_iter_delete(struct PactMessageIterator *iter);
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* Get the next message from the message pact. As the messages returned are owned by the
|
|
1084
|
+
* iterator, they do not need to be deleted but will be cleaned up when the iterator is
|
|
1085
|
+
* deleted.
|
|
1086
|
+
*
|
|
1087
|
+
* # Safety
|
|
1088
|
+
*
|
|
1089
|
+
* This function is safe.
|
|
1090
|
+
*
|
|
1091
|
+
* Deleting a message returned by the iterator can lead to undefined behaviour.
|
|
1092
|
+
*
|
|
1093
|
+
* # Error Handling
|
|
1094
|
+
*
|
|
1095
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
1096
|
+
*/
|
|
1097
|
+
struct Message *pactffi_pact_message_iter_next(struct PactMessageIterator *iter);
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* Get the next synchronous request/response message from the pact. As the messages returned are owned by the
|
|
1101
|
+
* iterator, they do not need to be deleted but will be cleaned up when the iterator is
|
|
1102
|
+
* deleted.
|
|
1103
|
+
*
|
|
1104
|
+
* # Safety
|
|
1105
|
+
*
|
|
1106
|
+
* This function is safe.
|
|
1107
|
+
*
|
|
1108
|
+
* Deleting a message returned by the iterator can lead to undefined behaviour.
|
|
1109
|
+
*
|
|
1110
|
+
* # Error Handling
|
|
1111
|
+
*
|
|
1112
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
1113
|
+
*/
|
|
1114
|
+
struct SynchronousMessage *pactffi_pact_sync_message_iter_next(struct PactSyncMessageIterator *iter);
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* Free the iterator when you're done using it.
|
|
1118
|
+
*/
|
|
1119
|
+
void pactffi_pact_sync_message_iter_delete(struct PactSyncMessageIterator *iter);
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* Destroy the `Message` being pointed to.
|
|
1123
|
+
*/
|
|
1124
|
+
void pactffi_sync_message_delete(struct SynchronousMessage *message);
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* Get the request contents of a `SynchronousMessage` in string form.
|
|
1128
|
+
*
|
|
1129
|
+
* # Safety
|
|
1130
|
+
*
|
|
1131
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1132
|
+
*
|
|
1133
|
+
* The returned string can outlive the message.
|
|
1134
|
+
*
|
|
1135
|
+
* # Error Handling
|
|
1136
|
+
*
|
|
1137
|
+
* If the message is NULL, returns NULL. If the body of the request message
|
|
1138
|
+
* is missing, then this function also returns NULL. This means there's
|
|
1139
|
+
* no mechanism to differentiate with this function call alone between
|
|
1140
|
+
* a NULL message and a missing message body.
|
|
1141
|
+
*/
|
|
1142
|
+
const char *pactffi_sync_message_get_request_contents(const struct SynchronousMessage *message);
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* Get the length of the request contents of a `SynchronousMessage`.
|
|
1146
|
+
*
|
|
1147
|
+
* # Safety
|
|
1148
|
+
*
|
|
1149
|
+
* This function is safe.
|
|
1150
|
+
*
|
|
1151
|
+
* # Error Handling
|
|
1152
|
+
*
|
|
1153
|
+
* If the message is NULL, returns 0. If the body of the request
|
|
1154
|
+
* is missing, then this function also returns 0.
|
|
1155
|
+
*/
|
|
1156
|
+
size_t pactffi_sync_message_get_request_contents_length(const struct SynchronousMessage *message);
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* Get the request contents of a `SynchronousMessage` as a pointer to an array of bytes.
|
|
1160
|
+
*
|
|
1161
|
+
* # Safety
|
|
1162
|
+
*
|
|
1163
|
+
* The number of bytes in the buffer will be returned by `pactffi_sync_message_get_request_contents_length`.
|
|
1164
|
+
* It is safe to use the pointer while the message is not deleted or changed. Using the pointer
|
|
1165
|
+
* after the message is mutated or deleted may lead to undefined behaviour.
|
|
1166
|
+
*
|
|
1167
|
+
* # Error Handling
|
|
1168
|
+
*
|
|
1169
|
+
* If the message is NULL, returns NULL. If the body of the message
|
|
1170
|
+
* is missing, then this function also returns NULL.
|
|
1171
|
+
*/
|
|
1172
|
+
const unsigned char *pactffi_sync_message_get_request_contents_bin(const struct SynchronousMessage *message);
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* Get the number of response messages in the `SynchronousMessage`.
|
|
1176
|
+
*
|
|
1177
|
+
* # Safety
|
|
1178
|
+
*
|
|
1179
|
+
* The message pointer must point to a valid SynchronousMessage.
|
|
1180
|
+
*
|
|
1181
|
+
* # Error Handling
|
|
1182
|
+
*
|
|
1183
|
+
* If the message is NULL, returns 0.
|
|
1184
|
+
*/
|
|
1185
|
+
size_t pactffi_sync_message_get_number_responses(const struct SynchronousMessage *message);
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* Get the response contents of a `SynchronousMessage` in string form.
|
|
1189
|
+
*
|
|
1190
|
+
* # Safety
|
|
1191
|
+
*
|
|
1192
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1193
|
+
*
|
|
1194
|
+
* The returned string can outlive the message.
|
|
1195
|
+
*
|
|
1196
|
+
* # Error Handling
|
|
1197
|
+
*
|
|
1198
|
+
* If the message is NULL or the index is not valid, returns NULL.
|
|
1199
|
+
*
|
|
1200
|
+
* If the body of the response message is missing, then this function also returns NULL.
|
|
1201
|
+
* This means there's no mechanism to differentiate with this function call alone between
|
|
1202
|
+
* a NULL message and a missing message body.
|
|
1203
|
+
*/
|
|
1204
|
+
const char *pactffi_sync_message_get_response_contents(const struct SynchronousMessage *message,
|
|
1205
|
+
size_t index);
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* Get the length of the response contents of a `SynchronousMessage`.
|
|
1209
|
+
*
|
|
1210
|
+
* # Safety
|
|
1211
|
+
*
|
|
1212
|
+
* This function is safe.
|
|
1213
|
+
*
|
|
1214
|
+
* # Error Handling
|
|
1215
|
+
*
|
|
1216
|
+
* If the message is NULL or the index is not valid, returns 0. If the body of the request
|
|
1217
|
+
* is missing, then this function also returns 0.
|
|
1218
|
+
*/
|
|
1219
|
+
size_t pactffi_sync_message_get_response_contents_length(const struct SynchronousMessage *message,
|
|
1220
|
+
size_t index);
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* Get the response contents of a `SynchronousMessage` as a pointer to an array of bytes.
|
|
1224
|
+
*
|
|
1225
|
+
* # Safety
|
|
1226
|
+
*
|
|
1227
|
+
* The number of bytes in the buffer will be returned by `pactffi_sync_message_get_response_contents_length`.
|
|
1228
|
+
* It is safe to use the pointer while the message is not deleted or changed. Using the pointer
|
|
1229
|
+
* after the message is mutated or deleted may lead to undefined behaviour.
|
|
1230
|
+
*
|
|
1231
|
+
* # Error Handling
|
|
1232
|
+
*
|
|
1233
|
+
* If the message is NULL or the index is not valid, returns NULL. If the body of the message
|
|
1234
|
+
* is missing, then this function also returns NULL.
|
|
1235
|
+
*/
|
|
1236
|
+
const unsigned char *pactffi_sync_message_get_response_contents_bin(const struct SynchronousMessage *message,
|
|
1237
|
+
size_t index);
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* Get a copy of the description.
|
|
1241
|
+
*
|
|
1242
|
+
* # Safety
|
|
1243
|
+
*
|
|
1244
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1245
|
+
*
|
|
1246
|
+
* Since it is a copy, the returned string may safely outlive
|
|
1247
|
+
* the `SynchronousMessage`.
|
|
1248
|
+
*
|
|
1249
|
+
* # Errors
|
|
1250
|
+
*
|
|
1251
|
+
* On failure, this function will return a NULL pointer.
|
|
1252
|
+
*
|
|
1253
|
+
* This function may fail if the Rust string contains embedded
|
|
1254
|
+
* null ('\0') bytes.
|
|
1255
|
+
*/
|
|
1256
|
+
const char *pactffi_sync_message_get_description(const struct SynchronousMessage *message);
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* Write the `description` field on the `SynchronousMessage`.
|
|
1260
|
+
*
|
|
1261
|
+
* # Safety
|
|
1262
|
+
*
|
|
1263
|
+
* `description` must contain valid UTF-8. Invalid UTF-8
|
|
1264
|
+
* will be replaced with U+FFFD REPLACEMENT CHARACTER.
|
|
1265
|
+
*
|
|
1266
|
+
* This function will only reallocate if the new string
|
|
1267
|
+
* does not fit in the existing buffer.
|
|
1268
|
+
*
|
|
1269
|
+
* # Error Handling
|
|
1270
|
+
*
|
|
1271
|
+
* Errors will be reported with a non-zero return value.
|
|
1272
|
+
*/
|
|
1273
|
+
int pactffi_sync_message_set_description(struct SynchronousMessage *message,
|
|
1274
|
+
const char *description);
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* Get a copy of the provider state at the given index from this message.
|
|
1278
|
+
*
|
|
1279
|
+
* # Safety
|
|
1280
|
+
*
|
|
1281
|
+
* The returned structure must be deleted with `provider_state_delete`.
|
|
1282
|
+
*
|
|
1283
|
+
* Since it is a copy, the returned structure may safely outlive
|
|
1284
|
+
* the `SynchronousMessage`.
|
|
1285
|
+
*
|
|
1286
|
+
* # Error Handling
|
|
1287
|
+
*
|
|
1288
|
+
* On failure, this function will return a variant other than Success.
|
|
1289
|
+
*
|
|
1290
|
+
* This function may fail if the index requested is out of bounds,
|
|
1291
|
+
* or if any of the Rust strings contain embedded null ('\0') bytes.
|
|
1292
|
+
*/
|
|
1293
|
+
const struct ProviderState *pactffi_sync_message_get_provider_state(const struct SynchronousMessage *message,
|
|
1294
|
+
unsigned int index);
|
|
1295
|
+
|
|
1296
|
+
/**
|
|
1297
|
+
* Get an iterator over provider states.
|
|
1298
|
+
*
|
|
1299
|
+
* # Safety
|
|
1300
|
+
*
|
|
1301
|
+
* The underlying data must not change during iteration.
|
|
1302
|
+
*
|
|
1303
|
+
* # Error Handling
|
|
1304
|
+
*
|
|
1305
|
+
* Returns NULL if an error occurs.
|
|
1306
|
+
*/
|
|
1307
|
+
struct ProviderStateIterator *pactffi_sync_message_get_provider_state_iter(struct SynchronousMessage *message);
|
|
1308
|
+
|
|
1048
1309
|
/**
|
|
1049
1310
|
* Delete a string previously returned by this FFI.
|
|
1050
1311
|
*
|
|
@@ -1114,7 +1375,7 @@ char *pactffi_get_tls_ca_certificate(void);
|
|
|
1114
1375
|
* | -6 | Could not create the TLS configuration with the self-signed certificate |
|
|
1115
1376
|
*
|
|
1116
1377
|
*/
|
|
1117
|
-
int32_t pactffi_create_mock_server_for_pact(
|
|
1378
|
+
int32_t pactffi_create_mock_server_for_pact(PactHandle pact,
|
|
1118
1379
|
const char *addr_str,
|
|
1119
1380
|
bool tls);
|
|
1120
1381
|
|
|
@@ -1182,24 +1443,81 @@ int32_t pactffi_write_pact_file(int32_t mock_server_port, const char *directory,
|
|
|
1182
1443
|
*/
|
|
1183
1444
|
const char *pactffi_mock_server_logs(int32_t mock_server_port);
|
|
1184
1445
|
|
|
1446
|
+
/**
|
|
1447
|
+
* Generates a datetime value from the provided format string, using the current system date and time
|
|
1448
|
+
* NOTE: The memory for the returned string needs to be freed with the free_string function
|
|
1449
|
+
*
|
|
1450
|
+
* # Safety
|
|
1451
|
+
*
|
|
1452
|
+
* Exported functions are inherently unsafe.
|
|
1453
|
+
*/
|
|
1454
|
+
struct StringResult pactffi_generate_datetime_string(const char *format);
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* Checks that the example string matches the given regex
|
|
1458
|
+
*
|
|
1459
|
+
* # Safety
|
|
1460
|
+
*
|
|
1461
|
+
* Exported functions are inherently unsafe.
|
|
1462
|
+
*/
|
|
1463
|
+
bool pactffi_check_regex(const char *regex, const char *example);
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* Generates an example string based on the provided regex.
|
|
1467
|
+
* NOTE: The memory for the returned string needs to be freed with the free_string function
|
|
1468
|
+
*
|
|
1469
|
+
* # Safety
|
|
1470
|
+
*
|
|
1471
|
+
* Exported functions are inherently unsafe.
|
|
1472
|
+
*/
|
|
1473
|
+
struct StringResult pactffi_generate_regex_value(const char *regex);
|
|
1474
|
+
|
|
1475
|
+
/**
|
|
1476
|
+
* [DEPRECATED] Frees the memory allocated to a string by another function
|
|
1477
|
+
*
|
|
1478
|
+
* This function is deprecated. Use pactffi_string_delete instead.
|
|
1479
|
+
*
|
|
1480
|
+
* # Safety
|
|
1481
|
+
*
|
|
1482
|
+
* Exported functions are inherently unsafe.
|
|
1483
|
+
*/
|
|
1484
|
+
void pactffi_free_string(char *s);
|
|
1485
|
+
|
|
1185
1486
|
/**
|
|
1186
1487
|
* Creates a new Pact model and returns a handle to it.
|
|
1187
1488
|
*
|
|
1188
1489
|
* * `consumer_name` - The name of the consumer for the pact.
|
|
1189
1490
|
* * `provider_name` - The name of the provider for the pact.
|
|
1190
1491
|
*
|
|
1191
|
-
* Returns a new `PactHandle`.
|
|
1492
|
+
* Returns a new `PactHandle`. The handle will need to be freed with the `pactffi_free_pact_handle`
|
|
1493
|
+
* method to release its resources.
|
|
1192
1494
|
*/
|
|
1193
|
-
|
|
1495
|
+
PactHandle pactffi_new_pact(const char *consumer_name, const char *provider_name);
|
|
1194
1496
|
|
|
1195
1497
|
/**
|
|
1196
|
-
* Creates a new Interaction and returns a handle to it.
|
|
1498
|
+
* Creates a new HTTP Interaction and returns a handle to it.
|
|
1197
1499
|
*
|
|
1198
1500
|
* * `description` - The interaction description. It needs to be unique for each interaction.
|
|
1199
1501
|
*
|
|
1200
1502
|
* Returns a new `InteractionHandle`.
|
|
1201
1503
|
*/
|
|
1202
|
-
|
|
1504
|
+
InteractionHandle pactffi_new_interaction(PactHandle pact, const char *description);
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* Creates a new message interaction and return a handle to it
|
|
1508
|
+
* * `description` - The interaction description. It needs to be unique for each interaction.
|
|
1509
|
+
*
|
|
1510
|
+
* Returns a new `InteractionHandle`.
|
|
1511
|
+
*/
|
|
1512
|
+
InteractionHandle pactffi_new_message_interaction(PactHandle pact, const char *description);
|
|
1513
|
+
|
|
1514
|
+
/**
|
|
1515
|
+
* Creates a new synchronous message interaction (request/response) and return a handle to it
|
|
1516
|
+
* * `description` - The interaction description. It needs to be unique for each interaction.
|
|
1517
|
+
*
|
|
1518
|
+
* Returns a new `InteractionHandle`.
|
|
1519
|
+
*/
|
|
1520
|
+
InteractionHandle pactffi_new_sync_message_interaction(PactHandle pact, const char *description);
|
|
1203
1521
|
|
|
1204
1522
|
/**
|
|
1205
1523
|
* Sets the description for the Interaction. Returns false if the interaction or Pact can't be
|
|
@@ -1207,7 +1525,7 @@ struct InteractionHandle pactffi_new_interaction(struct PactHandle pact, const c
|
|
|
1207
1525
|
*
|
|
1208
1526
|
* * `description` - The interaction description. It needs to be unique for each interaction.
|
|
1209
1527
|
*/
|
|
1210
|
-
bool pactffi_upon_receiving(
|
|
1528
|
+
bool pactffi_upon_receiving(InteractionHandle interaction, const char *description);
|
|
1211
1529
|
|
|
1212
1530
|
/**
|
|
1213
1531
|
* Adds a provider state to the Interaction. Returns false if the interaction or Pact can't be
|
|
@@ -1215,7 +1533,27 @@ bool pactffi_upon_receiving(struct InteractionHandle interaction, const char *de
|
|
|
1215
1533
|
*
|
|
1216
1534
|
* * `description` - The provider state description. It needs to be unique.
|
|
1217
1535
|
*/
|
|
1218
|
-
bool pactffi_given(
|
|
1536
|
+
bool pactffi_given(InteractionHandle interaction, const char *description);
|
|
1537
|
+
|
|
1538
|
+
/**
|
|
1539
|
+
* Sets the test name annotation for the interaction. This allows capturing the name of
|
|
1540
|
+
* the test as metadata. This can only be used with V4 interactions.
|
|
1541
|
+
*
|
|
1542
|
+
* # Safety
|
|
1543
|
+
*
|
|
1544
|
+
* The test name parameter must be a valid pointer to a NULL terminated string.
|
|
1545
|
+
*
|
|
1546
|
+
* # Error Handling
|
|
1547
|
+
*
|
|
1548
|
+
* If the test name can not be set, this will return a positive value.
|
|
1549
|
+
*
|
|
1550
|
+
* * `1` - Function panicked. Error message will be available by calling `pactffi_get_error_message`.
|
|
1551
|
+
* * `2` - Handle was not valid.
|
|
1552
|
+
* * `3` - Mock server was already started and the interation can not be modified.
|
|
1553
|
+
* * `4` - Not a V4 interaction.
|
|
1554
|
+
*/
|
|
1555
|
+
unsigned int pactffi_interaction_test_name(InteractionHandle interaction,
|
|
1556
|
+
const char *test_name);
|
|
1219
1557
|
|
|
1220
1558
|
/**
|
|
1221
1559
|
* 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 +1563,7 @@ bool pactffi_given(struct InteractionHandle interaction, const char *description
|
|
|
1225
1563
|
* * `name` - Parameter name.
|
|
1226
1564
|
* * `value` - Parameter value.
|
|
1227
1565
|
*/
|
|
1228
|
-
bool pactffi_given_with_param(
|
|
1566
|
+
bool pactffi_given_with_param(InteractionHandle interaction,
|
|
1229
1567
|
const char *description,
|
|
1230
1568
|
const char *name,
|
|
1231
1569
|
const char *value);
|
|
@@ -1237,9 +1575,7 @@ bool pactffi_given_with_param(struct InteractionHandle interaction,
|
|
|
1237
1575
|
* * `method` - The request method. Defaults to GET.
|
|
1238
1576
|
* * `path` - The request path. Defaults to `/`.
|
|
1239
1577
|
*/
|
|
1240
|
-
bool pactffi_with_request(
|
|
1241
|
-
const char *method,
|
|
1242
|
-
const char *path);
|
|
1578
|
+
bool pactffi_with_request(InteractionHandle interaction, const char *method, const char *path);
|
|
1243
1579
|
|
|
1244
1580
|
/**
|
|
1245
1581
|
* Configures a query parameter for the Interaction. Returns false if the interaction or Pact can't be
|
|
@@ -1249,7 +1585,7 @@ bool pactffi_with_request(struct InteractionHandle interaction,
|
|
|
1249
1585
|
* * `value` - the query parameter value.
|
|
1250
1586
|
* * `index` - the index of the value (starts at 0). You can use this to create a query parameter with multiple values
|
|
1251
1587
|
*/
|
|
1252
|
-
bool pactffi_with_query_parameter(
|
|
1588
|
+
bool pactffi_with_query_parameter(InteractionHandle interaction,
|
|
1253
1589
|
const char *name,
|
|
1254
1590
|
size_t index,
|
|
1255
1591
|
const char *value);
|
|
@@ -1261,7 +1597,7 @@ bool pactffi_with_query_parameter(struct InteractionHandle interaction,
|
|
|
1261
1597
|
* * `pact` - Handle to a Pact model
|
|
1262
1598
|
* * `version` - the spec version to use
|
|
1263
1599
|
*/
|
|
1264
|
-
bool pactffi_with_specification(
|
|
1600
|
+
bool pactffi_with_specification(PactHandle pact,
|
|
1265
1601
|
enum PactSpecification version);
|
|
1266
1602
|
|
|
1267
1603
|
/**
|
|
@@ -1273,7 +1609,7 @@ bool pactffi_with_specification(struct PactHandle pact,
|
|
|
1273
1609
|
* * `name` - the key to set
|
|
1274
1610
|
* * `value` - the value to set
|
|
1275
1611
|
*/
|
|
1276
|
-
bool pactffi_with_pact_metadata(
|
|
1612
|
+
bool pactffi_with_pact_metadata(PactHandle pact,
|
|
1277
1613
|
const char *namespace_,
|
|
1278
1614
|
const char *name,
|
|
1279
1615
|
const char *value);
|
|
@@ -1287,7 +1623,7 @@ bool pactffi_with_pact_metadata(struct PactHandle pact,
|
|
|
1287
1623
|
* * `value` - the header value.
|
|
1288
1624
|
* * `index` - the index of the value (starts at 0). You can use this to create a header with multiple values
|
|
1289
1625
|
*/
|
|
1290
|
-
bool pactffi_with_header(
|
|
1626
|
+
bool pactffi_with_header(InteractionHandle interaction,
|
|
1291
1627
|
enum InteractionPart part,
|
|
1292
1628
|
const char *name,
|
|
1293
1629
|
size_t index,
|
|
@@ -1299,7 +1635,7 @@ bool pactffi_with_header(struct InteractionHandle interaction,
|
|
|
1299
1635
|
*
|
|
1300
1636
|
* * `status` - the response status. Defaults to 200.
|
|
1301
1637
|
*/
|
|
1302
|
-
bool pactffi_response_status(
|
|
1638
|
+
bool pactffi_response_status(InteractionHandle interaction, unsigned short status);
|
|
1303
1639
|
|
|
1304
1640
|
/**
|
|
1305
1641
|
* Adds the body for the interaction. Returns false if the interaction or Pact can't be
|
|
@@ -1310,49 +1646,11 @@ bool pactffi_response_status(struct InteractionHandle interaction, unsigned shor
|
|
|
1310
1646
|
* header is already set.
|
|
1311
1647
|
* * `body` - The body contents. For JSON payloads, matching rules can be embedded in the body.
|
|
1312
1648
|
*/
|
|
1313
|
-
bool pactffi_with_body(
|
|
1649
|
+
bool pactffi_with_body(InteractionHandle interaction,
|
|
1314
1650
|
enum InteractionPart part,
|
|
1315
1651
|
const char *content_type,
|
|
1316
1652
|
const char *body);
|
|
1317
1653
|
|
|
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
1654
|
/**
|
|
1357
1655
|
* Adds a binary file as the body with the expected content type and example contents. Will use
|
|
1358
1656
|
* a mime type matcher to match the body. Returns false if the interaction or Pact can't be
|
|
@@ -1364,7 +1662,7 @@ void pactffi_free_string(char *s);
|
|
|
1364
1662
|
* * `body` - example body contents in bytes
|
|
1365
1663
|
* * `size` - number of bytes in the body
|
|
1366
1664
|
*/
|
|
1367
|
-
bool pactffi_with_binary_file(
|
|
1665
|
+
bool pactffi_with_binary_file(InteractionHandle interaction,
|
|
1368
1666
|
enum InteractionPart part,
|
|
1369
1667
|
const char *content_type,
|
|
1370
1668
|
const uint8_t *body,
|
|
@@ -1381,22 +1679,57 @@ bool pactffi_with_binary_file(struct InteractionHandle interaction,
|
|
|
1381
1679
|
* * `file` - path to the example file
|
|
1382
1680
|
* * `part_name` - name for the mime part
|
|
1383
1681
|
*/
|
|
1384
|
-
struct StringResult pactffi_with_multipart_file(
|
|
1682
|
+
struct StringResult pactffi_with_multipart_file(InteractionHandle interaction,
|
|
1385
1683
|
enum InteractionPart part,
|
|
1386
1684
|
const char *content_type,
|
|
1387
1685
|
const char *file,
|
|
1388
1686
|
const char *part_name);
|
|
1389
1687
|
|
|
1688
|
+
/**
|
|
1689
|
+
* Get an iterator over all the messages of the Pact. The returned iterator needs to be
|
|
1690
|
+
* freed with `pactffi_pact_message_iter_delete`.
|
|
1691
|
+
*
|
|
1692
|
+
* # Safety
|
|
1693
|
+
*
|
|
1694
|
+
* The iterator contains a copy of the Pact, so it is always safe to use.
|
|
1695
|
+
*
|
|
1696
|
+
* # Error Handling
|
|
1697
|
+
*
|
|
1698
|
+
* On failure, this function will return a NULL pointer.
|
|
1699
|
+
*
|
|
1700
|
+
* This function may fail if any of the Rust strings contain embedded
|
|
1701
|
+
* null ('\0') bytes.
|
|
1702
|
+
*/
|
|
1703
|
+
struct PactMessageIterator *pactffi_pact_handle_get_message_iter(PactHandle pact);
|
|
1704
|
+
|
|
1705
|
+
/**
|
|
1706
|
+
* Get an iterator over all the synchronous request/response messages of the Pact.
|
|
1707
|
+
* The returned iterator needs to be freed with `pactffi_pact_sync_message_iter_delete`.
|
|
1708
|
+
*
|
|
1709
|
+
* # Safety
|
|
1710
|
+
*
|
|
1711
|
+
* The iterator contains a copy of the Pact, so it is always safe to use.
|
|
1712
|
+
*
|
|
1713
|
+
* # Error Handling
|
|
1714
|
+
*
|
|
1715
|
+
* On failure, this function will return a NULL pointer.
|
|
1716
|
+
*
|
|
1717
|
+
* This function may fail if any of the Rust strings contain embedded
|
|
1718
|
+
* null ('\0') bytes.
|
|
1719
|
+
*/
|
|
1720
|
+
struct PactSyncMessageIterator *pactffi_pact_handle_get_sync_message_iter(PactHandle pact);
|
|
1721
|
+
|
|
1390
1722
|
/**
|
|
1391
1723
|
* Creates a new Pact Message model and returns a handle to it.
|
|
1392
1724
|
*
|
|
1393
1725
|
* * `consumer_name` - The name of the consumer for the pact.
|
|
1394
1726
|
* * `provider_name` - The name of the provider for the pact.
|
|
1395
1727
|
*
|
|
1396
|
-
* Returns a new `MessagePactHandle`.
|
|
1728
|
+
* Returns a new `MessagePactHandle`. The handle will need to be freed with the `pactffi_free_message_pact_handle`
|
|
1729
|
+
* function to release its resources.
|
|
1397
1730
|
*/
|
|
1398
|
-
|
|
1399
|
-
|
|
1731
|
+
MessagePactHandle pactffi_new_message_pact(const char *consumer_name,
|
|
1732
|
+
const char *provider_name);
|
|
1400
1733
|
|
|
1401
1734
|
/**
|
|
1402
1735
|
* Creates a new Message and returns a handle to it.
|
|
@@ -1405,21 +1738,21 @@ struct MessagePactHandle pactffi_new_message_pact(const char *consumer_name,
|
|
|
1405
1738
|
*
|
|
1406
1739
|
* Returns a new `MessageHandle`.
|
|
1407
1740
|
*/
|
|
1408
|
-
|
|
1741
|
+
MessageHandle pactffi_new_message(MessagePactHandle pact, const char *description);
|
|
1409
1742
|
|
|
1410
1743
|
/**
|
|
1411
1744
|
* Sets the description for the Message.
|
|
1412
1745
|
*
|
|
1413
1746
|
* * `description` - The message description. It needs to be unique for each message.
|
|
1414
1747
|
*/
|
|
1415
|
-
void pactffi_message_expects_to_receive(
|
|
1748
|
+
void pactffi_message_expects_to_receive(MessageHandle message, const char *description);
|
|
1416
1749
|
|
|
1417
1750
|
/**
|
|
1418
1751
|
* Adds a provider state to the Interaction.
|
|
1419
1752
|
*
|
|
1420
1753
|
* * `description` - The provider state description. It needs to be unique for each message
|
|
1421
1754
|
*/
|
|
1422
|
-
void pactffi_message_given(
|
|
1755
|
+
void pactffi_message_given(MessageHandle message, const char *description);
|
|
1423
1756
|
|
|
1424
1757
|
/**
|
|
1425
1758
|
* Adds a provider state to the Message with a parameter key and value.
|
|
@@ -1428,7 +1761,7 @@ void pactffi_message_given(struct MessageHandle message, const char *description
|
|
|
1428
1761
|
* * `name` - Parameter name.
|
|
1429
1762
|
* * `value` - Parameter value.
|
|
1430
1763
|
*/
|
|
1431
|
-
void pactffi_message_given_with_param(
|
|
1764
|
+
void pactffi_message_given_with_param(MessageHandle message,
|
|
1432
1765
|
const char *description,
|
|
1433
1766
|
const char *name,
|
|
1434
1767
|
const char *value);
|
|
@@ -1447,7 +1780,7 @@ void pactffi_message_given_with_param(struct MessageHandle message,
|
|
|
1447
1780
|
* * `content_type` - Expected content type (e.g. application/json, application/octet-stream)
|
|
1448
1781
|
* * `size` - number of bytes in the message body to read. This is not required for text bodies (JSON, XML, etc.).
|
|
1449
1782
|
*/
|
|
1450
|
-
void pactffi_message_with_contents(
|
|
1783
|
+
void pactffi_message_with_contents(MessageHandle message_handle,
|
|
1451
1784
|
const char *content_type,
|
|
1452
1785
|
const uint8_t *body,
|
|
1453
1786
|
size_t size);
|
|
@@ -1458,7 +1791,7 @@ void pactffi_message_with_contents(struct MessageHandle message,
|
|
|
1458
1791
|
* * `key` - metadata key
|
|
1459
1792
|
* * `value` - metadata value.
|
|
1460
1793
|
*/
|
|
1461
|
-
void pactffi_message_with_metadata(
|
|
1794
|
+
void pactffi_message_with_metadata(MessageHandle message_handle,
|
|
1462
1795
|
const char *key,
|
|
1463
1796
|
const char *value);
|
|
1464
1797
|
|
|
@@ -1468,7 +1801,7 @@ void pactffi_message_with_metadata(struct MessageHandle message,
|
|
|
1468
1801
|
* Reification is the process of stripping away any matchers, and returning the original contents.
|
|
1469
1802
|
* NOTE: the returned string needs to be deallocated with the `free_string` function
|
|
1470
1803
|
*/
|
|
1471
|
-
const char *pactffi_message_reify(
|
|
1804
|
+
const char *pactffi_message_reify(MessageHandle message_handle);
|
|
1472
1805
|
|
|
1473
1806
|
/**
|
|
1474
1807
|
* External interface to write out the message pact file. This function should
|
|
@@ -1490,7 +1823,7 @@ const char *pactffi_message_reify(struct MessageHandle message);
|
|
|
1490
1823
|
* | 1 | The pact file was not able to be written |
|
|
1491
1824
|
* | 2 | The message pact for the given handle was not found |
|
|
1492
1825
|
*/
|
|
1493
|
-
int32_t pactffi_write_message_pact_file(
|
|
1826
|
+
int32_t pactffi_write_message_pact_file(MessagePactHandle pact,
|
|
1494
1827
|
const char *directory,
|
|
1495
1828
|
bool overwrite);
|
|
1496
1829
|
|
|
@@ -1502,11 +1835,71 @@ int32_t pactffi_write_message_pact_file(struct MessagePactHandle pact,
|
|
|
1502
1835
|
* * `name` - the key to set
|
|
1503
1836
|
* * `value` - the value to set
|
|
1504
1837
|
*/
|
|
1505
|
-
void pactffi_with_message_pact_metadata(
|
|
1838
|
+
void pactffi_with_message_pact_metadata(MessagePactHandle pact,
|
|
1506
1839
|
const char *namespace_,
|
|
1507
1840
|
const char *name,
|
|
1508
1841
|
const char *value);
|
|
1509
1842
|
|
|
1843
|
+
/**
|
|
1844
|
+
* External interface to write out the pact file. This function should
|
|
1845
|
+
* be called if all the consumer tests have passed. The directory to write the file to is passed
|
|
1846
|
+
* as the second parameter. If a NULL pointer is passed, the current working directory is used.
|
|
1847
|
+
*
|
|
1848
|
+
* If overwrite is true, the file will be overwritten with the contents of the current pact.
|
|
1849
|
+
* Otherwise, it will be merged with any existing pact file.
|
|
1850
|
+
*
|
|
1851
|
+
* Returns 0 if the pact file was successfully written. Returns a positive code if the file can
|
|
1852
|
+
* not be written or the function panics.
|
|
1853
|
+
*
|
|
1854
|
+
* # Safety
|
|
1855
|
+
*
|
|
1856
|
+
* The directory parameter must either be NULL or point to a valid NULL terminated string.
|
|
1857
|
+
*
|
|
1858
|
+
* # Errors
|
|
1859
|
+
*
|
|
1860
|
+
* Errors are returned as positive values.
|
|
1861
|
+
*
|
|
1862
|
+
* | Error | Description |
|
|
1863
|
+
* |-------|-------------|
|
|
1864
|
+
* | 1 | The function panicked. |
|
|
1865
|
+
* | 2 | The pact file was not able to be written. |
|
|
1866
|
+
* | 3 | The pact for the given handle was not found. |
|
|
1867
|
+
*/
|
|
1868
|
+
int32_t pactffi_pact_handle_write_file(PactHandle pact, const char *directory, bool overwrite);
|
|
1869
|
+
|
|
1870
|
+
/**
|
|
1871
|
+
* Creates a new V4 asynchronous message and returns a handle to it.
|
|
1872
|
+
*
|
|
1873
|
+
* * `description` - The message description. It needs to be unique for each Message.
|
|
1874
|
+
*
|
|
1875
|
+
* Returns a new `MessageHandle`.
|
|
1876
|
+
*/
|
|
1877
|
+
MessageHandle pactffi_new_async_message(PactHandle pact, const char *description);
|
|
1878
|
+
|
|
1879
|
+
/**
|
|
1880
|
+
* Delete a Pact handle and free the resources used by it.
|
|
1881
|
+
*
|
|
1882
|
+
* # Error Handling
|
|
1883
|
+
*
|
|
1884
|
+
* On failure, this function will return a positive integer value.
|
|
1885
|
+
*
|
|
1886
|
+
* * `1` - The handle is not valid or does not refer to a valid Pact. Could be that it was previously deleted.
|
|
1887
|
+
*
|
|
1888
|
+
*/
|
|
1889
|
+
unsigned int pactffi_free_pact_handle(PactHandle pact);
|
|
1890
|
+
|
|
1891
|
+
/**
|
|
1892
|
+
* Delete a Pact handle and free the resources used by it.
|
|
1893
|
+
*
|
|
1894
|
+
* # Error Handling
|
|
1895
|
+
*
|
|
1896
|
+
* On failure, this function will return a positive integer value.
|
|
1897
|
+
*
|
|
1898
|
+
* * `1` - The handle is not valid or does not refer to a valid Pact. Could be that it was previously deleted.
|
|
1899
|
+
*
|
|
1900
|
+
*/
|
|
1901
|
+
unsigned int pactffi_free_message_pact_handle(MessagePactHandle pact);
|
|
1902
|
+
|
|
1510
1903
|
/**
|
|
1511
1904
|
* External interface to verifier a provider
|
|
1512
1905
|
*
|
|
@@ -1531,7 +1924,10 @@ int32_t pactffi_verify(const char *args);
|
|
|
1531
1924
|
|
|
1532
1925
|
/**
|
|
1533
1926
|
* 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
|
|
1927
|
+
* done with the verifier to free all allocated resources.
|
|
1928
|
+
*
|
|
1929
|
+
* This function is deprecated. Use `pactffi_verifier_new_for_application` which allows the
|
|
1930
|
+
* calling application/framework name and version to be specified.
|
|
1535
1931
|
*
|
|
1536
1932
|
* # Safety
|
|
1537
1933
|
*
|
|
@@ -1543,6 +1939,20 @@ int32_t pactffi_verify(const char *args);
|
|
|
1543
1939
|
*/
|
|
1544
1940
|
struct VerifierHandle *pactffi_verifier_new(void);
|
|
1545
1941
|
|
|
1942
|
+
/**
|
|
1943
|
+
* Get a Handle to a newly created verifier. You should call `pactffi_verifier_shutdown` when
|
|
1944
|
+
* done with the verifier to free all allocated resources
|
|
1945
|
+
*
|
|
1946
|
+
* # Safety
|
|
1947
|
+
*
|
|
1948
|
+
* This function is safe.
|
|
1949
|
+
*
|
|
1950
|
+
* # Error Handling
|
|
1951
|
+
*
|
|
1952
|
+
* Returns NULL on error.
|
|
1953
|
+
*/
|
|
1954
|
+
struct VerifierHandle *pactffi_verifier_new_for_application(const char *name, const char *version);
|
|
1955
|
+
|
|
1546
1956
|
/**
|
|
1547
1957
|
* Shutdown the verifier and release all resources
|
|
1548
1958
|
*/
|
|
@@ -1565,6 +1975,24 @@ void pactffi_verifier_set_provider_info(struct VerifierHandle *handle,
|
|
|
1565
1975
|
unsigned short port,
|
|
1566
1976
|
const char *path);
|
|
1567
1977
|
|
|
1978
|
+
/**
|
|
1979
|
+
* Set the filters for the Pact verifier.
|
|
1980
|
+
*
|
|
1981
|
+
* If `filter_description` is not empty, it needs to be as a regular expression.
|
|
1982
|
+
*
|
|
1983
|
+
* `filter_no_state` is a boolean value. Set it to greater than zero to turn the option on.
|
|
1984
|
+
*
|
|
1985
|
+
* # Safety
|
|
1986
|
+
*
|
|
1987
|
+
* All string fields must contain valid UTF-8. Invalid UTF-8
|
|
1988
|
+
* will be replaced with U+FFFD REPLACEMENT CHARACTER.
|
|
1989
|
+
*
|
|
1990
|
+
*/
|
|
1991
|
+
void pactffi_verifier_set_filter_info(struct VerifierHandle *handle,
|
|
1992
|
+
const char *filter_description,
|
|
1993
|
+
const char *filter_state,
|
|
1994
|
+
unsigned char filter_no_state);
|
|
1995
|
+
|
|
1568
1996
|
/**
|
|
1569
1997
|
* Set the provider state for the Pact verifier.
|
|
1570
1998
|
*
|
|
@@ -1583,9 +2011,8 @@ void pactffi_verifier_set_provider_state(struct VerifierHandle *handle,
|
|
|
1583
2011
|
unsigned char body);
|
|
1584
2012
|
|
|
1585
2013
|
/**
|
|
1586
|
-
* Set the
|
|
2014
|
+
* Set the options used by the verifier when calling the provider
|
|
1587
2015
|
*
|
|
1588
|
-
* `publish` is a boolean value. Set it to greater than zero to turn the option on.
|
|
1589
2016
|
* `disable_ssl_verification` is a boolean value. Set it to greater than zero to turn the option on.
|
|
1590
2017
|
*
|
|
1591
2018
|
* # Safety
|
|
@@ -1595,13 +2022,33 @@ void pactffi_verifier_set_provider_state(struct VerifierHandle *handle,
|
|
|
1595
2022
|
*
|
|
1596
2023
|
*/
|
|
1597
2024
|
int pactffi_verifier_set_verification_options(struct VerifierHandle *handle,
|
|
1598
|
-
unsigned char publish,
|
|
1599
|
-
const char *provider_version,
|
|
1600
|
-
const char *build_url,
|
|
1601
2025
|
unsigned char disable_ssl_verification,
|
|
1602
|
-
unsigned long request_timeout
|
|
1603
|
-
|
|
1604
|
-
|
|
2026
|
+
unsigned long request_timeout);
|
|
2027
|
+
|
|
2028
|
+
/**
|
|
2029
|
+
* Set the options used when publishing verification results to the Pact Broker
|
|
2030
|
+
*
|
|
2031
|
+
* # Args
|
|
2032
|
+
*
|
|
2033
|
+
* - `handle` - The pact verifier handle to update
|
|
2034
|
+
* - `provider_version` - Version of the provider to publish
|
|
2035
|
+
* - `build_url` - URL to the build which ran the verification
|
|
2036
|
+
* - `provider_tags` - Collection of tags for the provider
|
|
2037
|
+
* - `provider_tags_len` - Number of provider tags supplied
|
|
2038
|
+
* - `provider_branch` - Name of the branch used for verification
|
|
2039
|
+
*
|
|
2040
|
+
* # Safety
|
|
2041
|
+
*
|
|
2042
|
+
* All string fields must contain valid UTF-8. Invalid UTF-8
|
|
2043
|
+
* will be replaced with U+FFFD REPLACEMENT CHARACTER.
|
|
2044
|
+
*
|
|
2045
|
+
*/
|
|
2046
|
+
int pactffi_verifier_set_publish_options(struct VerifierHandle *handle,
|
|
2047
|
+
const char *provider_version,
|
|
2048
|
+
const char *build_url,
|
|
2049
|
+
const char *const *provider_tags,
|
|
2050
|
+
unsigned short provider_tags_len,
|
|
2051
|
+
const char *provider_branch);
|
|
1605
2052
|
|
|
1606
2053
|
/**
|
|
1607
2054
|
* Set the consumer filters for the Pact verifier.
|
|
@@ -1616,6 +2063,18 @@ void pactffi_verifier_set_consumer_filters(struct VerifierHandle *handle,
|
|
|
1616
2063
|
const char *const *consumer_filters,
|
|
1617
2064
|
unsigned short consumer_filters_len);
|
|
1618
2065
|
|
|
2066
|
+
/**
|
|
2067
|
+
* Adds a custom header to be added to the requests made to the provider.
|
|
2068
|
+
*
|
|
2069
|
+
* # Safety
|
|
2070
|
+
*
|
|
2071
|
+
* The header name and value must point to a valid NULL terminated string and must contain
|
|
2072
|
+
* valid UTF-8.
|
|
2073
|
+
*/
|
|
2074
|
+
void pactffi_verifier_add_custom_header(struct VerifierHandle *handle,
|
|
2075
|
+
const char *header_name,
|
|
2076
|
+
const char *header_value);
|
|
2077
|
+
|
|
1619
2078
|
/**
|
|
1620
2079
|
* Adds a Pact file as a source to verify.
|
|
1621
2080
|
*
|
|
@@ -1672,7 +2131,6 @@ void pactffi_verifier_url_source(struct VerifierHandle *handle,
|
|
|
1672
2131
|
*/
|
|
1673
2132
|
void pactffi_verifier_broker_source(struct VerifierHandle *handle,
|
|
1674
2133
|
const char *url,
|
|
1675
|
-
const char *provider_name,
|
|
1676
2134
|
const char *username,
|
|
1677
2135
|
const char *password,
|
|
1678
2136
|
const char *token);
|
|
@@ -1700,14 +2158,18 @@ void pactffi_verifier_broker_source(struct VerifierHandle *handle,
|
|
|
1700
2158
|
*/
|
|
1701
2159
|
void pactffi_verifier_broker_source_with_selectors(struct VerifierHandle *handle,
|
|
1702
2160
|
const char *url,
|
|
1703
|
-
const char *provider_name,
|
|
1704
2161
|
const char *username,
|
|
1705
2162
|
const char *password,
|
|
1706
2163
|
const char *token,
|
|
1707
2164
|
unsigned char enable_pending,
|
|
1708
2165
|
const char *include_wip_pacts_since,
|
|
1709
2166
|
const char *const *provider_tags,
|
|
1710
|
-
unsigned short provider_tags_len
|
|
2167
|
+
unsigned short provider_tags_len,
|
|
2168
|
+
const char *provider_branch,
|
|
2169
|
+
const char *const *consumer_version_selectors,
|
|
2170
|
+
unsigned short consumer_version_selectors_len,
|
|
2171
|
+
const char *const *consumer_version_tags,
|
|
2172
|
+
unsigned short consumer_version_tags_len);
|
|
1711
2173
|
|
|
1712
2174
|
/**
|
|
1713
2175
|
* Runs the verification.
|
|
@@ -1787,4 +2249,90 @@ const char *pactffi_verifier_logs(const struct VerifierHandle *handle);
|
|
|
1787
2249
|
*/
|
|
1788
2250
|
const char *pactffi_verifier_logs_for_provider(const char *provider_name);
|
|
1789
2251
|
|
|
2252
|
+
/**
|
|
2253
|
+
* Extracts the standard output for the verification run. The returned string will need to be
|
|
2254
|
+
* freed with the `free_string` function call to avoid leaking memory.
|
|
2255
|
+
*
|
|
2256
|
+
* * `strip_ansi` - This parameter controls ANSI escape codes. Setting it to a non-zero value
|
|
2257
|
+
* will cause the ANSI control codes to be stripped from the output.
|
|
2258
|
+
*
|
|
2259
|
+
* Will return a NULL pointer if the handle is invalid.
|
|
2260
|
+
*/
|
|
2261
|
+
const char *pactffi_verifier_output(const struct VerifierHandle *handle, unsigned char strip_ansi);
|
|
2262
|
+
|
|
2263
|
+
/**
|
|
2264
|
+
* Extracts the verification result as a JSON document. The returned string will need to be
|
|
2265
|
+
* freed with the `free_string` function call to avoid leaking memory.
|
|
2266
|
+
*
|
|
2267
|
+
* Will return a NULL pointer if the handle is invalid.
|
|
2268
|
+
*/
|
|
2269
|
+
const char *pactffi_verifier_json(const struct VerifierHandle *handle);
|
|
2270
|
+
|
|
2271
|
+
/**
|
|
2272
|
+
* Add a plugin to be used by the test. The plugin needs to be installed correctly for this
|
|
2273
|
+
* function to work.
|
|
2274
|
+
*
|
|
2275
|
+
* * `plugin_name` is the name of the plugin to load.
|
|
2276
|
+
* * `plugin_version` is the version of the plugin to load. It is optional, and can be NULL.
|
|
2277
|
+
*
|
|
2278
|
+
* Returns zero on success, and a positive integer value on failure.
|
|
2279
|
+
*
|
|
2280
|
+
* Note that plugins run as separate processes, so will need to be cleaned up afterwards by
|
|
2281
|
+
* calling `pactffi_cleanup_plugins` otherwise you have plugin processes left running.
|
|
2282
|
+
*
|
|
2283
|
+
* # Safety
|
|
2284
|
+
*
|
|
2285
|
+
* `plugin_name` must be a valid pointer to a NULL terminated string. `plugin_version` may be null,
|
|
2286
|
+
* and if not NULL must also be a valid pointer to a NULL terminated string.
|
|
2287
|
+
*
|
|
2288
|
+
* # Errors
|
|
2289
|
+
*
|
|
2290
|
+
* * `1` - A general panic was caught.
|
|
2291
|
+
* * `2` - Failed to load the plugin.
|
|
2292
|
+
* * `3` - Pact Handle is not valid.
|
|
2293
|
+
*
|
|
2294
|
+
* When an error errors, LAST_ERROR will contain the error message.
|
|
2295
|
+
*/
|
|
2296
|
+
unsigned int pactffi_using_plugin(PactHandle pact,
|
|
2297
|
+
const char *plugin_name,
|
|
2298
|
+
const char *plugin_version);
|
|
2299
|
+
|
|
2300
|
+
/**
|
|
2301
|
+
* Decrement the access count on any plugins that are loaded for the Pact. This will shutdown
|
|
2302
|
+
* any plugins that are no longer required (access count is zero).
|
|
2303
|
+
*/
|
|
2304
|
+
void pactffi_cleanup_plugins(PactHandle pact);
|
|
2305
|
+
|
|
2306
|
+
/**
|
|
2307
|
+
* Setup the interaction part using a plugin. The contents is a JSON string that will be passed on to
|
|
2308
|
+
* the plugin to configure the interaction part. Refer to the plugin documentation on the format
|
|
2309
|
+
* of the JSON contents.
|
|
2310
|
+
*
|
|
2311
|
+
* Returns zero on success, and a positive integer value on failure.
|
|
2312
|
+
*
|
|
2313
|
+
* * `interaction` - Handle to the interaction to configure.
|
|
2314
|
+
* * `part` - The part of the interaction to configure (request or response). It is ignored for messages.
|
|
2315
|
+
* * `content_type` - NULL terminated C string of the content type of the part.
|
|
2316
|
+
* * `contents` - NULL terminated C string of the JSON contents that gets passed to the plugin.
|
|
2317
|
+
*
|
|
2318
|
+
* # Safety
|
|
2319
|
+
*
|
|
2320
|
+
* `content_type` and `contents` must be a valid pointers to NULL terminated strings.
|
|
2321
|
+
*
|
|
2322
|
+
* # Errors
|
|
2323
|
+
*
|
|
2324
|
+
* * `1` - A general panic was caught.
|
|
2325
|
+
* * `2` - The mock server has already been started.
|
|
2326
|
+
* * `3` - The interaction handle is invalid.
|
|
2327
|
+
* * `4` - The content type is not valid.
|
|
2328
|
+
* * `5` - The contents JSON is not valid JSON.
|
|
2329
|
+
* * `6` - The plugin returned an error.
|
|
2330
|
+
*
|
|
2331
|
+
* When an error errors, LAST_ERROR will contain the error message.
|
|
2332
|
+
*/
|
|
2333
|
+
unsigned int pactffi_interaction_contents(InteractionHandle interaction,
|
|
2334
|
+
enum InteractionPart part,
|
|
2335
|
+
const char *content_type,
|
|
2336
|
+
const char *contents);
|
|
2337
|
+
|
|
1790
2338
|
#endif /* pact_ffi_h */
|