zm-ruby-client 2.0.5 → 2.0.6

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: 2922ec4ff3ece6b82feeee37bd6ec363824f822e884df6e5a9eafb87953f3e10
4
- data.tar.gz: 6139bad6da17e8dcbb042af4060410ea83ea94ff63b9b0b6ee92a437d46d36c6
3
+ metadata.gz: 13a8f6a25daf14d60d491a527f7b9b71920afe9e5df79cbb60bceeacdbdcd606
4
+ data.tar.gz: f3e41e0e600c97ab87a0198bb69e305ba7e12e07d9235ae57ff2e5f6d8457e21
5
5
  SHA512:
6
- metadata.gz: 21213f0d951333e67a030a97f06fb5a578e8970cc080749bc6bb4aa2ecc28d0736686f26879ccafb8404a7ade34230231435195dd262f8f1ed6ea5bbf74c9bc8
7
- data.tar.gz: 48c3570bb2b80842b66d01a14c586b4e00e2b78bd2d0eaaebbbc818b17304af62d264e8b1255673d8bf2206e0da959ed9e08883d01abfe3b28b1f5ea1f62544e
6
+ metadata.gz: 38457fc1f124a1970240edbe7ee900ba02b1c9a864306c03335318eff0c106b27a16cf6598bcc3b1f931904eff7f6de31834f125a69a4177cba07aef86ca6ea7
7
+ data.tar.gz: 2d4491d26f0c59c8b2bc36c9f7f1ac183a3d00b06abf749005442dd67ef5fa17674f1fcd36a7bb4ae23c73a23a157f1f3a063427b938ddc7a9decda724967653
@@ -7,34 +7,35 @@ module Zm
7
7
 
8
8
  def initialize
9
9
  @verbose = false
10
+ @cookies = nil
10
11
  @follow_location = true
11
- @curl = easy_curl
12
12
  end
13
13
 
14
14
  def verbose!
15
15
  @verbose = true
16
- @curl.verbose = @verbose
17
16
  end
18
17
 
19
18
  def cookies(cookies)
20
- @curl.cookies = cookies
19
+ @cookies = cookies
21
20
  end
22
21
 
23
22
  def download(url, dest_file_path)
24
- @curl.url = url
23
+ curl = init_curl_client(url)
24
+
25
25
  File.open(dest_file_path, 'wb') do |f|
26
- @curl.on_body do |data|
26
+ curl.on_body do |data|
27
27
  f << data
28
28
  data.size
29
29
  end
30
30
 
31
- @curl.perform
31
+ curl.perform
32
32
  end
33
33
 
34
- if @curl.status.to_i >= 400
34
+ if curl.status.to_i >= 400
35
35
  File.unlink(dest_file_path) if File.exist?(dest_file_path)
36
36
 
37
- message = "Download failure: #{@curl.body_str} (status=#{@curl.status})"
37
+ message = "Download failure: #{curl.body_str} (status=#{curl.status})"
38
+ close_curl(curl)
38
39
  raise RestError, message
39
40
  end
40
41
 
@@ -42,24 +43,34 @@ module Zm
42
43
  end
43
44
 
44
45
  def upload(url, src_file_path)
45
- @curl.url = url
46
- @curl.http_post(Curl::PostField.file('file', src_file_path))
46
+ curl = init_curl_client(url)
47
+
48
+ curl.http_post(Curl::PostField.file('file', src_file_path))
47
49
 
48
- if @curl.status.to_i >= 400
50
+ if curl.status.to_i >= 400
49
51
  messages = [
50
52
  "Upload failure ! #{src_file_path}",
51
- extract_title(@curl.body_str)
53
+ extract_title(curl.body_str)
52
54
  ].compact
55
+ close_curl(curl)
53
56
  raise RestError, messages.join("\n")
54
57
  end
55
58
 
56
- @curl.body_str
59
+ str = curl.body_str
60
+ close_curl(curl)
61
+ str
57
62
  end
58
63
 
59
64
  private
60
65
 
61
- def easy_curl
62
- Curl::Easy.new do |curl|
66
+ def close_curl(curl)
67
+ curl.close
68
+ # force process to kill socket
69
+ GC.start
70
+ end
71
+
72
+ def init_curl_client(url)
73
+ ::Curl::Easy.new(url) do |curl|
63
74
  curl.timeout = 300
64
75
  curl.enable_cookies = false
65
76
  curl.encoding = ''
@@ -68,6 +79,8 @@ module Zm
68
79
  curl.multipart_form_post = true
69
80
  curl.verbose = verbose
70
81
  curl.follow_location = follow_location
82
+ curl.verbose = @verbose
83
+ curl.cookies = @cookies
71
84
  end
72
85
  end
73
86
 
@@ -23,12 +23,10 @@ module Zm
23
23
  @verbose = false
