influxdb-client 1.12.0.pre.1596 → 1.12.0.pre.1894

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: 42b667ed662608069e33e175273de10be09affb5aa8190a75c57dd205c1aed65
4
- data.tar.gz: b7c446ed723df259bb6600d2fe5004a4382bafa451c9c670799b88ae16fdec39
3
+ metadata.gz: 348cc579c1aa802928e344e2075f7aa4896363108f9e30407e07c8fe8d293686
4
+ data.tar.gz: 434a5039b83030ce068a3b913880e2c3d084f495cfbd119a839428ceb08f4f5e
5
5
  SHA512:
6
- metadata.gz: a84f02925546e8503d603155f04c9d45bb6f654f8b49a3c4db51f5d20ad1b11ea0dd144b919703ecaacdab59d1792a35a6b63321bcba80494146c28ba47a2a42
7
- data.tar.gz: c50a33e3cb339c61b13c1b11c7d7137f7041db959bb725ea89355fd627ce4ab612e0a788ad5fc404f6da7d012d2a1c6b4515e6e51b4e9ad64a38b54dbdb6ab55
6
+ metadata.gz: f917dc680761aabd57d033211da42712cb560c7461cec2f15f581e40e9f22b6e511c1e8c9874ceaa6f8dc8502c512dc09640f4cdbfdce7e601ba970670ab1788
7
+ data.tar.gz: e5d9bc0d90cf42b3b9b8cd2e10c771f095cbe176adeb022ed903b27e347b028abde77c01bcb59113a419589dcfcce92bb429a4881e82269d5dcf0abedbf7fa2d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## 1.12.0 [unreleased]
2
2
 
3
+ ### Features
4
+ 1. [#71](https://github.com/influxdata/influxdb-client-ruby/pull/71): Added possibility to specify the certification verification behaviour
5
+
3
6
  ## 1.11.0 [2021-01-29]
4
7
 
5
8
  ### CI
data/README.md CHANGED
@@ -48,6 +48,7 @@ client = InfluxDB2::Client.new('https://localhost:8086', 'my-token')
48
48
  | read_timeout | Number of seconds to wait for one block of data to be read | Integer | 10 |
49
49
  | max_redirect_count | Maximal number of followed HTTP redirects | Integer | 10 |
50
50
  | use_ssl | Turn on/off SSL for HTTP communication | bool | true |
51
+ | verify_mode | Sets the flags for the certification verification at beginning of SSL/TLS session. | `OpenSSL::SSL::VERIFY_NONE` or `OpenSSL::SSL::VERIFY_PEER` | none |
51
52
 
52
53
  ```ruby
53
54
  client = InfluxDB2::Client.new('https://localhost:8086', 'my-token',
@@ -43,6 +43,9 @@ module InfluxDB2
43
43
  # @option options [Integer] :read_timeout Number of seconds to wait for one block of data to be read
44
44
  # @option options [Integer] :max_redirect_count Maximal number of followed HTTP redirects
45
45
  # @option options [bool] :use_ssl Turn on/off SSL for HTTP communication
46
+ # @option options [Integer] :verify_mode Sets the flags for the certification verification
47
+ # at beginning of SSL/TLS session. Could be one of `OpenSSL::SSL::VERIFY_NONE` or `OpenSSL::SSL::VERIFY_PEER`.
48
+ # For more info see - https://docs.ruby-lang.org/en/3.0.0/Net/HTTP.html#verify_mode.
46
49
  # @option options [Logger] :logger Logger used for logging. Disable logging by set to false.
47
50
  # @option options [Hash] :tags Default tags which will be added to each point written by api.
48
51
  # the body line-protocol
@@ -84,11 +84,7 @@ module InfluxDB2
84
84
  def _request(payload, uri, limit: @max_redirect_count, headers: {}, request: Net::HTTP::Post)
85
85
  raise InfluxError.from_message("Too many HTTP redirects. Exceeded limit: #{@max_redirect_count}") if limit.zero?
86
86
 
87
- http = Net::HTTP.new(uri.host, uri.port)
88
- http.open_timeout = @options[:open_timeout] || DEFAULT_TIMEOUT
89
- http.write_timeout = @options[:write_timeout] || DEFAULT_TIMEOUT if Net::HTTP.method_defined? :write_timeout
90
- http.read_timeout = @options[:read_timeout] || DEFAULT_TIMEOUT
91
- http.use_ssl = @options[:use_ssl].nil? ? true : @options[:use_ssl]
87
+ http = _prepare_http_client(uri)
92
88
 
93
89
  request = request.new(uri.request_uri)
94
90
  request['Authorization'] = "Token #{@options[:token]}"
@@ -115,6 +111,16 @@ module InfluxDB2
115
111
  end
116
112
  end
117
113
 
114
+ def _prepare_http_client(uri)
115
+ http = Net::HTTP.new(uri.host, uri.port)
116
+ http.open_timeout = @options[:open_timeout] || DEFAULT_TIMEOUT
117
+ http.write_timeout = @options[:write_timeout] || DEFAULT_TIMEOUT if Net::HTTP.method_defined? :write_timeout
118
+ http.read_timeout = @options[:read_timeout] || DEFAULT_TIMEOUT
119
+ http.use_ssl = @options[:use_ssl].nil? ? true : @options[:use_ssl]
120
+ http.verify_mode = @options[:verify_mode] if @options[:verify_mode]
121
+ http
122
+ end
123
+
118
124
  def _check_arg_type(name, value, klass)
119
125
  raise TypeError, "expected a #{klass.name} for #{name}; got #{value.class.name}" unless value.is_a?(klass)
120
126
  end
@@ -57,4 +57,33 @@ class DefaultApiTest < MiniTest::Test
57
57
 
58
58
  @api.log(:info, 'without error')
59
59
  end
60
+
61
+ def test_default_verify_mode
62
+ http_client = @api.send(:_prepare_http_client, URI.parse('https://localhost:8086'))
63
+
64
+ refute_nil http_client
65
+ assert_nil http_client.verify_mode
66
+
67
+ http_client.finish if http_client.started?
68
+ end
69
+
70
+ def test_default_verify_mode_none
71
+ @api = InfluxDB2::DefaultApi.new(options: { logger: @logger, verify_mode: OpenSSL::SSL::VERIFY_NONE })
72
+ http_client = @api.send(:_prepare_http_client, URI.parse('https://localhost:8086'))
73
+
74
+ refute_nil http_client
75
+ assert_equal OpenSSL::SSL::VERIFY_NONE, http_client.verify_mode
76
+
77
+ http_client.finish if http_client.started?
78
+ end
79
+
80
+ def test_default_verify_mode_peer
81
+ @api = InfluxDB2::DefaultApi.new(options: { logger: @logger, verify_mode: OpenSSL::SSL::VERIFY_PEER })
82
+ http_client = @api.send(:_prepare_http_client, URI.parse('https://localhost:8086'))
83
+
84
+ refute_nil http_client
85
+ assert_equal OpenSSL::SSL::VERIFY_PEER, http_client.verify_mode
86
+
87
+ http_client.finish if http_client.started?
88
+ end
60
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: influxdb-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0.pre.1596
4
+ version: 1.12.0.pre.1894
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Bednar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-11 00:00:00.000000000 Z
11
+ date: 2021-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler