pact-ffi 0.4.22.2-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cb695f04726bddb3b16ea6462a330a960bb011fff8d4820860b4bcbeccf78039
4
+ data.tar.gz: 2fe4b533a02c1848dfdc6e4a4048466d1ce5ae1aa1ae15485553ce1aeb47fd81
5
+ SHA512:
6
+ metadata.gz: 561ed6559bd8510eea5bdc9db88690f63065d191bd982000753c01af41b120c25b4539a82dbc37c09eaae4d0e40cd619d3371ecc9a59f7cde9f4732e261315e3
7
+ data.tar.gz: 91afad5d421437b8a6ef94b68bd573061cab734a168b4921fdc5ebcf08b6ef526b12e1be662fafef78af79ef453c3aeee549edaa31c1cdd0a06bcf0faa702c7a
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Yousaf Nabi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # PactFfi
2
+
3
+ Ruby spike gem, to show interactions with the Pact Rust FFI methods.
4
+
5
+ Available on RubyGems - <https://rubygems.org/gems/pact-ffi>
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'pact-ffi'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ gem install pact-ffi
22
+
23
+ ## Usage
24
+
25
+ Simple
26
+
27
+ ```ruby
28
+ require 'pact/ffi'
29
+
30
+ puts PactFfi.pactffi_version
31
+ ```
32
+
33
+ - See [`lib/pact/ffi.rb`](lib/pact/ffi.rb) for all available methods
34
+ - See [`spec`](spec) folder to see the tests, with the library in use
35
+ - See [`examples/area_calculator`](examples/area_calculator) folder for an example using a pact-plugin, to test the canonical area_calculator example
36
+ - Test it out in your browser, with our Killercoda example! <https://killercoda.com/safdotdev/course/safacoda/grpc_plugins_quick_start_ruby>
37
+
38
+ ## Supported Platforms
39
+
40
+ - Ruby
41
+ - This gem is compatible with all the rubies, and various platforms, it comes pre-packaged with the pact_ffi binary for each platform.
42
+
43
+ | OS | Ruby | Architecture | Supported | Ruby Platform |
44
+ | ------- | ------- | ------------ | --------- | --------- |
45
+ | OSX | 2.6 - 3.3 | x86_64 | ✅ | x86_64-darwin |
46
+ | OSX | 2.6 - 3.3 | aarch64 (arm)| ✅ | arm64-darwin |
47
+ | Linux | 2.6 - 3.3 | x86_64 | ✅ | x86_64-linux |
48
+ | Linux | 2.6 - 3.3 | aarch64 (arm)| ✅ | aarch64-linux |
49
+ | Linux (musl) | 2.6 - 3.3 | x86_64 | ✅ | x86_64-linux-musl |
50
+ | Linux (musl) | 2.6 - 3.3 | aarch64 (arm)| ✅ | aarch64-linux-musl|
51
+ | Windows | 2.6 - 3.3 | x86_64 | ✅ | x64-mingw-ucrt |
52
+
53
+ You can checkout the ci tests, to see all the architectures, platforms and examples tested
54
+
55
+ - GitHub Actions <https://github.com/YOU54F/pact-ruby-ffi/actions>
56
+ - Cirrus CI <https://cirrus-ci.com/github/YOU54F/pact-ruby-ffi/main>
57
+
58
+ _note_ - Alpine is currently not supported, but is on the list
59
+
60
+ - FFI libraries for your current platform - run `./script/download-libs.sh` to download
61
+
62
+ - If testing the protobuf plugin
63
+ - `3.0` for protobuf/grpc example
64
+ - See <https://grpc.io/docs/languages/ruby/quickstart/> for steps
65
+ - See `examples/proto-ruby/README.md` for notes
66
+ - ruby-grpc is not currently, on m1 hardware for the `pact-protobuf-plugin` example
67
+ - Have the pact-protobuf plugin available
68
+ - Run `pact-plugin-cli -y install https://github.com/pactflow/pact-protobuf-plugin/releases/latest`
69
+
70
+ ## Development
71
+
72
+ - run `bin/setup` or `bundle install` to install dependencies
73
+ - run `./script/download-libs.sh` to download FFI libraries for your current platform
74
+ - run `rake spec` to run tests
75
+
76
+ ## Contributing
77
+
78
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/[USERNAME>]/pact-ffi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
79
+
80
+ ## License
81
+
82
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
83
+
84
+ ## Code of Conduct
85
+
86
+ Everyone interacting in the PactFfi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/pact-ffi/blob/master/CODE_OF_CONDUCT.md).
87
+
88
+ ## Pact Compatibility Suite
89
+
90
+ Help us implement the [Pact Compatibility Suite](https://github.com/pact-foundation/pact-compatibility-suite)
91
+
92
+ ```
93
+ compatibility-suite/pact-compatibility-suite/features
94
+ ├── V1
95
+ │ ├── http_consumer.feature
96
+ │ └── http_provider.feature
97
+ ├── V2
98
+ │ ├── http_consumer.feature
99
+ │ └── http_provider.feature
100
+ ├── V3
101
+ │ ├── generators.feature
102
+ │ ├── http_consumer.feature
103
+ │ ├── http_generators.feature
104
+ │ ├── http_matching.feature
105
+ │ ├── http_provider.feature
106
+ │ ├── matching_rules.feature
107
+ │ ├── message_consumer.feature
108
+ │ └── message_provider.feature
109
+ ├── V4
110
+ │ ├── generators.feature
111
+ │ ├── http_consumer.feature ✅
112
+ │ ├── http_provider.feature
113
+ │ ├── matching_rules.feature
114
+ │ ├── message_consumer.feature ✅
115
+ │ ├── message_provider.feature ✅
116
+ │ ├── synchronous_message_consumer.feature ✅
117
+ │ └── v4.feature ✅
118
+ ```
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pact-ffi"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
Binary file
@@ -0,0 +1,80 @@
1
+ module DetectOS
2
+ def self.windows?
3
+ return if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RbConfig::CONFIG['arch']).nil?
4
+ true
5
+ end
6
+
7
+ def self.mac_arm?
8
+ return unless !(/darwin/ =~ RbConfig::CONFIG['arch']).nil? && !(/arm64/ =~ RbConfig::CONFIG['arch']).nil?
9
+ true
10
+ end
11
+
12
+ def self.mac?
13
+ return unless !(/darwin/ =~ RbConfig::CONFIG['arch']).nil? && !(/x86_64/ =~ RbConfig::CONFIG['arch']).nil?
14
+ true
15
+ end
16
+
17
+ def self.linux_arm_musl?
18
+ return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/aarch64/ =~ RbConfig::CONFIG['arch']).nil? && !(/musl/ =~ RbConfig::CONFIG['arch']).nil?
19
+ true
20
+ end
21
+
22
+ def self.linux_musl?
23
+ return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/x86_64/ =~ RbConfig::CONFIG['arch']).nil?&& !(/musl/ =~ RbConfig::CONFIG['arch']).nil?
24
+ true
25
+ end
26
+ def self.linux_arm?
27
+ return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/aarch64/ =~ RbConfig::CONFIG['arch']).nil?
28
+ true
29
+ end
30
+
31
+ def self.linux?
32
+ return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/x86_64/ =~ RbConfig::CONFIG['arch']).nil?
33
+ true
34
+ end
35
+
36
+ def self.debug?
37
+ return if ENV['DEBUG_TARGET'].nil?
38
+ true
39
+ end
40
+
41
+ def self.get_bin_path
42
+ if debug?
43
+ ENV['DEBUG_TARGET'].to_s
44
+ elsif windows?
45
+ File.join(__dir__, '../../ffi/windows-x64/pact_ffi.dll')
46
+ elsif mac_arm?
47
+ File.join(__dir__, '../../ffi/macos-arm64/libpact_ffi.dylib')
48
+ elsif mac?
49
+ File.join(__dir__, '../../ffi/macos-x64/libpact_ffi.dylib')
50
+ elsif linux_arm_musl?
51
+ File.join(__dir__, '../../ffi/linux-arm64-musl/libpact_ffi.so')
52
+ elsif linux_musl?
53
+ File.join(__dir__, '../../ffi/linux-x64-musl/libpact_ffi.so')
54
+ elsif linux_arm?
55
+ File.join(__dir__, '../../ffi/linux-arm64/libpact_ffi.so')
56
+ elsif linux?
57
+ File.join(__dir__, '../../ffi/linux-x64/libpact_ffi.so')
58
+ else
59
+ raise "Detected #{RbConfig::CONFIG['arch']}-- I have no idea what to do with that."
60
+ end
61
+ end
62
+
63
+ def self.get_os
64
+ if windows?
65
+ 'win'
66
+ elsif mac_arm?
67
+ 'macos-arm64'
68
+ elsif mac?
69
+ 'linux-x8664'
70
+ elsif linux_arm?
71
+ 'linux-aarch64'
72
+ elsif linux?
73
+ 'linux-x8664'
74
+ else
75
+ raise "Detected #{RbConfig::CONFIG['arch']}-- I have no idea what to do with that."
76
+ end
77
+ end
78
+ end
79
+
80
+ ENV['PACT_DEBUG'] ? (puts "Detected platform: #{RbConfig::CONFIG['arch']} \nLoad Path: #{DetectOS.get_bin_path}" ): nil
@@ -0,0 +1,29 @@
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
+ (typedef :uint32, :uint32_type)
12
+
13
+ attach_function :new_async_message, :pactffi_async_message_new, %i[], :pointer
14
+ attach_function :delete, :pactffi_async_message_delete, %i[pointer], :void
15
+ attach_function :get_contents, :pactffi_async_message_get_contents, %i[pointer], :pointer
16
+ attach_function :get_contents_str, :pactffi_async_message_get_contents_str, %i[pointer], :string
17
+ attach_function :set_contents_str, :pactffi_async_message_set_contents_str, %i[pointer string string], :void
18
+ attach_function :get_contents_length, :pactffi_async_message_get_contents_length, %i[pointer], :size_t
19
+ attach_function :get_contents_bin, :pactffi_async_message_get_contents_bin, %i[pointer], :pointer
20
+ attach_function :set_contents_bin, :pactffi_async_message_set_contents_bin, %i[pointer pointer size_t string], :void
21
+ attach_function :get_description, :pactffi_async_message_get_description, %i[pointer], :string
22
+ attach_function :set_description, :pactffi_async_message_set_description, %i[pointer string], :int32
23
+ attach_function :get_provider_state, :pactffi_async_message_get_provider_state, %i[pointer uint32_type], :pointer
24
+ attach_function :get_provider_state_iter, :pactffi_async_message_get_provider_state_iter, %i[pointer], :pointer
25
+ attach_function :new, :pactffi_new_async_message, %i[uint16 string], :uint32_type
26
+ attach_function :pact_interaction_as_asynchronous_message, :pactffi_pact_interaction_as_asynchronous_message,
27
+ %i[pointer], :pointer
28
+ end
29
+ end
@@ -0,0 +1,40 @@
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
+ (typedef :uint32, :uint32_type)
12
+
13
+ attach_function :pact_interaction_iter_next, :pactffi_pact_interaction_iter_next, %i[pointer], :pointer
14
+ attach_function :pact_interaction_iter_delete, :pactffi_pact_interaction_iter_delete, %i[pointer], :void
15
+ attach_function :new_pact, :pactffi_new_pact, %i[string string], :uint16
16
+ attach_function :new_interaction, :pactffi_new_interaction, %i[uint16 string], :uint32_type
17
+ attach_function :upon_receiving, :pactffi_upon_receiving, %i[uint32_type string], :bool
18
+ attach_function :given, :pactffi_given, %i[uint32_type string], :bool
19
+ attach_function :given_with_param, :pactffi_given_with_param, %i[uint32_type string], :bool
20
+ attach_function :given_with_params, :pactffi_given_with_params, %i[uint32_type string string], :int32
21
+ attach_function :interaction_test_name, :pactffi_interaction_test_name, %i[uint32_type string], :uint32_type
22
+ attach_function :given_with_param, :pactffi_given_with_param, %i[uint32_type string string string], :bool
23
+ attach_function :with_request, :pactffi_with_request, %i[uint32_type string string], :bool
24
+ attach_function :with_query_parameter, :pactffi_with_query_parameter, %i[uint32_type string size_t string], :bool
25
+ attach_function :with_query_parameter_v2, :pactffi_with_query_parameter_v2, %i[uint32_type string size_t string],
26
+ :bool
27
+ attach_function :with_specification, :pactffi_with_specification, %i[uint16 int32], :bool
28
+ attach_function :with_pact_metadata, :pactffi_with_pact_metadata, %i[uint16 string string string], :bool
29
+ attach_function :with_header, :pactffi_with_header, %i[uint32_type int32 string size_t string], :bool
30
+ attach_function :with_header_v2, :pactffi_with_header_v2, %i[uint32_type int32 string size_t string], :bool
31
+ attach_function :response_status, :pactffi_response_status, %i[uint32_type uint16], :bool
32
+ attach_function :with_body, :pactffi_with_body, %i[uint32_type int32 string string], :bool
33
+ attach_function :with_binary_file, :pactffi_with_binary_file, %i[uint32_type int32 string pointer size_t], :bool
34
+ attach_function :with_multipart_file, :pactffi_with_multipart_file, %i[uint32_type int32 string string string], :pointer
35
+ attach_function :set_header, :pactffi_set_header, %i[uint32_type int32 string string], :bool
36
+ attach_function :with_binary_body, :pactffi_with_binary_body, %i[uint32_type int32 string pointer size_t], :bool
37
+ attach_function :with_matching_rules, :pactffi_with_matching_rules, %i[uint32_type int32 string], :bool
38
+ attach_function :with_multipart_file_v2, :pactffi_with_multipart_file_v2, %i[uint32_type int32 string string string string], :pointer
39
+ end
40
+ end
@@ -0,0 +1,34 @@
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
+ (typedef :uint32, :uint32_type)
12
+
13
+ LogLevel = Hash[
14
+ 'OFF' => 0,
15
+ 'ERROR' => 1,
16
+ 'WARN' => 2,
17
+ 'INFO' => 3,
18
+ 'DEBUG' => 4,
19
+ 'TRACE' => 5
20
+ ]
21
+
22
+ attach_function :enable_ansi_support, :pactffi_enable_ansi_support, %i[], :void
23
+ attach_function :message, :pactffi_log_message, %i[string string string], :void
24
+ attach_function :get_error_message, :pactffi_get_error_message, %i[string int32], :int32
25
+ attach_function :log_to_stdout, :pactffi_log_to_stdout, %i[int32], :int32
26
+ attach_function :log_to_stderr, :pactffi_log_to_stderr, %i[int32], :int32
27
+ attach_function :log_to_file, :pactffi_log_to_file, %i[string int32], :int32
28
+ attach_function :log_to_buffer, :pactffi_log_to_buffer, %i[int32], :int32
29
+ attach_function :init, :pactffi_logger_init, %i[], :void
30
+ attach_function :attach_sink, :pactffi_logger_attach_sink, %i[string int32], :int32
31
+ attach_function :apply, :pactffi_logger_apply, %i[], :int32
32
+ attach_function :fetch_log_buffer, :pactffi_fetch_log_buffer, %i[string], :string
33
+ end
34
+ end
@@ -0,0 +1,129 @@
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
+ (typedef :uint32, :uint32_type)
12
+
13
+ FfiSpecificationVersion = Hash[
14
+ 'SPECIFICATION_VERSION_UNKNOWN' => 0,
15
+ 'SPECIFICATION_VERSION_V1' => 1,
16
+ 'SPECIFICATION_VERSION_V1_1' => 2,
17
+ 'SPECIFICATION_VERSION_V2' => 3,
18
+ 'SPECIFICATION_VERSION_V3' => 4,
19
+ 'SPECIFICATION_VERSION_V4' => 5,
20
+ ]
21
+ FfiWritePactResponse = Hash[
22
+ 'SUCCESS' => 0,
23
+ 'GENERAL_PANIC' => 1,
24
+ 'UNABLE_TO_WRITE_PACT_FILE' => 2,
25
+ 'MOCK_SERVER_NOT_FOUND' => 3,
26
+ ]
27
+ FfiWriteMessagePactResponse = Hash[
28
+ 'SUCCESS' => 0,
29
+ 'UNABLE_TO_WRITE_PACT_FILE' => 1,
30
+ 'MESSAGE_HANDLE_INVALID' => 2,
31
+ 'MOCK_SERVER_NOT_FOUND' => 3,
32
+ ]
33
+ FfiConfigurePluginResponse = Hash[
34
+ 'SUCCESS' => 0,
35
+ 'GENERAL_PANIC' => 1,
36
+ 'FAILED_TO_LOAD_PLUGIN' => 2,
37
+ 'PACT_HANDLE_INVALID' => 3,
38
+ ]
39
+ FfiPluginInteractionResponse = Hash[
40
+ 'SUCCESS' => 0,
41
+ 'A_GENERAL_PANIC_WAS_CAUGHT' => 1,
42
+ 'MOCK_SERVER_HAS_ALREADY_BEEN_STARTED' => 2,
43
+ 'INTERACTION_HANDLE_IS_INVALID' => 3,
44
+ 'CONTENT_TYPE_IS_NOT_VALID' => 4,
45
+ 'CONTENTS_JSON_IS_NOT_VALID_JSON' => 5,
46
+ 'PLUGIN_RETURNED_AN_ERROR' => 6,
47
+ ]
48
+ FfiInteractionPart = Hash[
49
+ 'INTERACTION_PART_REQUEST' => 0,
50
+ 'INTERACTION_PART_RESPONSE' => 1,
51
+ ]
52
+ # /*
53
+ # -1 A null pointer was received
54
+ # -2 The pact JSON could not be parsed
55
+ # -3 The mock server could not be started
56
+ # -4 The method panicked
57
+ # -5 The address is not valid
58
+ # -6 Could not create the TLS configuration with the self-signed certificate
59
+ # */
60
+ FfiPluginCreateMockServerErrors = Hash[
61
+ 'NULL_POINTER' => -1,
62
+ 'JSON_PARSE_ERROR' => -2,
63
+ 'MOCK_SERVER_START_FAIL' => -3,
64
+ 'CORE_PANIC' => -4,
65
+ 'ADDRESS_NOT_VALID' => -5,
66
+ 'TLS_CONFIG' => -6,
67
+ ]
68
+
69
+ FfiPluginFunctionResult = Hash[
70
+ 'RESULT_OK' => 0,
71
+ 'RESULT_FAILED' => 1,
72
+ ]
73
+
74
+ attach_function :contents_get_contents_str, :pactffi_message_contents_get_contents_str, %i[pointer], :string
75
+ attach_function :contents_set_contents_str, :pactffi_message_contents_set_contents_str, %i[pointer string string], :void
76
+ attach_function :contents_get_contents_length, :pactffi_message_contents_get_contents_length, %i[pointer], :size_t
77
+ attach_function :contents_get_contents_bin, :pactffi_message_contents_get_contents_bin, %i[pointer], :pointer
78
+ attach_function :contents_set_contents_bin, :pactffi_message_contents_set_contents_bin, %i[pointer pointer size_t string], :void
79
+ attach_function :contents_get_metadata_iter, :pactffi_message_contents_get_metadata_iter, %i[pointer], :pointer
80
+ attach_function :contents_get_matching_rule_iter, :pactffi_message_contents_get_matching_rule_iter, %i[pointer int32], :pointer
81
+ attach_function :message_contents_get_generators_iter, :pactffi_message_contents_get_generators_iter, %i[pointer int32], :pointer
82
+ attach_function :pact_interaction_as_message, :pactffi_pact_interaction_as_message, %i[pointer], :pointer
83
+ attach_function :new, :pactffi_message_new, %i[], :pointer
84
+ attach_function :new_from_json, :pactffi_message_new_from_json, %i[uint32_type string int32], :pointer
85
+ attach_function :new_from_body, :pactffi_message_new_from_body, %i[string string], :pointer
86
+ attach_function :delete, :pactffi_message_delete, %i[pointer], :void
87
+ attach_function :get_contents, :pactffi_message_get_contents, %i[pointer], :string
88
+ attach_function :set_contents, :pactffi_message_set_contents, %i[pointer string string], :void
89
+ attach_function :get_contents_length, :pactffi_message_get_contents_length, %i[pointer], :size_t
90
+ attach_function :get_contents_bin, :pactffi_message_get_contents_bin, %i[pointer], :pointer
91
+ attach_function :set_contents_bin, :pactffi_message_set_contents_bin, %i[pointer pointer size_t string], :void
92
+ attach_function :get_description, :pactffi_message_get_description, %i[pointer], :string
93
+ attach_function :set_description, :pactffi_message_set_description, %i[pointer string], :int32
94
+ attach_function :get_provider_state, :pactffi_message_get_provider_state, %i[pointer uint32_type], :pointer
95
+ attach_function :get_provider_state_iter, :pactffi_message_get_provider_state_iter, %i[pointer], :pointer
96
+ attach_function :find_metadata, :pactffi_message_find_metadata, %i[pointer string], :string
97
+ attach_function :insert_metadata, :pactffi_message_insert_metadata, %i[pointer string string], :int32
98
+ attach_function :metadata_iter_next, :pactffi_message_metadata_iter_next, %i[pointer], :pointer
99
+ attach_function :get_metadata_iter, :pactffi_message_get_metadata_iter, %i[pointer], :pointer
100
+ attach_function :metadata_iter_delete, :pactffi_message_metadata_iter_delete, %i[pointer], :void
101
+ attach_function :metadata_pair_delete, :pactffi_message_metadata_pair_delete, %i[pointer], :void
102
+ attach_function :new_from_json, :pactffi_message_pact_new_from_json, %i[string string], :pointer
103
+ attach_function :delete, :pactffi_message_pact_delete, %i[pointer], :void
104
+ attach_function :get_consumer, :pactffi_message_pact_get_consumer, %i[pointer], :pointer
105
+ attach_function :get_provider, :pactffi_message_pact_get_provider, %i[pointer], :pointer
106
+ attach_function :get_message_iter, :pactffi_message_pact_get_message_iter, %i[pointer], :pointer
107
+ attach_function :message_iter_next, :pactffi_message_pact_message_iter_next, %i[pointer], :pointer
108
+ attach_function :message_iter_delete, :pactffi_message_pact_message_iter_delete, %i[pointer], :void
109
+ attach_function :find_metadata, :pactffi_message_pact_find_metadata, %i[pointer string string], :string
110
+ attach_function :get_metadata_iter, :pactffi_message_pact_get_metadata_iter, %i[pointer], :pointer
111
+ attach_function :metadata_iter_next, :pactffi_message_pact_metadata_iter_next, %i[pointer], :pointer
112
+ attach_function :metadata_iter_delete, :pactffi_message_pact_metadata_iter_delete, %i[pointer], :void
113
+ attach_function :metadata_triple_delete, :pactffi_message_pact_metadata_triple_delete, %i[pointer], :void
114
+ attach_function :new_message_interaction, :pactffi_new_message_interaction, %i[uint16 string], :uint32_type
115
+ attach_function :new_message_pact, :pactffi_new_message_pact, %i[string string], :uint16
116
+ attach_function :new_message, :pactffi_new_message, %i[uint16 string], :uint32_type
117
+ attach_function :expects_to_receive, :pactffi_message_expects_to_receive, %i[uint32_type string], :void
118
+ attach_function :given, :pactffi_message_given, %i[uint32_type string], :void
119
+ attach_function :given_with_param, :pactffi_message_given_with_param, %i[uint32_type string string string], :void
120
+ attach_function :with_contents, :pactffi_message_with_contents, %i[uint32_type string pointer size_t], :void
121
+ attach_function :with_metadata, :pactffi_message_with_metadata, %i[uint32_type string string], :void
122
+ attach_function :reify, :pactffi_message_reify, %i[uint32_type], :string
123
+ attach_function :write_message_pact_file, :pactffi_write_message_pact_file, %i[uint16 string bool], :int32
124
+ attach_function :with_message_pact_metadata, :pactffi_with_message_pact_metadata, %i[uint16 string string string], :void
125
+ attach_function :free_handle, :pactffi_free_message_pact_handle, %i[uint16], :uint32_type
126
+ attach_function :pact_handle_get_message_iter, :pactffi_pact_handle_get_message_iter, %i[uint16], :pointer
127
+ attach_function :with_metadata_v2, :pactffi_message_with_metadata_v2, %i[uint32_type string string], :void
128
+ end
129
+ end
@@ -0,0 +1,84 @@
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
+ (typedef :uint32, :uint32_type)
12
+
13
+ FfiSpecificationVersion = Hash[
14
+ 'SPECIFICATION_VERSION_UNKNOWN' => 0,
15
+ 'SPECIFICATION_VERSION_V1' => 1,
16
+ 'SPECIFICATION_VERSION_V1_1' => 2,
17
+ 'SPECIFICATION_VERSION_V2' => 3,
18
+ 'SPECIFICATION_VERSION_V3' => 4,
19
+ 'SPECIFICATION_VERSION_V4' => 5,
20
+ ]
21
+ FfiWritePactResponse = Hash[
22
+ 'SUCCESS' => 0,
23
+ 'GENERAL_PANIC' => 1,
24
+ 'UNABLE_TO_WRITE_PACT_FILE' => 2,
25
+ 'MOCK_SERVER_NOT_FOUND' => 3,
26
+ ]
27
+ FfiWriteMessagePactResponse = Hash[
28
+ 'SUCCESS' => 0,
29
+ 'UNABLE_TO_WRITE_PACT_FILE' => 1,
30
+ 'MESSAGE_HANDLE_INVALID' => 2,
31
+ 'MOCK_SERVER_NOT_FOUND' => 3,
32
+ ]
33
+ FfiConfigurePluginResponse = Hash[
34
+ 'SUCCESS' => 0,
35
+ 'GENERAL_PANIC' => 1,
36
+ 'FAILED_TO_LOAD_PLUGIN' => 2,
37
+ 'PACT_HANDLE_INVALID' => 3,
38
+ ]
39
+ FfiPluginInteractionResponse = Hash[
40
+ 'SUCCESS' => 0,
41
+ 'A_GENERAL_PANIC_WAS_CAUGHT' => 1,
42
+ 'MOCK_SERVER_HAS_ALREADY_BEEN_STARTED' => 2,
43
+ 'INTERACTION_HANDLE_IS_INVALID' => 3,
44
+ 'CONTENT_TYPE_IS_NOT_VALID' => 4,
45
+ 'CONTENTS_JSON_IS_NOT_VALID_JSON' => 5,
46
+ 'PLUGIN_RETURNED_AN_ERROR' => 6,
47
+ ]
48
+ FfiInteractionPart = Hash[
49
+ 'INTERACTION_PART_REQUEST' => 0,
50
+ 'INTERACTION_PART_RESPONSE' => 1,
51
+ ]
52
+ # /*
53
+ # -1 A null pointer was received
54
+ # -2 The pact JSON could not be parsed
55
+ # -3 The mock server could not be started
56
+ # -4 The method panicked
57
+ # -5 The address is not valid
58
+ # -6 Could not create the TLS configuration with the self-signed certificate
59
+ # */
60
+ FfiPluginCreateMockServerErrors = Hash[
61
+ 'NULL_POINTER' => -1,
62
+ 'JSON_PARSE_ERROR' => -2,
63
+ 'MOCK_SERVER_START_FAIL' => -3,
64
+ 'CORE_PANIC' => -4,
65
+ 'ADDRESS_NOT_VALID' => -5,
66
+ 'TLS_CONFIG' => -6,
67
+ ]
68
+
69
+ FfiPluginFunctionResult = Hash[
70
+ 'RESULT_OK' => 0,
71
+ 'RESULT_FAILED' => 1,
72
+ ]
73
+
74
+ attach_function :create, :pactffi_create_mock_server, %i[string string bool], :int32
75
+ attach_function :get_tls_cert, :pactffi_get_tls_ca_certificate, %i[], :string
76
+ attach_function :create_for_pact, :pactffi_create_mock_server_for_pact, %i[uint16 string bool], :int32
77
+ attach_function :create_for_transport, :pactffi_create_mock_server_for_transport, %i[uint16 string uint16 string string], :int32
78
+ attach_function :matched, :pactffi_mock_server_matched, %i[int32], :bool
79
+ attach_function :mismatches, :pactffi_mock_server_mismatches, %i[int32], :string
80
+ attach_function :cleanup, :pactffi_cleanup_mock_server, %i[int32], :bool
81
+ attach_function :write_pact_file, :pactffi_write_pact_file, %i[int32 string bool], :int32
82
+ attach_function :logs, :pactffi_mock_server_logs, %i[int32], :string
83
+ end
84
+ end
@@ -0,0 +1,40 @@
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
+ (typedef :uint32, :uint32_type)
12
+
13
+ # /*
14
+ # -1 A null pointer was received
15
+ # -2 The pact JSON could not be parsed
16
+ # -3 The mock server could not be started
17
+ # -4 The method panicked
18
+ # -5 The address is not valid
19
+ # -6 Could not create the TLS configuration with the self-signed certificate
20
+ # */
21
+ CreateMockServerErrors = Hash[
22
+ 'NULL_POINTER' => -1,
23
+ 'JSON_PARSE_ERROR' => -2,
24
+ 'MOCK_SERVER_START_FAIL' => -3,
25
+ 'CORE_PANIC' => -4,
26
+ 'ADDRESS_NOT_VALID' => -5,
27
+ 'TLS_CONFIG' => -6,
28
+ ]
29
+
30
+ PluginFunctionResult = Hash[
31
+ 'RESULT_OK' => 0,
32
+ 'RESULT_FAILED' => 1,
33
+ ]
34
+
35
+ attach_function :using_plugin, :pactffi_using_plugin, %i[uint16 string string], :uint32_type
36
+ attach_function :cleanup_plugins, :pactffi_cleanup_plugins, %i[uint16], :void
37
+ attach_function :interaction_contents, :pactffi_interaction_contents, %i[uint32_type int32 string string],
38
+ :uint32_type
39
+ end
40
+ end
@@ -0,0 +1,36 @@
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
+ (typedef :uint32, :uint32_type)
12
+
13
+ attach_function :new, :pactffi_sync_http_new, %i[], :pointer
14
+ attach_function :delete, :pactffi_sync_http_delete, %i[pointer], :void
15
+ attach_function :get_request, :pactffi_sync_http_get_request, %i[pointer], :pointer
16
+ attach_function :get_request_contents, :pactffi_sync_http_get_request_contents, %i[pointer], :string
17
+ attach_function :set_request_contents, :pactffi_sync_http_set_request_contents, %i[pointer string string], :void
18
+ attach_function :get_request_contents_length, :pactffi_sync_http_get_request_contents_length, %i[pointer], :size_t
19
+ attach_function :get_request_contents_bin, :pactffi_sync_http_get_request_contents_bin, %i[pointer], :pointer
20
+ attach_function :set_request_contents_bin, :pactffi_sync_http_set_request_contents_bin, %i[pointer pointer size_t string], :void
21
+ attach_function :get_response, :pactffi_sync_http_get_response, %i[pointer], :pointer
22
+ attach_function :get_response_contents, :pactffi_sync_http_get_response_contents, %i[pointer], :string
23
+ attach_function :set_response_contents, :pactffi_sync_http_set_response_contents, %i[pointer string string], :void
24
+ attach_function :get_response_contents_length, :pactffi_sync_http_get_response_contents_length, %i[pointer], :size_t
25
+ attach_function :get_response_contents_bin, :pactffi_sync_http_get_response_contents_bin, %i[pointer], :pointer
26
+ attach_function :set_response_contents_bin, :pactffi_sync_http_set_response_contents_bin, %i[pointer pointer size_t string], :void
27
+ attach_function :get_description, :pactffi_sync_http_get_description, %i[pointer], :string
28
+ attach_function :set_description, :pactffi_sync_http_set_description, %i[pointer string], :int32
29
+ attach_function :get_provider_state, :pactffi_sync_http_get_provider_state, %i[pointer uint32_type], :pointer
30
+ attach_function :get_provider_state_iter, :pactffi_sync_http_get_provider_state_iter, %i[pointer], :pointer
31
+ attach_function :pact_interaction_as_synchronous_http, :pactffi_pact_interaction_as_synchronous_http, %i[pointer], :pointer
32
+ attach_function :iter_next, :pactffi_pact_sync_http_iter_next, %i[pointer], :pointer
33
+ attach_function :iter_delete, :pactffi_pact_sync_http_iter_delete, %i[pointer], :void
34
+ attach_function :pact_handle_get_sync_http_iter, :pactffi_pact_handle_get_sync_http_iter, %i[uint16], :pointer
35
+ end
36
+ end