artifactory 2.8.2 → 3.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +5 -5
  2. data/lib/artifactory.rb +3 -2
  3. data/lib/artifactory/client.rb +16 -7
  4. data/lib/artifactory/collections/artifact.rb +1 -1
  5. data/lib/artifactory/collections/base.rb +1 -1
  6. data/lib/artifactory/collections/build.rb +1 -1
  7. data/lib/artifactory/configurable.rb +15 -15
  8. data/lib/artifactory/defaults.rb +2 -2
  9. data/lib/artifactory/errors.rb +6 -6
  10. data/lib/artifactory/resources/artifact.rb +17 -19
  11. data/lib/artifactory/resources/backup.rb +3 -1
  12. data/lib/artifactory/resources/base.rb +17 -7
  13. data/lib/artifactory/resources/build.rb +6 -6
  14. data/lib/artifactory/resources/build_component.rb +1 -0
  15. data/lib/artifactory/resources/certificate.rb +90 -0
  16. data/lib/artifactory/resources/group.rb +2 -1
  17. data/lib/artifactory/resources/layout.rb +2 -1
  18. data/lib/artifactory/resources/ldap_setting.rb +3 -1
  19. data/lib/artifactory/resources/mail_server.rb +2 -1
  20. data/lib/artifactory/resources/permission_target.rb +18 -2
  21. data/lib/artifactory/resources/plugin.rb +1 -1
  22. data/lib/artifactory/resources/repository.rb +5 -1
  23. data/lib/artifactory/resources/system.rb +1 -1
  24. data/lib/artifactory/resources/url_base.rb +2 -1
  25. data/lib/artifactory/resources/user.rb +2 -1
  26. data/lib/artifactory/util.rb +4 -3
  27. data/lib/artifactory/version.rb +2 -2
  28. metadata +11 -131
  29. data/.gitignore +0 -27
  30. data/.travis.yml +0 -28
  31. data/CHANGELOG.md +0 -141
  32. data/Gemfile +0 -14
  33. data/README.md +0 -288
  34. data/Rakefile +0 -28
  35. data/appveyor.yml +0 -30
  36. data/artifactory.gemspec +0 -25
  37. data/spec/integration/resources/artifact_spec.rb +0 -99
  38. data/spec/integration/resources/backup.rb +0 -22
  39. data/spec/integration/resources/build_component_spec.rb +0 -64
  40. data/spec/integration/resources/build_spec.rb +0 -38
  41. data/spec/integration/resources/group_spec.rb +0 -45
  42. data/spec/integration/resources/layout_spec.rb +0 -22
  43. data/spec/integration/resources/ldap_setting_spec.rb +0 -22
  44. data/spec/integration/resources/mail_server_spec.rb +0 -22
  45. data/spec/integration/resources/permission_target_spec.rb +0 -75
  46. data/spec/integration/resources/repository_spec.rb +0 -40
  47. data/spec/integration/resources/system_spec.rb +0 -58
  48. data/spec/integration/resources/url_base_spec.rb +0 -22
  49. data/spec/integration/resources/user_spec.rb +0 -45
  50. data/spec/spec_helper.rb +0 -52
  51. data/spec/support/api_server.rb +0 -49
  52. data/spec/support/api_server/artifact_endpoints.rb +0 -186
  53. data/spec/support/api_server/build_component_endpoints.rb +0 -44
  54. data/spec/support/api_server/build_endpoints.rb +0 -240
  55. data/spec/support/api_server/group_endpoints.rb +0 -53
  56. data/spec/support/api_server/permission_target_endpoints.rb +0 -53
  57. data/spec/support/api_server/repository_endpoints.rb +0 -114
  58. data/spec/support/api_server/status_endpoints.rb +0 -11
  59. data/spec/support/api_server/system_endpoints.rb +0 -104
  60. data/spec/support/api_server/user_endpoints.rb +0 -59
  61. data/spec/unit/artifactory_spec.rb +0 -73
  62. data/spec/unit/client_spec.rb +0 -132
  63. data/spec/unit/resources/artifact_spec.rb +0 -608
  64. data/spec/unit/resources/backup_spec.rb +0 -61
  65. data/spec/unit/resources/base_spec.rb +0 -180
  66. data/spec/unit/resources/build_component_spec.rb +0 -118
  67. data/spec/unit/resources/build_spec.rb +0 -347
  68. data/spec/unit/resources/defaults_spec.rb +0 -27
  69. data/spec/unit/resources/group_spec.rb +0 -108
  70. data/spec/unit/resources/layout_spec.rb +0 -61
  71. data/spec/unit/resources/ldap_setting_spec.rb +0 -65
  72. data/spec/unit/resources/mail_server_spec.rb +0 -57
  73. data/spec/unit/resources/permission_target_spec.rb +0 -189
  74. data/spec/unit/resources/plugin_spec.rb +0 -25
  75. data/spec/unit/resources/repository_spec.rb +0 -217
  76. data/spec/unit/resources/system_spec.rb +0 -90
  77. data/spec/unit/resources/url_base_spec.rb +0 -53
  78. data/spec/unit/resources/user_spec.rb +0 -115
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3ef3bf846ba58ab200c737eb261bef55b26d42a6
4
- data.tar.gz: a50a886a796ad877dae21183d7601d060371f2d6
2
+ SHA256:
3
+ metadata.gz: b25bc5d80ff1f446765041dfa18c8124632de6d74c99757b968ee599afb687f5
4
+ data.tar.gz: 872377830c2c226593aa01dd98bcd9a9ed077a1fc987ac014056e976f64db7b6
5
5
  SHA512:
6
- metadata.gz: bf1d7d48171793cbe944043a280d512194addd87d1b25c6f23239c6744e6ff3b5940714d29aa9a2a99ffaf4cfea7c95bfb2c2fe07faa65f8b387c7662bf1c966
7
- data.tar.gz: 774c9fd405215ed6c14036cb9ea6b916edd1729d9899bcae48bcb755092062175b8b983369edeea4cf7229fc8bb79956704cd146a3fd56b5c37d1265c7b7e1e6
6
+ metadata.gz: 64e08e305ffadc57955be2aa5ec362e3c79dfb425af8180d3d9560db573cef1a4f5b0f0d1fd49f8e3e173cb4ce7ef8f58eec53290e5a170a98bfec9469f5919d
7
+ data.tar.gz: 82474417dff7e81ae2c1c26029d5c91c780c1275201ac1d2a96bfda419c3314cf0ceb577284fc1c059a4a8f4c474337c6565d64def6f1d4e60cee478390930b0
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014 Chef Software, Inc.
2
+ # Copyright 2014-2018 Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
15
15
  #
16
16
 
17
17
  require "pathname"
18
- require "artifactory/version"
18
+ require_relative "artifactory/version"
19
19
 
20
20
  module Artifactory
21
21
  autoload :Client, "artifactory/client"
@@ -36,6 +36,7 @@ module Artifactory
36
36
  autoload :Base, "artifactory/resources/base"
37
37
  autoload :Build, "artifactory/resources/build"
38
38
  autoload :BuildComponent, "artifactory/resources/build_component"
39
+ autoload :Certificate, "artifactory/resources/certificate"
39
40
  autoload :Group, "artifactory/resources/group"
40
41
  autoload :Layout, "artifactory/resources/layout"
41
42
  autoload :LDAPSetting, "artifactory/resources/ldap_setting"
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014 Chef Software, Inc.
2
+ # Copyright 2014-2018 Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -50,6 +50,7 @@ module Artifactory
50
50
 
51
51
  proxy Resource::Artifact
52
52
  proxy Resource::Backup
53
+ proxy Resource::Certificate
53
54
  proxy Resource::Layout
54
55
  proxy Resource::LDAPSetting
55
56
  proxy Resource::MailServer
@@ -207,7 +208,7 @@ module Artifactory
207
208
  end
208
209
 
209
210
  # Setup PATCH/POST/PUT
210
- if [:patch, :post, :put].include?(verb)
211
+ if %i{patch post put}.include?(verb)
211
212
  if data.respond_to?(:read)
212
213
  request.content_length = data.size
213
214
  request.body_stream = data
@@ -257,8 +258,16 @@ module Artifactory
257
258
 
258
259
  if block_given?
259
260
  http.request(request) do |response|
260
- response.read_body do |chunk|
261
- yield chunk
261
+ case response
262
+ when Net::HTTPRedirection
263
+ redirect = response["location"]
264
+ request(verb, redirect, data, headers, &block)
265
+ when Net::HTTPSuccess
266
+ response.read_body do |chunk|
267
+ yield chunk
268
+ end
269
+ else
270
+ error(response)
262
271
  end
263
272
  end
264
273
  else
@@ -266,7 +275,7 @@ module Artifactory
266
275
 
267
276
  case response
268
277
  when Net::HTTPRedirection
269
- redirect = URI.parse(response["location"])
278
+ redirect = response["location"]
270
279
  request(verb, redirect, data, headers)
271
280
  when Net::HTTPSuccess
272
281
  success(response)
@@ -313,7 +322,7 @@ module Artifactory
313
322
  #
314
323
  def build_uri(verb, path, params = {})
315
324
  # Add any query string parameters
316
- if [:delete, :get].include?(verb)
325
+ if %i{delete get}.include?(verb)
317
326
  path = [path, to_query_string(params)].compact.join("?")
318
327
  end
319
328
 
@@ -371,7 +380,7 @@ module Artifactory
371
380
  if (response.content_type || "").include?("json")
372
381
  JSON.parse(response.body || "{}")
373
382
  else
374
- response.body
383
+ response.body || ""
375
384
  end
376
385
  end
377
386
 
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014 Chef Software, Inc.
2
+ # Copyright 2014-2018 Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014 Chef Software, Inc.
2
+ # Copyright 2014-2018 Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015 Chef Software, Inc.
2
+ # Copyright 2015-2018 Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014 Chef Software, Inc.
2
+ # Copyright 2014-2018 Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -27,20 +27,20 @@ module Artifactory
27
27
  # @return [Array<Symbol>]
28
28
  #
29
29
  def keys
30
- @keys ||= [
31
- :endpoint,
32
- :username,
33
- :password,
34
- :api_key,
35
- :proxy_address,
36
- :proxy_password,
37
- :proxy_port,
38
- :proxy_username,
39
- :ssl_pem_file,
40
- :ssl_verify,
41
- :user_agent,
42
- :read_timeout,
43
- ]
30
+ @keys ||= %i{
31
+ endpoint
32
+ username
33
+ password
34
+ api_key
35
+ proxy_address
36
+ proxy_password
37
+ proxy_port
38
+ proxy_username
39
+ ssl_pem_file
40
+ ssl_verify
41
+ user_agent
42
+ read_timeout
43
+ }
44
44
  end
45
45
  end
46
46
 
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014 Chef Software, Inc.
2
+ # Copyright 2014-2018 Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require "artifactory/version"
17
+ require_relative "version"
18
18
 
19
19
  module Artifactory
20
20
  module Defaults
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014 Chef Software, Inc.
2
+ # Copyright 2014-2018 Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -44,14 +44,14 @@ module Artifactory
44
44
  # A general connection error with a more informative message
45
45
  class InvalidBuildType < ArtifactoryError
46
46
  def initialize(given_type)
47
- super <<-EOH
48
- '#{given_type}' is not a valid build type.
47
+ super <<~EOH
48
+ '#{given_type}' is not a valid build type.
49
49
 
50
- Valid build types include:
50
+ Valid build types include:
51
51
 
52
- #{Resource::Build::BUILD_TYPES.join("\n ")}"
52
+ #{Resource::Build::BUILD_TYPES.join("\n ")}"
53
53
 
54
- EOH
54
+ EOH
55
55
  end
56
56
  end
57
57
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014 Chef Software, Inc.
2
+ # Copyright 2014-2018 Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -95,11 +95,10 @@ module Artifactory
95
95
  def gavc_search(options = {})
96
96
  client = extract_client!(options)
97
97
  options = Util.rename_keys(options,
98
- :group => :g,
99
- :name => :a,
100
- :version => :v,
101
- :classifier => :c
102
- )
98
+ group: :g,
99
+ name: :a,
100
+ version: :v,
101
+ classifier: :c)
103
102
  params = Util.slice(options, :g, :a, :v, :c, :repos)
104
103
  format_repos!(params)
105
104
 
@@ -291,16 +290,16 @@ module Artifactory
291
290
  def versions(options = {})
292
291
  client = extract_client!(options)
293
292
  options = Util.rename_keys(options,
294
- :group => :g,
295
- :name => :a,
296
- :version => :v
297
- )
293
+ group: :g,
294
+ name: :a,
295
+ version: :v)
298
296
  params = Util.slice(options, :g, :a, :v, :repos)
299
297
  format_repos!(params)
300
298
 
301
299
  client.get("/api/search/versions", params)["results"]
302
300
  rescue Error::HTTPError => e
303
301
  raise unless e.code == 404
302
+
304
303
  []
305
304
  end
306
305
 
@@ -342,10 +341,9 @@ module Artifactory
342
341
  def latest_version(options = {})
343
342
  client = extract_client!(options)
344
343
  options = Util.rename_keys(options,
345
- :group => :g,
346
- :name => :a,
347
- :version => :v
348
- )
344
+ group: :g,
345
+ name: :a,
346
+ version: :v)
349
347
  params = Util.slice(options, :g, :a, :v, :repos, :remote)
350
348
  format_repos!(params)
351
349
 
@@ -356,6 +354,7 @@ module Artifactory
356
354
  client.get("/api/search/latestVersion", params)
357
355
  rescue Error::HTTPError => e
358
356
  raise unless e.code == 404
357
+
359
358
  nil
360
359
  end
361
360
 
@@ -493,7 +492,7 @@ module Artifactory
493
492
  target = File.expand_path(target)
494
493
 
495
494
  # Make the directory if it doesn't yet exist
496
- FileUtils.mkdir_p(target) unless File.exists?(target)
495
+ FileUtils.mkdir_p(target) unless File.exist?(target)
497
496
 
498
497
  # Use the server artifact's filename if one wasn't given
499
498
  filename = options[:filename] || File.basename(download_uri)
@@ -555,6 +554,7 @@ module Artifactory
555
554
  response = client.put(endpoint, file, headers)
556
555
 
557
556
  return unless response.is_a?(Hash)
557
+
558
558
  self.class.from_hash(response)
559
559
  end
560
560
 
@@ -608,8 +608,7 @@ module Artifactory
608
608
  def upload_with_checksum(repo, remote_path, checksum, properties = {})
609
609
  upload(repo, remote_path, properties,
610
610
  "X-Checksum-Deploy" => true,
611
- "X-Checksum-Sha1" => checksum
612
- )
611
+ "X-Checksum-Sha1" => checksum)
613
612
  end
614
613
 
615
614
  #
@@ -626,8 +625,7 @@ module Artifactory
626
625
  #
627
626
  def upload_from_archive(repo, remote_path, properties = {})
628
627
  upload(repo, remote_path, properties,
629
- "X-Explode-Archive" => true
630
- )
628
+ "X-Explode-Archive" => true)
631
629
  end
632
630
 
633
631
  private
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014 Chef Software, Inc.
2
+ # Copyright 2014-2018 Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -59,6 +59,7 @@ module Artifactory
59
59
  find_from_config("config/backups/backup/key[text()='#{key}']", config, options)
60
60
  rescue Error::HTTPError => e
61
61
  raise unless e.code == 404
62
+
62
63
  nil
63
64
  end
64
65
 
@@ -102,6 +103,7 @@ module Artifactory
102
103
  def find_from_config(xpath, config, options = {})
103
104
  name_node = REXML::XPath.match(config, xpath)
104
105
  return nil if name_node.empty?
106
+
105
107
  properties = Util.xml_to_hash(name_node[0].parent, "excludedRepositories", false)
106
108
  from_hash(properties, options)
107
109
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014 Chef Software, Inc.
2
+ # Copyright 2014-2018 Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -88,7 +88,7 @@ module Artifactory
88
88
  # @return [true, false]
89
89
  #
90
90
  def has_attribute?(key)
91
- attributes.has_key?(key.to_sym)
91
+ attributes.key?(key.to_sym)
92
92
  end
93
93
 
94
94
  #
@@ -156,6 +156,7 @@ module Artifactory
156
156
  def find_from_config(xpath, config, options = {})
157
157
  name_node = REXML::XPath.match(config, xpath)
158
158
  return nil if name_node.empty?
159
+
159
160
  properties = {}
160
161
  name_node[0].parent.each_element_with_text do |e|
161
162
  properties[e.name] = Util.to_type(e.text)
@@ -227,6 +228,7 @@ module Artifactory
227
228
  #
228
229
  def format_repos!(options)
229
230
  return options if options[:repos].nil? || options[:repos].empty?
231
+
230
232
  options[:repos] = Array(options[:repos]).compact.join(",")
231
233
  options
232
234
  end
@@ -241,7 +243,15 @@ module Artifactory
241
243
  # the URL-safe version of the string
242
244
  #
243
245
  def url_safe(value)
244
- URI.escape(URI.unescape(value.to_s))
246
+ uri_parser.escape(uri_parser.unescape(value.to_s))
247
+ end
248
+
249
+ #
250
+ # Generate a URI parser
251
+ #
252
+ # @return [URI::Parser]
253
+ def uri_parser
254
+ @uri_parser ||= URI::Parser.new
245
255
  end
246
256
  end
247
257
 
@@ -340,7 +350,7 @@ module Artifactory
340
350
  if properties.empty?
341
351
  nil
342
352
  else
343
- ";#{properties.join(';')}"
353
+ ";#{properties.join(";")}"
344
354
  end
345
355
  end
346
356
 
@@ -351,8 +361,8 @@ module Artifactory
351
361
  #
352
362
  def to_query_string_parameters(hash = {})
353
363
  properties = hash.map do |k, v|
354
- key = URI.escape(k.to_s)
355
- value = URI.escape(v.to_s)
364
+ key = self.class.uri_parser.escape(k.to_s)
365
+ value = self.class.uri_parser.escape(v.to_s)
356
366
 
357
367
  "#{key}=#{value}"
358
368
  end
@@ -377,7 +387,7 @@ module Artifactory
377
387
  end
378
388
  end.compact
379
389
 
380
- "#<#{short_classname} #{list.join(', ')}>"
390
+ "#<#{short_classname} #{list.join(", ")}>"
381
391
  end
382
392
 
383
393
  private
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015 Chef Software, Inc.
2
+ # Copyright 2015-2018 Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ module Artifactory
20
20
  class Resource::Build < Resource::Base
21
21
  BUILD_SCHEMA_VERSION = "1.0.1".freeze
22
22
  # valid build types as dictated by the Artifactory API
23
- BUILD_TYPES = %w{ ANT IVY MAVEN GENERIC GRADLE }
23
+ BUILD_TYPES = %w{ ANT IVY MAVEN GENERIC GRADLE }.freeze
24
24
 
25
25
  class << self
26
26
  #
@@ -49,6 +49,7 @@ module Artifactory
49
49
  # builds. Whoever decided that was a good idea clearly doesn't
50
50
  # understand the point of REST interfaces...
51
51
  raise unless e.code == 404
52
+
52
53
  []
53
54
  end
54
55
 
@@ -78,6 +79,7 @@ module Artifactory
78
79
  from_hash(response["buildInfo"], client: client)
79
80
  rescue Error::HTTPError => e
80
81
  raise unless e.code == 404
82
+
81
83
  nil
82
84
  end
83
85
 
@@ -189,8 +191,7 @@ module Artifactory
189
191
 
190
192
  endpoint = "/api/build/promote/#{url_safe(name)}/#{url_safe(number)}"
191
193
  client.post(endpoint, JSON.fast_generate(request_body),
192
- "Content-Type" => "application/json"
193
- )
194
+ "Content-Type" => "application/json")
194
195
  end
195
196
 
196
197
  #
@@ -206,8 +207,7 @@ module Artifactory
206
207
  file.rewind
207
208
 
208
209
  client.put("/api/build", file,
209
- "Content-Type" => "application/json"
210
- )
210
+ "Content-Type" => "application/json")
211
211
  true
212
212
  ensure
213
213
  if file