pact-ffi 0.0.2-arm64-darwin → 0.4.22-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +69 -5
- data/ffi/macos-arm64/libpact_ffi.dylib +0 -0
- data/lib/pact/detect_os.rb +13 -12
- data/lib/pact/ffi/async_message_pact.rb +29 -0
- data/lib/pact/ffi/http_consumer.rb +40 -0
- data/lib/pact/ffi/logger.rb +34 -0
- data/lib/pact/ffi/message_consumer.rb +129 -0
- data/lib/pact/ffi/mock_server.rb +84 -0
- data/lib/pact/ffi/plugin_consumer.rb +40 -0
- data/lib/pact/ffi/sync_http_consumer.rb +36 -0
- data/lib/pact/ffi/sync_message_consumer.rb +38 -0
- data/lib/pact/ffi/utils.rb +150 -0
- data/lib/pact/ffi/verifier.rb +62 -0
- data/lib/pact/ffi/version.rb +5 -0
- data/lib/pact/ffi.rb +271 -259
- metadata +47 -9
- data/lib/pact/fiddle.rb +0 -1292
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a08b4235f2c7e92f100ca5435ee7deb51a17d2faf9a7a529c315c0a1abd7e1ab
|
4
|
+
data.tar.gz: 55b07a1973b89d1537dde95382c5350c8ae8a053cc9ed41d1a298c9089de24a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10f309b40d1dba4a4536e8c1d07a825f383006573a89571cc9a1e15e83d7fd8a0a97ffac0011fbd5ccf16ac91df825168c321bbde847a63e7825db1319185ee1
|
7
|
+
data.tar.gz: 29cefb0e44a3ea8686013594c43ed7740d052fce9cf69891a093b40acfda6abb25909907082db530e8b4c4e49d88ad531d0829a63a0ae0774507779f7a20fef3
|
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:
|
@@ -20,21 +22,51 @@ Or install it yourself as:
|
|
20
22
|
|
21
23
|
## Usage
|
22
24
|
|
23
|
-
|
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>
|
24
37
|
|
25
|
-
##
|
38
|
+
## Supported Platforms
|
26
39
|
|
27
40
|
- Ruby
|
28
|
-
- This gem is compatible with
|
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
|
29
59
|
|
30
60
|
- FFI libraries for your current platform - run `./script/download-libs.sh` to download
|
61
|
+
|
31
62
|
- If testing the protobuf plugin
|
32
|
-
- `
|
33
|
-
- See https://grpc.io/docs/languages/ruby/quickstart
|
63
|
+
- `3.0` for protobuf/grpc example
|
64
|
+
- See <https://grpc.io/docs/languages/ruby/quickstart/> for steps
|
34
65
|
- See `examples/proto-ruby/README.md` for notes
|
35
66
|
- ruby-grpc is not currently, on m1 hardware for the `pact-protobuf-plugin` example
|
36
67
|
- Have the pact-protobuf plugin available
|
37
68
|
- Run `pact-plugin-cli -y install https://github.com/pactflow/pact-protobuf-plugin/releases/latest`
|
69
|
+
|
38
70
|
## Development
|
39
71
|
|
40
72
|
- run `bin/setup` or `bundle install` to install dependencies
|
@@ -52,3 +84,35 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
52
84
|
## Code of Conduct
|
53
85
|
|
54
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
|
+
```
|
Binary file
|
data/lib/pact/detect_os.rb
CHANGED
@@ -1,43 +1,40 @@
|
|
1
1
|
module DetectOS
|
2
2
|
def self.windows?
|
3
3
|
return if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RbConfig::CONFIG['arch']).nil?
|
4
|
-
|
5
|
-
puts 'detected windows'
|
6
4
|
true
|
7
5
|
end
|
8
6
|
|
9
7
|
def self.mac_arm?
|
10
8
|
return unless !(/darwin/ =~ RbConfig::CONFIG['arch']).nil? && !(/arm64/ =~ RbConfig::CONFIG['arch']).nil?
|
11
|
-
|
12
|
-
puts 'detected macos arm'
|
13
9
|
true
|
14
10
|
end
|
15
11
|
|
16
12
|
def self.mac?
|
17
13
|
return unless !(/darwin/ =~ RbConfig::CONFIG['arch']).nil? && !(/x86_64/ =~ RbConfig::CONFIG['arch']).nil?
|
14
|
+
true
|
15
|
+
end
|
18
16
|
|
19
|
-
|
17
|
+
def self.linux_arm_musl?
|
18
|
+
return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/aarch64/ =~ RbConfig::CONFIG['arch']).nil? && !(/musl/ =~ RbConfig::CONFIG['arch']).nil?
|
20
19
|
true
|
21
20
|
end
|
22
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
|
23
26
|
def self.linux_arm?
|
24
27
|
return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/aarch64/ =~ RbConfig::CONFIG['arch']).nil?
|
25
|
-
|
26
|
-
puts 'detected linux aarch64'
|
27
28
|
true
|
28
29
|
end
|
29
30
|
|
30
31
|
def self.linux?
|
31
32
|
return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/x86_64/ =~ RbConfig::CONFIG['arch']).nil?
|
32
|
-
|
33
|
-
puts 'detected linux'
|
34
33
|
true
|
35
34
|
end
|
36
35
|
|
37
36
|
def self.debug?
|
38
37
|
return if ENV['DEBUG_TARGET'].nil?
|
39
|
-
|
40
|
-
puts 'detected debug target' + ENV['DEBUG_TARGET']
|
41
38
|
true
|
42
39
|
end
|
43
40
|
|
@@ -50,6 +47,10 @@ module DetectOS
|
|
50
47
|
File.join(__dir__, '../../ffi/macos-arm64/libpact_ffi.dylib')
|
51
48
|
elsif mac?
|
52
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')
|
53
54
|
elsif linux_arm?
|
54
55
|
File.join(__dir__, '../../ffi/linux-arm64/libpact_ffi.so')
|
55
56
|
elsif linux?
|
@@ -76,4 +77,4 @@ module DetectOS
|
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
79
|
-
puts DetectOS.get_bin_path
|
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
|
@@ -0,0 +1,38 @@
|
|
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
|
+
(typedef :uint32, :uint32_type)
|
12
|
+
|
13
|
+
attach_function :pact_interaction_as_synchronous_message, :pactffi_pact_interaction_as_synchronous_message, %i[pointer], :pointer
|
14
|
+
attach_function :iter_next, :pactffi_pact_sync_message_iter_next, %i[pointer], :pointer
|
15
|
+
attach_function :iter_delete, :pactffi_pact_sync_message_iter_delete, %i[pointer], :void
|
16
|
+
attach_function :new, :pactffi_sync_message_new, %i[], :pointer
|
17
|
+
attach_function :delete, :pactffi_sync_message_delete, %i[pointer], :void
|
18
|
+
attach_function :get_request_contents_str, :pactffi_sync_message_get_request_contents_str, %i[pointer], :string
|
19
|
+
attach_function :set_request_contents_str, :pactffi_sync_message_set_request_contents_str, %i[pointer string string], :void
|
20
|
+
attach_function :get_request_contents_length, :pactffi_sync_message_get_request_contents_length, %i[pointer], :size_t
|
21
|
+
attach_function :get_request_contents_bin, :pactffi_sync_message_get_request_contents_bin, %i[pointer], :pointer
|
22
|
+
attach_function :set_request_contents_bin, :pactffi_sync_message_set_request_contents_bin, %i[pointer pointer size_t string], :void
|
23
|
+
attach_function :get_request_contents, :pactffi_sync_message_get_request_contents, %i[pointer], :pointer
|
24
|
+
attach_function :get_number_responses, :pactffi_sync_message_get_number_responses, %i[pointer], :size_t
|
25
|
+
attach_function :get_response_contents_str, :pactffi_sync_message_get_response_contents_str, %i[pointer size_t], :string
|
26
|
+
attach_function :set_response_contents_str, :pactffi_sync_message_set_response_contents_str, %i[pointer size_t string string], :void
|
27
|
+
attach_function :get_response_contents_length, :pactffi_sync_message_get_response_contents_length, %i[pointer size_t], :size_t
|
28
|
+
attach_function :get_response_contents_bin, :pactffi_sync_message_get_response_contents_bin, %i[pointer size_t], :pointer
|
29
|
+
attach_function :set_response_contents_bin, :pactffi_sync_message_set_response_contents_bin, %i[pointer size_t pointer size_t string], :void
|
30
|
+
attach_function :get_response_contents, :pactffi_sync_message_get_response_contents, %i[pointer size_t], :pointer
|
31
|
+
attach_function :get_description, :pactffi_sync_message_get_description, %i[pointer], :string
|
32
|
+
attach_function :set_description, :pactffi_sync_message_set_description, %i[pointer string], :int32
|
33
|
+
attach_function :get_provider_state, :pactffi_sync_message_get_provider_state, %i[pointer uint32_type], :pointer
|
34
|
+
attach_function :get_provider_state_iter, :pactffi_sync_message_get_provider_state_iter, %i[pointer], :pointer
|
35
|
+
attach_function :new_interaction, :pactffi_new_sync_message_interaction, %i[uint16 string], :uint32_type
|
36
|
+
attach_function :pact_handle_get_sync_message_iter, :pactffi_pact_handle_get_sync_message_iter, %i[uint16], :pointer
|
37
|
+
end
|
38
|
+
end
|