as2 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78765b4a0fba8aaa7e3531ee9e3841a0774d72b6a1d09b18a69b53117cf26e22
4
- data.tar.gz: c020c365f57a2dd428501b453bb349483bc98baf6db263dab7dfdfbab33b70a6
3
+ metadata.gz: 96ec1c65d6997fc278267320f6228096129a87752c52127fdf2c9a6d6b1a8b43
4
+ data.tar.gz: b9305a892d2833a59ee286567132cee1b060936ae1f87f80d0de36a6660a6d2b
5
5
  SHA512:
6
- metadata.gz: 13155476fe9dab95fa56e29ec8dc842c86d4cdba0bf296aec518801d4ff8ef3f963bdb7e20d9e17bbc58bfdf334d9c760ccd712b267f70882b8e7ec79fa9230a
7
- data.tar.gz: 1c6806d55b297222c0133e27f53914143ba0b3b35891c8076e93befe9d375534551b492890092432015a793dd88d97d8489ce69635e6ceeb8495f00880c5bd82
6
+ metadata.gz: 0c0aab2fb5d4282559cd0938d0bc540f0061a65d1a5eba7aa8f067a1f85fa746e599afeac5a9a4567456a737f2242bb73748b8460e4e398d612410536a3cafb8
7
+ data.tar.gz: 480ecc3810c376168a5778612c67c2db4eac48c0ea2da2fb782ba247ff0bc6400765b9b98b2835a7da9cd62d7cfdc37043dbee5b1278d3618c7782cd150b2182
@@ -9,26 +9,26 @@ name: test suite
9
9
 
10
10
  on:
11
11
  push:
12
- branches: '**'
12
+ branches: "**"
13
13
 
14
14
  jobs:
15
15
  test:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: ['2.5', '2.6', '2.7', '3.0', '3.1']
19
+ ruby: ["2.7", "3.0", "3.1", "3.2"]
20
20
 
21
21
  runs-on: ubuntu-latest
22
22
 
23
23
  steps:
24
- - uses: actions/checkout@v2
25
- - name: Set up Ruby
26
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
27
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
28
- uses: ruby/setup-ruby@v1
29
- with:
30
- ruby-version: ${{ matrix.ruby }}
31
- - name: Install dependencies
32
- run: bundle install
33
- - name: Run tests
34
- run: bundle exec rake test
24
+ - uses: actions/checkout@v2
25
+ - name: Set up Ruby
26
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
27
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
28
+ uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby }}
31
+ - name: Install dependencies
32
+ run: bundle install
33
+ - name: Run tests
34
+ run: bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.8.0, August 25, 2023
2
+
3
+ * Quote AS2-From/AS2-To identifiers which contain spaces. [#30](https://github.com/alexdean/as2/pull/30)
4
+ * Small improvements to aid integration testing with partners. [#31](https://github.com/alexdean/as2/pull/31)
5
+
1
6
  ## 0.7.0, August 25, 2023
2
7
 
3
8
  Two improvements in compatibility with IBM Sterling, which could not understand
@@ -1,9 +1,10 @@
1
1
  module As2
2
2
  class Client
3
3
  class Result
4
- attr_reader :response, :mic_matched, :mid_matched, :body, :disposition, :signature_verification_error, :exception, :outbound_message_id
4
+ attr_reader :request, :response, :mic_matched, :mid_matched, :body, :disposition, :signature_verification_error, :exception, :outbound_message_id
5
5
 
6
- def initialize(response:, mic_matched:, mid_matched:, body:, disposition:, signature_verification_error:, exception:, outbound_message_id:)
6
+ def initialize(request:, response:, mic_matched:, mid_matched:, body:, disposition:, signature_verification_error:, exception:, outbound_message_id:)
7
+ @request = request
7
8
  @response = response
8
9
  @mic_matched = mic_matched
9
10
  @mid_matched = mid_matched
data/lib/as2/client.rb CHANGED
@@ -56,8 +56,8 @@ module As2
56
56
 
57
57
  req = Net::HTTP::Post.new @partner.url.path
58
58
  req['AS2-Version'] = '1.0' # 1.1 includes compression support, which we dont implement.
59
- req['AS2-From'] = as2_from
60
- req['AS2-To'] = as2_to
59
+ req['AS2-From'] = As2.quoted_system_identifier(as2_from)
60
+ req['AS2-To'] = As2.quoted_system_identifier(as2_to)
61
61
  req['Subject'] = 'AS2 Transaction'
62
62
  req['Content-Type'] = 'application/pkcs7-mime; smime-type=enveloped-data; name=smime.p7m'
63
63
  req['Date'] = Time.now.rfc2822
@@ -99,9 +99,16 @@ module As2
99
99
  # note: to pass this traffic through a debugging proxy (like Charles)
100
100
  # set ENV['http_proxy'].
101
101
  http = Net::HTTP.new(@partner.url.host, @partner.url.port)
102
- http.use_ssl = @partner.url.scheme == 'https'
102
+
103
+ use_ssl = @partner.url.scheme == 'https'
104
+ http.use_ssl = use_ssl
105
+ if use_ssl
106
+ if @partner.tls_verify_mode
107
+ http.verify_mode = @partner.tls_verify_mode
108
+ end
109
+ end
110
+
103
111
  # http.set_debug_output $stderr
104
- # http.verify_mode = OpenSSL::SSL::VERIFY_NONE
105
112
 
106
113
  http.start do
107
114
  resp = http.request(req)
@@ -120,6 +127,7 @@ module As2
120
127
  end
121
128
 
122
129
  Result.new(
130
+ request: req,
123
131
  response: resp,
124
132
  mic_matched: mdn_report[:mic_matched],
125
133
  mid_matched: mdn_report[:mid_matched],
data/lib/as2/config.rb CHANGED
@@ -12,7 +12,7 @@ module As2
12
12
  end
13
13
  end
14
14
 
15
- class Partner < Struct.new :name, :url, :certificate, :mdn_format, :outbound_format
15
+ class Partner < Struct.new :name, :url, :certificate, :tls_verify_mode, :mdn_format, :outbound_format
16
16
  def url=(url)
17
17
  if url.kind_of? String
18
18
  self['url'] = URI.parse url
@@ -42,6 +42,17 @@ module As2
42
42
  def certificate=(certificate)
43
43
  self['certificate'] = As2::Config.build_certificate(certificate)
44
44
  end
45
+
46
+ # if set, will be used for SSL transmissions.
47
+ # @see `verify_mode` in https://ruby-doc.org/stdlib-2.7.1/libdoc/net/http/rdoc/Net/HTTP.html
48
+ def tls_verify_mode=(mode)
49
+ valid_modes = [nil, OpenSSL::SSL::VERIFY_NONE, OpenSSL::SSL::VERIFY_PEER]
50
+ if !valid_modes.include?(mode)
51
+ raise ArgumentError, "tls_verify_mode '#{mode}' must be one of #{valid_modes.inspect}"
52
+ end
53
+
54
+ self['tls_verify_mode'] = mode
55
+ end
45
56
  end
46
57
 
47
58
  class ServerInfo < Struct.new :name, :url, :certificate, :pkey, :domain
data/lib/as2/server.rb CHANGED
@@ -69,8 +69,8 @@ module As2
69
69
 
70
70
  options = {
71
71
  'Reporting-UA' => @server_info.name,
72
- 'Original-Recipient' => "rfc822; #{@server_info.name}",
73
- 'Final-Recipient' => "rfc822; #{@server_info.name}",
72
+ 'Original-Recipient' => "rfc822; #{As2.quoted_system_identifier(@server_info.name)}",
73
+ 'Final-Recipient' => "rfc822; #{As2.quoted_system_identifier(@server_info.name)}",
74
74
  'Original-Message-ID' => env['HTTP_MESSAGE_ID']
75
75
  }
76
76
  if failed
@@ -148,8 +148,8 @@ module As2
148
148
  # TODO: if MIME-Version header is actually needed, should extract it out of smime_signed.
149
149
  headers['MIME-Version'] = '1.0'
150
150
  headers['Message-ID'] = As2.generate_message_id(@server_info)
151
- headers['AS2-From'] = @server_info.name
152
- headers['AS2-To'] = as2_to
151
+ headers['AS2-From'] = As2.quoted_system_identifier(@server_info.name)
152
+ headers['AS2-To'] = As2.quoted_system_identifier(as2_to)
153
153
  headers['AS2-Version'] = '1.0'
154
154
  headers['Connection'] = 'close'
155
155
 
@@ -191,8 +191,8 @@ module As2
191
191
  headers['Content-Type'] = "multipart/signed; protocol=\"application/pkcs7-signature\"; micalg=\"#{micalg}\"; boundary=\"#{boundary}\""
192
192
  headers['MIME-Version'] = '1.0'
193
193
  headers['Message-ID'] = As2.generate_message_id(@server_info)
194
- headers['AS2-From'] = @server_info.name
195
- headers['AS2-To'] = as2_to
194
+ headers['AS2-From'] = As2.quoted_system_identifier(@server_info.name)
195
+ headers['AS2-To'] = As2.quoted_system_identifier(as2_to)
196
196
  headers['AS2-Version'] = '1.0'
197
197
  headers['Connection'] = 'close'
198
198
 
data/lib/as2/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module As2
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
data/lib/as2.rb CHANGED
@@ -35,4 +35,13 @@ module As2
35
35
  parsed = As2::Parser::DispositionNotificationOptions.parse(disposition_notification_options)
36
36
  Array(parsed['signed-receipt-micalg']).find { |m| As2::DigestSelector.valid?(m) }
37
37
  end
38
+
39
+ # surround an As2-From/As2-To value with double-quotes, if it contains a space.
40
+ def self.quoted_system_identifier(name)
41
+ if name.to_s.include?(' ')
42
+ "\"#{name}\""
43
+ else
44
+ name
45
+ end
46
+ end
38
47
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: as2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OfficeLuv