pact-ffi 0.0.2-x86_64-linux → 0.0.3-x86_64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 796362e12b10b6282483cdb3b62a6b3b607ebe55977a9cd4420eccf91e0c2d55
4
- data.tar.gz: 7b6d3220a258615ad4b2b78eae2347d5b155d8953ea7ad049e54b19f6523455e
3
+ metadata.gz: 9b24f3cc2d7c53327fd4c5fe7e500d8f1a059bfa4ade6e039f68d54780ee464f
4
+ data.tar.gz: 3c59fb16ec399e6bd8ec97b373e8661d6f5d099b62d696f65f5e6712057c68f1
5
5
  SHA512:
6
- metadata.gz: be931f229b00e793a200331630d2290869b5774471a978a2afdf3ba4f1ef520f2355d24af553e0d96033550bd6cd1f7f27cebcac4412454c33425ec500f963b2
7
- data.tar.gz: edc0c87a6ec24169f41dbeb23a43adbc91b6bbd84ee42f42574ac87161e53ae36bfa58f6da9ffe2149812062855a8bafeaa7aebc6e8d188c1a7851ddd4e29f90
6
+ metadata.gz: 25cd2d50d16b9e6809cf27332e49533caacebafc2118ff4011d89ec74cc60fe8094ec5e51e4db14d0bf3eca2a523e13940ff6ce93dc99aa1c5ac30627c76fbd0
7
+ data.tar.gz: 73312fda6349054c5804f7b7f753193830cb2e60da32d592248612ec5e738e1910d71c466a1b2660ddc47079f72d66ba63f03c4c0447c49e71ba257f6c59d405
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Ruby spike gem, to show interactions with the Pact Rust FFI methods.
4
4
 
5
+ Available on RubyGems - https://rubygems.org/gems/pact-ffi
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -12,22 +14,55 @@ gem 'pact-ffi'
12
14
 
13
15
  And then execute:
14
16
 
17
+
15
18
  bundle
16
19
 
20
+
17
21
  Or install it yourself as:
22
+
18
23
 
19
24
  gem install pact-ffi
20
25
 
26
+
21
27
  ## Usage
22
28
 
23
- TODO: Write usage instructions here
29
+ Simple
30
+
31
+ ```ruby
32
+ require 'pact/ffi'
33
+
34
+ puts PactFfi.pactffi_version
35
+ ```
36
+
24
37
 
25
- ## Pre-Reqs
38
+ - See [`lib/pact/ffi.rb`](lib/pact/ffi.rb) for all available methods
39
+ - See [`spec`](spec) folder to see the tests, with the library in use
40
+ - See [`examples/area_calculator`](examples/area_calculator) folder for an example using a pact-plugin, to test the canonical area_calculator example
41
+ - Test it out in your browser, with our Killercoda example! https://killercoda.com/safdotdev/course/safacoda/grpc_plugins_quick_start_ruby
42
+
43
+
44
+ ## Supported Platforms
26
45
 
27
46
  - Ruby
28
- - This gem is compatible with `3.0`
47
+ - This gem is compatible with all the rubies, and various platforms, it comes pre-packaged with the pact_ffi binary for each platform.
48
+
49
+ | OS | Ruby | Architecture | Supported | Ruby Platform |
50
+ | ------- | ------- | ------------ | --------- | --------- |
51
+ | OSX | 2.6 - 3.2 | x86_64 | ✅ | x86_64-darwin |
52
+ | OSX | 2.6 - 3.2 | aarch64 (arm)| ✅ | arm64-darwin |
53
+ | Linux | 2.6 - 3.2 | x86_64 | ✅ | x86_64-linux |
54
+ | Linux | 2.6 - 3.2 | aarch64 (arm)| ✅ | aarch64-linux |
55
+ | Windows | 2.6 - 3.2 | x86_64 | ✅ | x64-mingw-ucrt |
56
+
57
+ You can checkout the ci tests, to see all the architectures, platforms and examples tested
58
+
59
+ - GitHub Actions https://github.com/YOU54F/pact-ruby-ffi/actions
60
+ - Cirrus CI https://cirrus-ci.com/github/YOU54F/pact-ruby-ffi/main
61
+
62
+ _note_ - Alpine is currently not supported, but is on the list
29
63
 
30
64
  - FFI libraries for your current platform - run `./script/download-libs.sh` to download
65
+
31
66
  - If testing the protobuf plugin
