td-client 3.0.1 → 3.1.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: d819fbd1d3b7e9d4e5178cf7474bc0f1522cd7414352d0b39e41d6d9f61d8ac7
4
- data.tar.gz: 75ba42da56495d37fcd7b104f5ea6b7e4e6c5121a15c7ce15e66275a31041d65
3
+ metadata.gz: ef9f30fcd1a3c1fc0259050e8399d0ecc9d2a76d43bbac155c2b2bf9f4e60508
4
+ data.tar.gz: 07b8bf3489b7d821920665b8b650682de5a2ae6dd939a5c831347e51fc529fed
5
5
  SHA512:
6
- metadata.gz: d63996ea096f981a64ae24f6439a246789537502a48db5d16203742fdd53210c627e573351f91603947928418087798580e664e399eb03258e8a8ae131d87004
7
- data.tar.gz: a6de4e323a137ebc909f7c5e0de7195e39095b19cccd1640c1e4b0235cadbed3240c4a2828de266758033b70000db5fc06c81d995c6f3fed2a6b60cd3096b95e
6
+ metadata.gz: e910086e65eacab239b44408a7ce487e2414d18f3ad2050c94e3a20861cec7a5effa07ed20912d36422326bb536d4925133e555721839f6327bff1e68cccf2ac
7
+ data.tar.gz: cd85f7ae18e079074315e46975ba4afdb3e9f0f48b0beda6e86617a9acc62bd21a90040f63666e5833c651681e632000b699a66f24e8fb8cd313d537db6429ac
data/lib/td/client/api.rb CHANGED
@@ -239,9 +239,11 @@ class API
239
239
  io.string
240
240
  end
241
241
 
242
- # @param [String] ssl_ca_file
242
+ # @param [String, nil] ssl_ca_file nil restores HTTPClient's default CA source
243
243
  def ssl_ca_file=(ssl_ca_file)
244
244
  @ssl_ca_file = ssl_ca_file
245
+ @api.reset_all
246
+ @api = api_client("#{@ssl ? 'https' : 'http'}://#{@host}:#{@port}")
245
247
  end
246
248
 
247
249
  private
@@ -517,21 +519,7 @@ private
517
519
  def new_client(opts = {})
518
520
  client = HTTPClient.new(@http_proxy, @user_agent)
519
521
  client.connect_timeout = @connect_timeout
520
-
521
- if @ssl
522
- client.ssl_config.add_trust_ca(ssl_ca_file)
523
- client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_PEER
524
- # Disable SSLv3 connection in favor of POODLE Attack protection
525
- client.ssl_config.options |= OpenSSL::SSL::OP_NO_SSLv3
526
- end
527
-
528
- # allow users to use their own custom ca
529
- # or disable verification
530
- if @verify == false
531
- client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
532
- elsif @verify.is_a? String
533
- client.ssl_config.add_trust_ca(@verify)
534
- end
522
+ configure_ssl(client)
535
523
 
536
524
  header = {}
537
525
  if @apikey
@@ -553,11 +541,28 @@ private
553
541
  client.connect_timeout = @connect_timeout
554
542
  client.send_timeout = @send_timeout
555
543
  client.receive_timeout = @read_timeout
544
+ configure_ssl(client)
556
545
  client.transparent_gzip_decompression = true
557
546
  client.debug_dev = STDOUT unless ENV['TD_CLIENT_DEBUG'].nil?
558
547
  client
559
548
  end
560
549
 
550
+ def configure_ssl(client)
551
+ if @ssl
552
+ # Leave CA selection to HTTPClient unless the caller supplies a CA file.
553
+ ca_file = ssl_ca_file
554
+ client.ssl_config.add_trust_ca(ca_file) if ca_file
555
+ # Disable SSLv3 connection in favor of POODLE Attack protection
556
+ client.ssl_config.options |= OpenSSL::SSL::OP_NO_SSLv3
557
+ end
558
+
559
+ if @verify == false
560
+ client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
561
+ elsif @verify.is_a? String
562
+ client.ssl_config.add_trust_ca(@verify)
563
+ end
564
+ end
565
+
561
566
  def api(opt = {:retry_request => true}, &block)
562
567
  retry_request = opt[:retry_request]
563
568
  # up to 7 retries with exponential (base 2) back-off starting at 'retry_delay'
@@ -606,7 +611,7 @@ private
606
611
  end
607
612
 
608
613
  def ssl_ca_file
609
- @ssl_ca_file ||= File.join(File.dirname(__FILE__), '..', '..', '..', 'data', 'ca-bundle.crt')
614
+ @ssl_ca_file
610
615
  end
611
616
 
612
617
  # @param [response] res
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
  class Client
3
- VERSION = '3.0.1'
3
+ VERSION = '3.1.0'
4
4
  end
5
5
  end
@@ -72,6 +72,28 @@ describe 'API SSL connection' do
72
72
  }.to raise_error TreasureData::NotFoundError
73
73
  end
74
74
 
75
+ it 'should use ssl_ca_file for bulk load requests' do
76
+ @server = setup_server(:TLSv1_2)
77
+ api = API.new(nil, :endpoint => "https://localhost:#{@serverport}", :retry_post_requests => false)
78
+ api.ssl_ca_file = File.join(DIR, 'testRootCA.crt')
79
+
80
+ expect(api.bulk_load_list).to eq([])
81
+ end
82
+
83
+ it 'should apply verify false to bulk load requests' do
84
+ @server = setup_server(:TLSv1_2)
85
+ api = API.new(nil, :endpoint => "https://localhost:#{@serverport}", :retry_post_requests => false, :verify => false)
86
+
87
+ expect(api.bulk_load_list).to eq([])
88
+ end
89
+
90
+ it 'should use the verify CA file for bulk load requests' do
91
+ @server = setup_server(:TLSv1_2)
92
+ api = API.new(nil, :endpoint => "https://localhost:#{@serverport}", :retry_post_requests => false, :verify => File.join(DIR, 'testRootCA.crt'))
93
+
94
+ expect(api.bulk_load_list).to eq([])
95
+ end
96
+
75
97
  def setup_server(ssl_version, port = 1000 + rand(1000))
76
98
  logger = Logger.new(STDERR)
77
99
  logger.level = Logger::Severity::FATAL # avoid logging SSLError (ERROR level)
@@ -91,6 +113,10 @@ describe 'API SSL connection' do
91
113
  '/hello',
92
114
  WEBrick::HTTPServlet::ProcHandler.new(method(:do_hello).to_proc)
93
115
  )
116
+ @server.mount_proc('/v3/bulk_loads') do |_req, res|
117
+ res['content-type'] = 'application/json'
118
+ res.body = '[]'
119
+ end
94
120
  @server.ssl_context.ssl_version = ssl_version
95
121
  @server_thread = start_server_thread(@server)
96
122
  return @server
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Treasure Data, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-11 00:00:00.000000000 Z
11
+ date: 2026-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '2.7'
39
+ version: 2.10.0
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: '2.7'
46
+ version: 2.10.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -162,7 +162,6 @@ executables: []
162
162
  extensions: []
163
163
  extra_rdoc_files: []
164
164
  files:
165
- - data/ca-bundle.crt
166
165
  - lib/td-client.rb
167
166
  - lib/td/client.rb
168
167
  - lib/td/client/api.rb