better-faraday 3.1.0 → 3.1.1

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: 505a74e2ae063f298dd6b7885d06f6e8d4851e1b566d4f5560be0b1d1e7890d5
4
- data.tar.gz: abe6ef33c08df902f55f8d6235ff587707e84e497ec65a2059b2f4bb06c20097
3
+ metadata.gz: 63e3069002b8c492c1974502babbe1ab1b0815a499fcb1fb6384860953957051
4
+ data.tar.gz: 79af46da23df8de021919a3e1fab6990b927524634cb705b3e88a06eeb115170
5
5
  SHA512:
6
- metadata.gz: 692fd039d299eeb2067441d8dd816634924b826314ddcc3caaf0cb3d0231b82b90e47c9077b337fcaaa721231ece2e865432f9b4f1dbb80c97ebb81940f02338
7
- data.tar.gz: ca8287fcd46f4e32a2ea5d9ec217b05d0f0fea61167895a90d7c61d0643dc7704b07ced2894a0e89230a08ad29b957f23cf4428840a164e5c3ce36d98e3e5da0
6
+ metadata.gz: ef42fd021a83dc99654aef97736ac6364942774748865be68ca3b379fcb097213043274f0ab6ab16b0912918b5b9b68438ab69fc0326b7404b7d2d112c13780d
7
+ data.tar.gz: 1dba086f05f40addb2577ea44905cb7e7114abb6b2176b13884324df8dc4c3c8cee5a7d0d334cad6da6c1467cd6a58a91532b109071532df1edba4ed3c5cbce8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- better-faraday (3.1.0)
4
+ better-faraday (3.1.1)
5
5
  faraday (>= 1.0, < 3.0)
6
6
 
7
7
  GEM
@@ -86,7 +86,7 @@ DEPENDENCIES
86
86
 
87
87
  CHECKSUMS
88
88
  addressable (2.9.0) sha256=7fdf6ac3660f7f4e867a0838be3f6cf722ace541dd97767fa42bc6cfa980c7af
89
- better-faraday (3.1.0)
89
+ better-faraday (3.1.1)
90
90
  bigdecimal (4.1.3) sha256=61ebe1e5e559bdc3cc6f2c0ee7f427321fc838f59611c294356eb04d6e21cf66
91
91
  bundler (4.0.22) sha256=d8d5ec84c8555e0af71db63ed7aee4d1a8fb839ec46d84212d61979242a5d75a
92
92
  byebug (13.0.0) sha256=d2263efe751941ca520fa29744b71972d39cbc41839496706f5d9b22e92ae05d
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "better-faraday"
5
- s.version = "3.1.0"
5
+ s.version = "3.1.1"
6
6
  s.author = "Yaroslav Konoplov"
7
7
  s.email = "eahome00@gmail.com"
8
8
  s.summary = "Extends Faraday with useful features"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "better_faraday"
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require "securerandom"
5
+
6
+ RSpec.describe "BetterFaraday Binary Data Handling" do
7
+ # Generate 3000 bytes of random binary data (invalid UTF-8)
8
+ let(:binary_payload) { SecureRandom.random_bytes(3000) }
9
+ let(:expected_omission) { "... (truncated)" }
10
+
11
+ let(:env) do
12
+ Faraday::Env.from(
13
+ method: :post,
14
+ url: URI("https://api.example.com/upload"),
15
+ status: 200,
16
+ reason_phrase: "OK",
17
+ request_headers: { "Content-Type" => "application/octet-stream" },
18
+ request_body: binary_payload,
19
+ response_headers: { "Content-Type" => "image/png" },
20
+ body: binary_payload
21
+ )
22
+ end
23
+
24
+ let(:response) { Faraday::Response.new(env) }
25
+
26
+ before do
27
+ response.env.instance_variable_set(:@bf_request_headers, { "Content-Type" => "application/octet-stream" })
28
+ response.env.instance_variable_set(:@bf_request_body, binary_payload)
29
+ end
30
+
31
+ it "safely inspects binary data without encoding crashes and truncates it" do
32
+ inspection = nil
33
+
34
+ # Ensure no Encoding::UndefinedConversionError or similar exceptions are raised
35
+ expect { inspection = response.inspect }.not_to raise_error
36
+
37
+ # Verify that the byte count accurately reflects the binary size
38
+ expect(inspection).to include("-- Request Body (3000 bytes) --")
39
+ expect(inspection).to include("-- Response Body (3000 bytes) --")
40
+
41
+ # Verify that the output is safely truncated to avoid console memory bloat
42
+ expect(inspection).to include(expected_omission)
43
+
44
+ # The raw binary string should not be fully present in the output
45
+ expect(inspection).not_to include(binary_payload)
46
+ end
47
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better-faraday
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Konoplov
@@ -142,10 +142,12 @@ files:
142
142
  - README.md
143
143
  - Rakefile
144
144
  - better-faraday.gemspec
145
+ - lib/better-faraday.rb
145
146
  - lib/better_faraday.rb
146
147
  - spec/adapters_spec.rb
147
148
  - spec/array_masking_spec.rb
148
149
  - spec/assert_status_spec.rb
150
+ - spec/binary_body_spec.rb
149
151
  - spec/custom_sensitive_signs_spec.rb
150
152
  - spec/http_error_spec.rb
151
153
  - spec/inspect_truncation_spec.rb
@@ -185,6 +187,7 @@ test_files:
185
187
  - spec/adapters_spec.rb
186
188
  - spec/array_masking_spec.rb
187
189
  - spec/assert_status_spec.rb
190
+ - spec/binary_body_spec.rb
188
191
  - spec/custom_sensitive_signs_spec.rb
189
192
  - spec/http_error_spec.rb
190
193
  - spec/inspect_truncation_spec.rb