32
67
  - `2.7` for protobuf/grpc example
33
68
  - See https://grpc.io/docs/languages/ruby/quickstart/ for steps
@@ -35,6 +70,8 @@ TODO: Write usage instructions here
35
70
  - ruby-grpc is not currently, on m1 hardware for the `pact-protobuf-plugin` example
36
71
  - Have the pact-protobuf plugin available
37
72
  - Run `pact-plugin-cli -y install https://github.com/pactflow/pact-protobuf-plugin/releases/latest`
73
+
74
+
38
75
  ## Development
39
76
 
40
77
  - run `bin/setup` or `bundle install` to install dependencies
Binary file
@@ -0,0 +1,27 @@
1
+ # require 'pact-ffi/version'
2
+ require 'ffi'
3
+ require 'pact/detect_os'
4
+
5
+ module PactFfi
6
+ module AsyncMessageConsumer
7
+ extend FFI::Library
8
+ ffi_lib DetectOS.get_bin_path
9
+
10
+ DetectOS.windows? || DetectOS.linux_arm? ? (typedef :uint32, :uint32_type) : (typedef :uint32_t, :uint32_type)
11
+
12
+ attach_function :new, :pactffi_async_message_new, %i[], :pointer
13
+ attach_function :delete, :pactffi_async_message_delete, %i[pointer], :void
14
+ attach_function :get_contents, :pactffi_async_message_get_contents, %i[pointer], :pointer
15
+ attach_function :get_contents_str, :pactffi_async_message_get_contents_str, %i[pointer], :string
16
+ attach_function :set_contents_str, :pactffi_async_message_set_contents_str, %i[pointer string string], :void
17
+ attach_function :get_contents_length, :pactffi_async_message_get_contents_length, %i[pointer], :size_t
18
+ attach_function :get_contents_bin, :pactffi_async_message_get_contents_bin, %i[pointer], :pointer
19
+ attach_function :set_contents_bin, :pactffi_async_message_set_contents_bin, %i[pointer pointer size_t string], :void
20
+ attach_function :get_description, :pactffi_async_message_get_description, %i[pointer], :string
21
+ attach_function :set_description, :pactffi_async_message_set_description, %i[pointer string], :int32
22
+ attach_function :get_provider_state, :pactffi_async_message_get_provider_state, %i[pointer uint32_type], :pointer
23
+ attach_function :get_provider_state_iter, :pactffi_async_message_get_provider_state_iter, %i[pointer], :pointer
24
+ attach_function :new, :pactffi_new_async_message, %i[uint16 string], :uint32_type
25
+ attach_function :pact_interaction_as_asynchronous_message, :pactffi_pact_interaction_as_asynchronous_message, %i[pointer], :pointer
26
+ end
27
+ end
@@ -0,0 +1,36 @@
1
+ # require 'pact-ffi/version'
2
+ require 'ffi'
3
+ require 'pact/detect_os'
4
+
5
+ module PactFfi
6
+ module HttpConsumer
7
+ extend FFI::Library
8
+ ffi_lib DetectOS.get_bin_path
9
+
10
+ DetectOS.windows? || DetectOS.linux_arm? ? (typedef :uint32, :uint32_type) : (typedef :uint32_t, :uint32_type)
11
+
12
+ attach_function :pact_interaction_iter_next, :pactffi_pact_interaction_iter_next, %i[pointer], :pointer
13
+ attach_function :pact_interaction_iter_delete, :pactffi_pact_interaction_iter_delete, %i[pointer], :void
14
+ attach_function :new_pact, :pactffi_new_pact, %i[string string], :uint16
15
+ attach_function :new_interaction, :pactffi_new_interaction, %i[uint16 string], :uint32_type
16
+ attach_function :upon_receiving, :pactffi_upon_receiving, %i[uint32_type string], :bool
17
+ attach_function :given, :pactffi_given, %i[uint32_type string], :bool
18
+ attach_function :given_with_param, :pactffi_given_with_param, %i[uint32_type string], :bool
19
+ attach_function :given_with_params, :pactffi_given_with_params, %i[uint32_t string string], :int32
20
+ attach_function :interaction_test_name, :pactffi_interaction_test_name, %i[uint32_type string], :uint32_type
21
+ attach_function :given_with_param, :pactffi_given_with_param, %i[uint32_type string string string], :bool
22
+ attach_function :with_request, :pactffi_with_request, %i[uint32_type string string], :bool
23
+ attach_function :with_query_parameter, :pactffi_with_query_parameter, %i[uint32_type string size_t string], :bool
24
+ attach_function :with_query_parameter_v2, :pactffi_with_query_parameter_v2, %i[uint32_type string size_t string],
25
+ :bool
26
+ attach_function :with_specification, :pactffi_with_specification, %i[uint16 int32], :bool
27
+ attach_function :with_pact_metadata, :pactffi_with_pact_metadata, %i[uint16 string string string], :bool
28
+ attach_function :with_header, :pactffi_with_header, %i[uint32_type int32 string size_t string], :bool
29
+ attach_function :with_header_v2, :pactffi_with_header_v2, %i[uint32_type int32 string size_t string], :bool
30
+ attach_function :response_status, :pactffi_response_status, %i[uint32_type uint16], :bool
31
+ attach_function :with_body, :pactffi_with_body, %i[uint32_type int32 string string], :bool
32
+ attach_function :with_binary_file, :pactffi_with_binary_file, %i[uint32_type int32 string pointer size_t], :bool
33
+ attach_function :with_multipart_file, :pactffi_with_multipart_file, %i[uint32_type int32 string string string],
34
+ :pointer
35
+ end
36
+ end
@@ -0,0 +1,33 @@
1
+ # require 'pact-ffi/version'
2
+ require 'ffi'
3
+ require 'pact/detect_os'
4
+
5
+ module PactFfi
6
+ module Logger
7
+ extend FFI::Library
8
+ ffi_lib DetectOS.get_bin_path
9
+
10
+ DetectOS.windows? || DetectOS.linux_arm? ? (typedef :uint32, :uint32_type) : (typedef :uint32_t, :uint32_type)
11
+
12
+ LogLevel = Hash[
13
+ 'OFF' => 0,
14
+ 'ERROR' => 1,
15
+ 'WARN' => 2,
16
+ 'INFO' => 3,
17
+ 'DEBUG' => 4,
18
+ 'TRACE' => 5
19
+ ]
20
+
21
+ attach_function :enable_ansi_support, :pactffi_enable_ansi_support, %i[], :void
22
+ attach_function :log_message, :pactffi_log_message, %i[string string string], :void
23
+ attach_function :get_error_message, :pactffi_get_error_message, %i[string int32], :int32
24
+ attach_function :log_to_stdout, :pactffi_log_to_stdout, %i[int32], :int32
25
+ attach_function :log_to_stderr, :pactffi_log_to_stderr, %i[int32], :int32
26
+ attach_function :log_to_file, :pactffi_log_to_file, %i[string int32], :int32
27
+ attach_function :log_to_buffer, :pactffi_log_to_buffer, %i[int32], :int32
28
+ attach_function :logger_init, :pactffi_logger_init, %i[], :void
29
+ attach_function :attach_sink, :pactffi_logger_attach_sink, %i[string int32], :int32
30
+ attach_function :logger_apply, :pactffi_logger_apply, %i[], :int32
31
+ attach_function :fetch_log_buffer, :pactffi_fetch_log_buffer, %i[string], :string
32
+ end
33
+ end
@@ -0,0 +1,127 @@
1
+ # require 'pact-ffi/version'
2
+ require 'ffi'
3
+ require 'pact/detect_os'
4
+
5
+ module PactFfi
6
+ module MessageConsumer
7
+ extend FFI::Library
8
+ ffi_lib DetectOS.get_bin_path
9
+
10
+ DetectOS.windows? || DetectOS.linux_arm? ? (typedef :uint32, :uint32_type) : (typedef :uint32_t, :uint32_type)
11
+
12
+ FfiSpecificationVersion = Hash[
13
+ 'SPECIFICATION_VERSION_UNKNOWN' => 0,
14
+ 'SPECIFICATION_VERSION_V1' => 1,
15
+ 'SPECIFICATION_VERSION_V1_1' => 2,
16
+ 'SPECIFICATION_VERSION_V2' => 3,
17
+ 'SPECIFICATION_VERSION_V3' => 4,
18
+ 'SPECIFICATION_VERSION_V4' => 5,
19
+ ]
20
+ FfiWritePactResponse = Hash[
21
+ 'SUCCESS' => 0,
22
+ 'GENERAL_PANIC' => 1,
23
+ 'UNABLE_TO_WRITE_PACT_FILE' => 2,
24
+ 'MOCK_SERVER_NOT_FOUND' => 3,
25
+ ]
26
+ FfiWriteMessagePactResponse = Hash[
27
+ 'SUCCESS' => 0,
28
+ 'UNABLE_TO_WRITE_PACT_FILE' => 1,
29
+ 'MESSAGE_HANDLE_INVALID' => 2,
30
+ 'MOCK_SERVER_NOT_FOUND' => 3,
31
+ ]
32
+ FfiConfigurePluginResponse = Hash[
33
+ 'SUCCESS' => 0,
34
+ 'GENERAL_PANIC' => 1,
35
+ 'FAILED_TO_LOAD_PLUGIN' => 2,
36
+ 'PACT_HANDLE_INVALID' => 3,
37
+ ]
38
+ FfiPluginInteractionResponse = Hash[
39
+ 'SUCCESS' => 0,
40
+ 'A_GENERAL_PANIC_WAS_CAUGHT' => 1,
41
+ 'MOCK_SERVER_HAS_ALREADY_BEEN_STARTED' => 2,
42
+ 'INTERACTION_HANDLE_IS_INVALID' => 3,
43
+ 'CONTENT_TYPE_IS_NOT_VALID' => 4,
44
+ 'CONTENTS_JSON_IS_NOT_VALID_JSON' => 5,
45
+ 'PLUGIN_RETURNED_AN_ERROR' => 6,
46
+ ]
47
+ FfiInteractionPart = Hash[
48
+ 'INTERACTION_PART_REQUEST' => 0,
49
+ 'INTERACTION_PART_RESPONSE' => 1,
50
+ ]
51
+ # /*
52
+ # -1 A null pointer was received
53
+ # -2 The pact JSON could not be parsed
54
+ # -3 The mock server could not be started
55
+ # -4 The method panicked
56
+ # -5 The address is not valid
57
+ # -6 Could not create the TLS configuration with the self-signed certificate
58
+ # */
59
+ FfiPluginCreateMockServerErrors = Hash[
60
+ 'NULL_POINTER' => -1,
61
+ 'JSON_PARSE_ERROR' => -2,
62
+ 'MOCK_SERVER_START_FAIL' => -3,
63
+ 'CORE_PANIC' => -4,
64
+ 'ADDRESS_NOT_VALID' => -5,
65
+ 'TLS_CONFIG' => -6,
66
+ ]
67
+
68
+ FfiPluginFunctionResult = Hash[
69
+ 'RESULT_OK' => 0,
70
+ 'RESULT_FAILED' => 1,
71
+ ]
72
+
73
+ attach_function :contents_get_contents_str, :pactffi_message_contents_get_contents_str, %i[pointer], :string
74
+ attach_function :contents_set_contents_str,, :pactffi_message_contents_set_contents_str, %i[pointer string string], :void
75
+ attach_function :contents_get_contents_length, :pactffi_message_contents_get_contents_length, %i[pointer], :size_t
76
+ attach_function :contents_get_contents_bin, :pactffi_message_contents_get_contents_bin, %i[pointer], :pointer
77
+ attach_function :contents_set_contents_bin, :pactffi_message_contents_set_contents_bin, %i[pointer pointer size_t string], :void
78
+ attach_function :contents_get_metadata_iter, :pactffi_message_contents_get_metadata_iter, %i[pointer], :pointer
79
+ attach_function :contents_get_matching_rule_iter, :pactffi_message_contents_get_matching_rule_iter, %i[pointer int32], :pointer
80
+ attach_function :message_contents_get_generators_iter, :pactffi_message_contents_get_generators_iter, %i[pointer int32], :pointer
81
+ attach_function :pact_interaction_as_message, :pactffi_pact_interaction_as_message, %i[pointer], :pointer
82
+ attach_function :new, :pactffi_message_new, %i[], :pointer
83
+ attach_function :new_from_json, :pactffi_message_new_from_json, %i[uint32_type string int32], :pointer
84
+ attach_function :new_from_body, :pactffi_message_new_from_body, %i[string string], :pointer
85
+ attach_function :delete, :pactffi_message_delete, %i[pointer], :void
86
+ attach_function :get_contents, :pactffi_message_get_contents, %i[pointer], :string
87
+ attach_function :set_contents, :pactffi_message_set_contents, %i[pointer string string], :void
88
+ attach_function :get_contents_length, :pactffi_message_get_contents_length, %i[pointer], :size_t
89
+ attach_function :get_contents_bin, :pactffi_message_get_contents_bin, %i[pointer], :pointer
90
+ attach_function :set_contents_bin, :pactffi_message_set_contents_bin, %i[pointer pointer size_t string], :void
91
+ attach_function :get_description, :pactffi_message_get_description, %i[pointer], :string
92
+ attach_function :set_description, :pactffi_message_set_description, %i[pointer string], :int32
93
+ attach_function :get_provider_state, :pactffi_message_get_provider_state, %i[pointer uint32_type], :pointer
94
+ attach_function :get_provider_state_iter, :pactffi_message_get_provider_state_iter, %i[pointer], :pointer
95
+ attach_function :find_metadata, :pactffi_message_find_metadata, %i[pointer string], :string
96
+ attach_function :insert_metadata, :pactffi_message_insert_metadata, %i[pointer string string], :int32
97
+ attach_function :metadata_iter_next, :pactffi_message_metadata_iter_next, %i[pointer], :pointer
98
+ attach_function :get_metadata_iter, :pactffi_message_get_metadata_iter, %i[pointer], :pointer
99
+ attach_function :metadata_iter_delete, :pactffi_message_metadata_iter_delete, %i[pointer], :void
100
+ attach_function :metadata_pair_delete, :pactffi_message_metadata_pair_delete, %i[pointer], :void
101
+ attach_function :new_from_json, :pactffi_message_pact_new_from_json, %i[string string], :pointer
102
+ attach_function :delete, :pactffi_message_pact_delete, %i[pointer], :void
103
+ attach_function :get_consumer, :pactffi_message_pact_get_consumer, %i[pointer], :pointer
104
+ attach_function :get_provider, :pactffi_message_pact_get_provider, %i[pointer], :pointer
105
+ attach_function :get_message_iter, :pactffi_message_pact_get_message_iter, %i[pointer], :pointer
106
+ attach_function :message_iter_next, :pactffi_message_pact_message_iter_next, %i[pointer], :pointer
107
+ attach_function :message_iter_delete, :pactffi_message_pact_message_iter_delete, %i[pointer], :void
108
+ attach_function :find_metadata, :pactffi_message_pact_find_metadata, %i[pointer string string], :string
109
+ attach_function :get_metadata_iter, :pactffi_message_pact_get_metadata_iter, %i[pointer], :pointer
110
+ attach_function :metadata_iter_next, :pactffi_message_pact_metadata_iter_next, %i[pointer], :pointer
111
+ attach_function :metadata_iter_delete, :pactffi_message_pact_metadata_iter_delete, %i[pointer], :void
112
+ attach_function :metadata_triple_delete, :pactffi_message_pact_metadata_triple_delete, %i[pointer], :void
113
+ attach_function :new_message_interaction, :pactffi_new_message_interaction, %i[uint16 string], :uint32_type
114
+ attach_function :new_message_pact, :pactffi_new_message_pact, %i[string string], :uint16
115
+ attach_function :new_message, :pactffi_new_message, %i[uint16 string], :uint32_type
116
+ attach_function :expects_to_receive, :pactffi_message_expects_to_receive, %i[uint32_type string], :void
117
+ attach_function :given, :pactffi_message_given, %i[uint32_type string], :void
118
+ attach_function :given_with_param, :pactffi_message_given_with_param, %i[uint32_type string string string], :void
119
+ attach_function :with_contents, :pactffi_message_with_contents, %i[uint32_type string pointer size_t], :void
120
+ attach_function :with_metadata, :pactffi_message_with_metadata, %i[uint32_type string string], :void
121
+ attach_function :rreify, :pactffi_message_reify, %i[uint32_type], :string
122
+ attach_function :write_message_pact_file, :pactffi_write_message_pact_file, %i[uint16 string bool], :int32
123
+ attach_function :with_message_pact_metadata, :pactffi_with_message_pact_metadata, %i[uint16 string string string], :void
124
+ attach_function :free_handle, :pactffi_free_message_pact_handle, %i[uint16], :uint32_type
125
+ attach_function :pact_handle_get_message_iter, :pactffi_pact_handle_get_message_iter, %i[uint16], :pointer
126
+ end
127
+ end
@@ -0,0 +1,83 @@
1
+ # require 'pact-ffi/version'
2
+ require 'ffi'
3
+ require 'pact/detect_os'
4
+
5
+ module PactFfi
6
+ module MockServer
7
+ extend FFI::Library
8
+ ffi_lib DetectOS.get_bin_path
9
+
10
+ DetectOS.windows? || DetectOS.linux_arm? ? (typedef :uint32, :uint32_type) : (typedef :uint32_t, :uint32_type)
11
+
12
+ FfiSpecificationVersion = Hash[
13
+ 'SPECIFICATION_VERSION_UNKNOWN' => 0,
14
+ 'SPECIFICATION_VERSION_V1' => 1,
15
+ 'SPECIFICATION_VERSION_V1_1' => 2,
16
+ 'SPECIFICATION_VERSION_V2' => 3,
17
+ 'SPECIFICATION_VERSION_V3' => 4,
18
+ 'SPECIFICATION_VERSION_V4' => 5,
19
+ ]
20
+ FfiWritePactResponse = Hash[
21
+ 'SUCCESS' => 0,
22
+ 'GENERAL_PANIC' => 1,
23
+ 'UNABLE_TO_WRITE_PACT_FILE' => 2,
24
+ 'MOCK_SERVER_NOT_FOUND' => 3,
25
+ ]
26
+ FfiWriteMessagePactResponse = Hash[
27
+ 'SUCCESS' => 0,
28
+ 'UNABLE_TO_WRITE_PACT_FILE' => 1,
29
+ 'MESSAGE_HANDLE_INVALID' => 2,
30
+ 'MOCK_SERVER_NOT_FOUND' => 3,
31
+ ]
32
+ FfiConfigurePluginResponse = Hash[
33
+ 'SUCCESS' => 0,
34
+ 'GENERAL_PANIC' => 1,
35
+ 'FAILED_TO_LOAD_PLUGIN' => 2,
36
+ 'PACT_HANDLE_INVALID' => 3,
37
+ ]
38
+ FfiPluginInteractionResponse = Hash[
39
+ 'SUCCESS' => 0,
40
+ 'A_GENERAL_PANIC_WAS_CAUGHT' => 1,
41
+ 'MOCK_SERVER_HAS_ALREADY_BEEN_STARTED' => 2,
42
+ 'INTERACTION_HANDLE_IS_INVALID' => 3,
43
+ 'CONTENT_TYPE_IS_NOT_VALID' => 4,
44
+ 'CONTENTS_JSON_IS_NOT_VALID_JSON' => 5,
45
+ 'PLUGIN_RETURNED_AN_ERROR' => 6,
46
+ ]
47
+ FfiInteractionPart = Hash[
48
+ 'INTERACTION_PART_REQUEST' => 0,
49
+ 'INTERACTION_PART_RESPONSE' => 1,
50
+ ]
51
+ # /*
52
+ # -1 A null pointer was received
53
+ # -2 The pact JSON could not be parsed
54
+ # -3 The mock server could not be started
55
+ # -4 The method panicked
56
+ # -5 The address is not valid
57
+ # -6 Could not create the TLS configuration with the self-signed certificate
58
+ # */
59
+ FfiPluginCreateMockServerErrors = Hash[
60
+ 'NULL_POINTER' => -1,
61
+ 'JSON_PARSE_ERROR' => -2,
62
+ 'MOCK_SERVER_START_FAIL' => -3,
63
+ 'CORE_PANIC' => -4,
64
+ 'ADDRESS_NOT_VALID' => -5,
65
+ 'TLS_CONFIG' => -6,
66
+ ]
67
+
68
+ FfiPluginFunctionResult = Hash[
69
+ 'RESULT_OK' => 0,
70
+ 'RESULT_FAILED' => 1,
71
+ ]
72
+
73
+ attach_function :create, :pactffi_create_mock_server, %i[string string bool], :int32
74
+ attach_function :get_tls_cert, :pactffi_get_tls_ca_certificate, %i[], :string
75
+ attach_function :create_for_pact, :pactffi_create_mock_server_for_pact, %i[uint16 string bool], :int32
76
+ attach_function :create_for_transport, :pactffi_create_mock_server_for_transport, %i[uint16 string uint16 string string], :int32
77
+ attach_function :matched, :pactffi_mock_server_matched, %i[int32], :bool
78
+ attach_function :mismatches, :pactffi_mock_server_mismatches, %i[int32], :string
79
+ attach_function :cleanup, :pactffi_cleanup_mock_server, %i[int32], :bool
80
+ attach_function :write_pact_file, :pactffi_write_pact_file, %i[int32 string bool], :int32
81
+ attach_function :logs, :pactffi_mock_server_logs, %i[int32], :string
82
+ end
83
+ end
@@ -0,0 +1,39 @@
1
+ # require 'pact-ffi/version'
2
+ require 'ffi'
3
+ require 'pact/detect_os'
4
+
5
+ module PactFfi
6
+ module PluginConsumer
7
+ extend FFI::Library
8
+ ffi_lib DetectOS.get_bin_path
9
+
10
+ DetectOS.windows? || DetectOS.linux_arm? ? (typedef :uint32, :uint32_type) : (typedef :uint32_t, :uint32_type)
11
+
12
+ # /*
13
+ # -1 A null pointer was received
14
+ # -2 The pact JSON could not be parsed
15
+ # -3 The mock server could not be started
16
+ # -4 The method panicked
17
+ # -5 The address is not valid
18
+ # -6 Could not create the TLS configuration with the self-signed certificate
19
+ # */
20
+ CreateMockServerErrors = Hash[
21
+ 'NULL_POINTER' => -1,
22
+ 'JSON_PARSE_ERROR' => -2,
23
+ 'MOCK_SERVER_START_FAIL' => -3,
24
+ 'CORE_PANIC' => -4,
25
+ 'ADDRESS_NOT_VALID' => -5,
26
+ 'TLS_CONFIG' => -6,
27
+ ]
28
+
29
+ PluginFunctionResult = Hash[
30
+ 'RESULT_OK' => 0,
31
+ 'RESULT_FAILED' => 1,
32
+ ]
33
+
34
+ attach_function :using_plugin, :pactffi_using_plugin, %i[uint16 string string], :uint32_type
35
+ attach_function :cleanup_plugins, :pactffi_cleanup_plugins, %i[uint16], :void
36
+ attach_function :interaction_contents, :pactffi_interaction_contents, %i[uint32_type int32 string string],
37
+ :uint32_type
38
+ end
39
+ end
@@ -0,0 +1,35 @@
1
+ # require 'pact-ffi/version'
2
+ require 'ffi'
3
+ require 'pact/detect_os'
4
+
5
+ module PactFfi
6
+ module SyncHttpConsumer
7
+ extend FFI::Library
8
+ ffi_lib DetectOS.get_bin_path
9
+
10
+ DetectOS.windows? || DetectOS.linux_arm? ? (typedef :uint32, :uint32_type) : (typedef :uint32_t, :uint32_type)
11
+
12
+ attach_function :new, :pactffi_sync_http_new, %i[], :pointer
13
+ attach_function :delete, :pactffi_sync_http_delete, %i[pointer], :void
14
+ attach_function :get_request, :pactffi_sync_http_get_request, %i[pointer], :pointer
15
+ attach_function :get_request_contents, :pactffi_sync_http_get_request_contents, %i[pointer], :string
16
+ attach_function :set_request_contents, :pactffi_sync_http_set_request_contents, %i[pointer string string], :void
17
+ attach_function :get_request_contents_length, :pactffi_sync_http_get_request_contents_length, %i[pointer], :size_t
18
+ attach_function :get_request_contents_bin, :pactffi_sync_http_get_request_contents_bin, %i[pointer], :pointer
19
+ attach_function :set_request_contents_bin, :pactffi_sync_http_set_request_contents_bin, %i[pointer pointer size_t string], :void
20
+ attach_function :get_response, :pactffi_sync_http_get_response, %i[pointer], :pointer
21
+ attach_function :get_response_contents, :pactffi_sync_http_get_response_contents, %i[pointer], :string
22
+ attach_function :set_response_contents, :pactffi_sync_http_set_response_contents, %i[pointer string string], :void
23
+ attach_function :get_response_contents_length, :pactffi_sync_http_get_response_contents_length, %i[pointer], :size_t
24
+ attach_function :get_response_contents_bin, :pactffi_sync_http_get_response_contents_bin, %i[pointer], :pointer
25
+ attach_function :set_response_contents_bin, :pactffi_sync_http_set_response_contents_bin, %i[pointer pointer size_t string], :void
26
+ attach_function :get_description, :pactffi_sync_http_get_description, %i[pointer], :string
27
+ attach_function :set_description, :pactffi_sync_http_set_description, %i[pointer string], :int32
28
+ attach_function :get_provider_state, :pactffi_sync_http_get_provider_state, %i[pointer uint32_type], :pointer
29
+ attach_function :get_provider_state_iter, :pactffi_sync_http_get_provider_state_iter, %i[pointer], :pointer
30
+ attach_function :pact_interaction_as_synchronous_http, :pactffi_pact_interaction_as_synchronous_http, %i[pointer], :pointer
31
+ attach_function :iter_next, :pactffi_pact_sync_http_iter_next, %i[pointer], :pointer
32
+ attach_function :iter_delete, :pactffi_pact_sync_http_iter_delete, %i[pointer], :void
33
+ attach_function :pact_handle_get_sync_http_iter, :pactffi_pact_handle_get_sync_http_iter, %i[uint16], :pointer
34
+ end
35
+ end
@@ -0,0 +1,37 @@
1
+ # require 'pact-ffi/version'
2
+ require 'ffi'
3
+ require 'pact/detect_os'
4
+
5
+ module PactFfi
6
+ module SyncMessageConsumer
7
+ extend FFI::Library
8
+ ffi_lib DetectOS.get_bin_path
9
+
10
+ DetectOS.windows? || DetectOS.linux_arm? ? (typedef :uint32, :uint32_type) : (typedef :uint32_t, :uint32_type)
11
+
12
+ attach_function :pact_interaction_as_synchronous_message, :pactffi_pact_interaction_as_synchronous_message, %i[pointer], :pointer
13
+ attach_function :iter_next, :pactffi_pact_sync_message_iter_next, %i[pointer], :pointer
14
+ attach_function :iter_delete, :pactffi_pact_sync_message_iter_delete, %i[pointer], :void
15
+ attach_function :new, :pactffi_sync_message_new, %i[], :pointer
16
+ attach_function :delete, :pactffi_sync_message_delete, %i[pointer], :void
17
+ attach_function :get_request_contents_str, :pactffi_sync_message_get_request_contents_str, %i[pointer], :string
18
+ attach_function :set_request_contents_str, :pactffi_sync_message_set_request_contents_str, %i[pointer string string], :void
19
+ attach_function :get_request_contents_length, :pactffi_sync_message_get_request_contents_length, %i[pointer], :size_t
20
+ attach_function :get_request_contents_bin, :pactffi_sync_message_get_request_contents_bin, %i[pointer], :pointer
21
+ attach_function :set_request_contents_bin, :pactffi_sync_message_set_request_contents_bin, %i[pointer pointer size_t string], :void
22
+ attach_function :get_request_contents, :pactffi_sync_message_get_request_contents, %i[pointer], :pointer
23
+ attach_function :get_number_responses, :pactffi_sync_message_get_number_responses, %i[pointer], :size_t
24
+ attach_function :get_response_contents_str, :pactffi_sync_message_get_response_contents_str, %i[pointer size_t], :string
25
+ attach_function :set_response_contents_str, :pactffi_sync_message_set_response_contents_str, %i[pointer size_t string string], :void
26
+ attach_function :get_response_contents_length, :pactffi_sync_message_get_response_contents_length, %i[pointer size_t], :size_t
27
+ attach_function :get_response_contents_bin, :pactffi_sync_message_get_response_contents_bin, %i[pointer size_t], :pointer
28
+ attach_function :set_response_contents_bin, :pactffi_sync_message_set_response_contents_bin, %i[pointer size_t pointer size_t string], :void
29
+ attach_function :get_response_contents, :pactffi_sync_message_get_response_contents, %i[pointer size_t], :pointer
30
+ attach_function :get_description, :pactffi_sync_message_get_description, %i[pointer], :string
31
+ attach_function :set_description, :pactffi_sync_message_set_description, %i[pointer string], :int32
32
+ attach_function :get_provider_state, :pactffi_sync_message_get_provider_state, %i[pointer uint32_type], :pointer
33
+ attach_function :get_provider_state_iter, :pactffi_sync_message_get_provider_state_iter, %i[pointer], :pointer
34
+ attach_function :new_interaction, :pactffi_new_sync_message_interaction, %i[uint16 string], :uint32_type
35
+ attach_function :pact_handle_get_sync_message_iter, :pactffi_pact_handle_get_sync_message_iter, %i[uint16], :pointer
36
+ end
37
+ end