24
24
  @uri = URI::HTTP.new(scheme, nil, host, port, nil, soap_path, nil, nil, nil)
25
25
  @context = SoapContext.new
26
- init_curl_client
27
26
  end
28
27
 
29
28
  def verbose!
30
29
  @verbose = true
31
- @curl.verbose = @verbose
32
30
  end
33
31
 
34
32
  def invoke(soap_element, error_handler = SoapError)
@@ -45,28 +43,42 @@ module Zm
45
43
  private
46
44
 
47
45
  def init_curl_client
48
- @curl = ::Curl::Easy.new(@uri.to_s) do |curl|
46
+ ::Curl::Easy.new(@uri.to_s) do |curl|
49
47
  curl.timeout = 300
50
48
  curl.enable_cookies = false
51
49
  curl.encoding = ''
52
50
  curl.headers = HTTP_HEADERS
53
51
  curl.ssl_verify_peer = false
54
52
  curl.ssl_verify_host = 0
53
+ curl.verbose = @verbose
55
54
  end
56
55
  end
57
56
 
58
57
  def curl_request(body, error_handler = SoapError)
58
+ curl = init_curl_client
59
59
  logger.debug body.to_json
60
- @curl.http_post(body.to_json)
60
+ curl.http_post(body.to_json)
61
61
 
62
- logger.debug @curl.body_str
62
+ logger.debug curl.body_str
63
63
 
64
- soapbody = JSON.parse(@curl.body_str, symbolize_names: true)
65
- raise(error_handler, soapbody) if @curl.status.to_i >= 400
64
+ soapbody = JSON.parse(curl.body_str, symbolize_names: true)
65
+
66
+ if curl.status.to_i >= 400
67
+ close_curl(curl)
68
+ raise(error_handler, soapbody)
69
+ end
70
+
71
+ close_curl(curl)
66
72
 
67
73
  soapbody
68
74
  end
69
75
 
76
+ def close_curl(curl)
77
+ curl.close
78
+ # force process to kill socket
79
+ GC.start
80
+ end
81
+
70
82
  def envelope(soap_element)
71
83
  {
72
84
  Body: soap_element.to_hash,
@@ -58,6 +58,22 @@ module Zm
58
58
  @parent.zimbra_attributes.all_domain_attrs_writable_names
59
59
  end
60
60
 
61
+ def DKIMPublicTxt
62
+ return if self.DKIMPublicKey.nil?
63
+ return @DKIMPublicTxt if @DKIMPublicTxt
64
+
65
+ txt = self.DKIMPublicKey.each_line.map do |line|
66
+ line.chomp!
67
+ line.gsub!('"', '')
68
+ line.strip!
69
+ end.join
70
+
71
+ matches = txt.scan(/\((.*)\)/)
72
+ return if matches.first.nil?
73
+
74
+ @DKIMPublicTxt = matches.first.first.strip
75
+ end
76
+
61
77
  private
62
78
 
63
79
  def do_update!(hash)
@@ -10,7 +10,7 @@ module Zm
10
10
  module VERSION
11
11
  MAJOR = 2
12
12
  MINOR = 0
13
- TINY = 5
13
+ TINY = 6
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
16
16
  end
@@ -30,4 +30,10 @@
30
30
  {"id":"MD060","name":"zimbraWebClientMaxInputBufferLength","type":"cstring","cardinality":"single","requiredIn":"domain"},
31
31
  {"id":"MD061","name":"zimbraWebClientStaySignedInDisabled","type":"cstring","cardinality":"single","requiredIn":"domain"},
32
32
  {"id":"MD062","name":"zimbraWebClientSupportedHelps","type":"cstring","cardinality":"single","requiredIn":"domain"},
33
- {"id":"MD063","name":"zimbraZimletDataSensitiveInMixedModeDisabled","type":"cstring","cardinality":"single","requiredIn":"domain"}]
33
+ {"id":"MD063","name":"zimbraZimletDataSensitiveInMixedModeDisabled","type":"cstring","cardinality":"single","requiredIn":"domain"},
34
+ {"id":"MD064","name":"DKIMDomain","type":"cstring","cardinality":"single","requiredIn":"domain"},
35
+ {"id":"MD065","name":"DKIMIdentity","type":"cstring","cardinality":"single","requiredIn":"domain"},
36
+ {"id":"MD066","name":"DKIMKey","type":"cstring","cardinality":"single","requiredIn":"domain"},
37
+ {"id":"MD067","name":"DKIMPublicKey","type":"cstring","cardinality":"single","requiredIn":"domain"},
38
+ {"id":"MD068","name":"DKIMSelector","type":"cstring","cardinality":"single","requiredIn":"domain"}
39
+ ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zm-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Désécot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-08 00:00:00.000000000 Z
11
+ date: 2024-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable