artifactory 2.5.2 → 2.6.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.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -2
  3. data/CHANGELOG.md +6 -0
  4. data/Gemfile +9 -13
  5. data/README.md +10 -1
  6. data/Rakefile +16 -7
  7. data/appveyor.yml +4 -2
  8. data/artifactory.gemspec +14 -14
  9. data/lib/artifactory.rb +26 -26
  10. data/lib/artifactory/client.rb +25 -23
  11. data/lib/artifactory/configurable.rb +1 -0
  12. data/lib/artifactory/defaults.rb +24 -15
  13. data/lib/artifactory/errors.rb +2 -2
  14. data/lib/artifactory/resources/artifact.rb +34 -33
  15. data/lib/artifactory/resources/backup.rb +5 -5
  16. data/lib/artifactory/resources/base.rb +7 -7
  17. data/lib/artifactory/resources/build.rb +15 -15
  18. data/lib/artifactory/resources/build_component.rb +4 -4
  19. data/lib/artifactory/resources/group.rb +4 -4
  20. data/lib/artifactory/resources/layout.rb +3 -3
  21. data/lib/artifactory/resources/ldap_setting.rb +7 -6
  22. data/lib/artifactory/resources/mail_server.rb +3 -3
  23. data/lib/artifactory/resources/permission_target.rb +20 -20
  24. data/lib/artifactory/resources/plugin.rb +1 -1
  25. data/lib/artifactory/resources/repository.rb +20 -20
  26. data/lib/artifactory/resources/system.rb +6 -6
  27. data/lib/artifactory/resources/url_base.rb +4 -3
  28. data/lib/artifactory/resources/user.rb +4 -4
  29. data/lib/artifactory/util.rb +10 -10
  30. data/lib/artifactory/version.rb +1 -1
  31. data/spec/integration/resources/artifact_spec.rb +31 -31
  32. data/spec/integration/resources/backup.rb +7 -7
  33. data/spec/integration/resources/build_component_spec.rb +18 -18
  34. data/spec/integration/resources/build_spec.rb +15 -15
  35. data/spec/integration/resources/group_spec.rb +16 -16
  36. data/spec/integration/resources/layout_spec.rb +7 -7
  37. data/spec/integration/resources/ldap_setting_spec.rb +7 -7
  38. data/spec/integration/resources/mail_server_spec.rb +7 -7
  39. data/spec/integration/resources/permission_target_spec.rb +35 -35
  40. data/spec/integration/resources/repository_spec.rb +14 -14
  41. data/spec/integration/resources/system_spec.rb +20 -21
  42. data/spec/integration/resources/url_base_spec.rb +7 -7
  43. data/spec/integration/resources/user_spec.rb +16 -16
  44. data/spec/spec_helper.rb +11 -11
  45. data/spec/support/api_server.rb +13 -13
  46. data/spec/support/api_server/artifact_endpoints.rb +94 -94
  47. data/spec/support/api_server/build_component_endpoints.rb +18 -18
  48. data/spec/support/api_server/build_endpoints.rb +76 -76
  49. data/spec/support/api_server/group_endpoints.rb +24 -24
  50. data/spec/support/api_server/permission_target_endpoints.rb +24 -24
  51. data/spec/support/api_server/repository_endpoints.rb +82 -82
  52. data/spec/support/api_server/status_endpoints.rb +5 -5
  53. data/spec/support/api_server/system_endpoints.rb +17 -18
  54. data/spec/support/api_server/user_endpoints.rb +30 -30
  55. data/spec/unit/artifactory_spec.rb +17 -17
  56. data/spec/unit/client_spec.rb +43 -43
  57. data/spec/unit/resources/artifact_spec.rb +256 -256
  58. data/spec/unit/resources/backup_spec.rb +8 -8
  59. data/spec/unit/resources/base_spec.rb +51 -51
  60. data/spec/unit/resources/build_component_spec.rb +45 -45
  61. data/spec/unit/resources/build_spec.rb +98 -98
  62. data/spec/unit/resources/defaults_spec.rb +4 -4
  63. data/spec/unit/resources/group_spec.rb +36 -36
  64. data/spec/unit/resources/layout_spec.rb +8 -8
  65. data/spec/unit/resources/ldap_setting_spec.rb +8 -8
  66. data/spec/unit/resources/mail_server_spec.rb +8 -8
  67. data/spec/unit/resources/permission_target_spec.rb +79 -79
  68. data/spec/unit/resources/plugin_spec.rb +7 -7
  69. data/spec/unit/resources/repository_spec.rb +98 -98
  70. data/spec/unit/resources/system_spec.rb +30 -30
  71. data/spec/unit/resources/url_base_spec.rb +8 -8
  72. data/spec/unit/resources/user_spec.rb +40 -40
  73. metadata +3 -3
@@ -24,8 +24,8 @@ module Artifactory
24
24
  attr_reader :code
25
25
 
26
26
  def initialize(hash = {})
27
- @code = hash['status'].to_i
28
- @http = hash['message'].to_s
27
+ @code = hash["status"].to_i
28
+ @http = hash["message"].to_s
29
29
 
30
30
  super "The Artifactory server responded with an HTTP Error " \
31
31
  "#{@code}: `#{@http}'"
@@ -14,7 +14,8 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'tempfile'
17
+ require "tempfile"
18
+ require "time"
18
19
 
19
20
  module Artifactory
20
21
  class Resource::Artifact < Resource::Base
@@ -46,8 +47,8 @@ module Artifactory
46
47
  params = Util.slice(options, :name, :repos)
47
48
  format_repos!(params)
48
49
 
49
- client.get('/api/search/artifact', params)['results'].map do |artifact|
50
- from_url(artifact['uri'], client: client)
50
+ client.get("/api/search/artifact", params)["results"].map do |artifact|
51
+ from_url(artifact["uri"], client: client)
51
52
  end
52
53
  end
53
54
 
@@ -97,13 +98,13 @@ module Artifactory
97
98
  :group => :g,
98
99
  :name => :a,
99
100
  :version => :v,
100
- :classifier => :c,
101
+ :classifier => :c
101
102
  )
102
103
  params = Util.slice(options, :g, :a, :v, :c, :repos)
103
104
  format_repos!(params)
104
105
 
105
- client.get('/api/search/gavc', params)['results'].map do |artifact|
106
- from_url(artifact['uri'], client: client)
106
+ client.get("/api/search/gavc", params)["results"].map do |artifact|
107
+ from_url(artifact["uri"], client: client)
107
108
  end
108
109
  end
109
110
 
@@ -141,8 +142,8 @@ module Artifactory
141
142
  params = options.dup
142
143
  format_repos!(params)
143
144
 
144
- client.get('/api/search/prop', params)['results'].map do |artifact|
145
- from_url(artifact['uri'], client: client)
145
+ client.get("/api/search/prop", params)["results"].map do |artifact|
146
+ from_url(artifact["uri"], client: client)
146
147
  end
147
148
  end
148
149
 
@@ -180,8 +181,8 @@ module Artifactory
180
181
  params = Util.slice(options, :md5, :sha1, :repos)
181
182
  format_repos!(params)
182
183
 
183
- client.get('/api/search/checksum', params)['results'].map do |artifact|
184
- from_url(artifact['uri'], client: client)
184
+ client.get("/api/search/checksum", params)["results"].map do |artifact|
185
+ from_url(artifact["uri"], client: client)
185
186
  end
186
187
  end
187
188
 
@@ -221,8 +222,8 @@ module Artifactory
221
222
  params = Util.slice(options, :notUsedSince, :createdBefore, :repos)
222
223
  format_repos!(params)
223
224
 
224
- client.get('/api/search/usage', params)['results'].map do |artifact|
225
- from_url(artifact['uri'], client: client)
225
+ client.get("/api/search/usage", params)["results"].map do |artifact|
226
+ from_url(artifact["uri"], client: client)
226
227
  end
227
228
  end
228
229
 
@@ -262,8 +263,8 @@ module Artifactory
262
263
  params = Util.slice(options, :from, :to, :repos)
263
264
  format_repos!(params)
264
265
 
265
- client.get('/api/search/creation', params)['results'].map do |artifact|
266
- from_url(artifact['uri'], client: client)
266
+ client.get("/api/search/creation", params)["results"].map do |artifact|
267
+ from_url(artifact["uri"], client: client)
267
268
  end
268
269
  end
269
270
 
@@ -292,12 +293,12 @@ module Artifactory
292
293
  options = Util.rename_keys(options,
293
294
  :group => :g,
294
295
  :name => :a,
295
- :version => :v,
296
+ :version => :v
296
297
  )
297
298
  params = Util.slice(options, :g, :a, :v, :repos)
298
299
  format_repos!(params)
299
300
 
300
- client.get('/api/search/versions', params)['results']
301
+ client.get("/api/search/versions", params)["results"]
301
302
  rescue Error::HTTPError => e
302
303
  raise unless e.code == 404
303
304
  []
@@ -343,7 +344,7 @@ module Artifactory
343
344
  options = Util.rename_keys(options,
344
345
  :group => :g,
345
346
  :name => :a,
346
- :version => :v,
347
+ :version => :v
347
348
  )
348
349
  params = Util.slice(options, :g, :a, :v, :repos, :remote)
349
350
  format_repos!(params)
@@ -352,7 +353,7 @@ module Artifactory
352
353
  # literal "1"...
353
354
  params[:remote] = 1 if options[:remote]
354
355
 
355
- client.get('/api/search/latestVersion', params)
356
+ client.get("/api/search/latestVersion", params)
356
357
  rescue Error::HTTPError => e
357
358
  raise unless e.code == 404
358
359
  nil
@@ -371,14 +372,14 @@ module Artifactory
371
372
  end
372
373
  end
373
374
 
374
- attribute :uri, ->{ raise 'API path missing!' }
375
+ attribute :uri, -> { raise "API path missing!" }
375
376
  attribute :checksums
376
377
  attribute :created
377
- attribute :download_uri, ->{ raise 'Download URI missing!' }
378
+ attribute :download_uri, -> { raise "Download URI missing!" }
378
379
  attribute :key
379
380
  attribute :last_modified
380
381
  attribute :last_updated
381
- attribute :local_path, ->{ raise 'Local destination missing!' }
382
+ attribute :local_path, -> { raise "Local destination missing!" }
382
383
  attribute :mime_type
383
384
  attribute :repo
384
385
  attribute :size
@@ -389,7 +390,7 @@ module Artifactory
389
390
  # @return [String]
390
391
  #
391
392
  def sha1
392
- checksums && checksums['sha1']
393
+ checksums && checksums["sha1"]
393
394
  end
394
395
 
395
396
  #
@@ -398,7 +399,7 @@ module Artifactory
398
399
  # @return [String]
399
400
  #
400
401
  def md5
401
- checksums && checksums['md5']
402
+ checksums && checksums["md5"]
402
403
  end
403
404
 
404
405
  #
@@ -438,7 +439,7 @@ module Artifactory
438
439
  # the list of properties
439
440
  #
440
441
  def properties
441
- @properties ||= client.get(File.join('/api/storage', relative_path), properties: nil)['properties']
442
+ @properties ||= client.get(File.join("/api/storage", relative_path), properties: nil)["properties"]
442
443
  end
443
444
 
444
445
  #
@@ -453,7 +454,7 @@ module Artifactory
453
454
  # @return [Hash<String, Array<Hash>>]
454
455
  #
455
456
  def compliance
456
- @compliance ||= client.get(File.join('/api/compliance', relative_path))
457
+ @compliance ||= client.get(File.join("/api/compliance", relative_path))
457
458
  end
458
459
 
459
460
  #
@@ -489,7 +490,7 @@ module Artifactory
489
490
  # Construct the full path for the file
490
491
  destination = File.join(target, filename)
491
492
 
492
- File.open(destination, 'wb') do |file|
493
+ File.open(destination, "wb") do |file|
493
494
  file.write(client.get(download_uri))
494
495
  end
495
496
 
@@ -535,8 +536,8 @@ module Artifactory
535
536
  endpoint = File.join("#{url_safe(repo)}#{matrix}", remote_path)
536
537
 
537
538
  # Include checksums in headers if given.
538
- headers['X-Checksum-Md5'] = md5 if md5
539
- headers['X-Checksum-Sha1'] = sha1 if sha1
539
+ headers["X-Checksum-Md5"] = md5 if md5
540
+ headers["X-Checksum-Sha1"] = sha1 if sha1
540
541
 
541
542
  response = client.put(endpoint, file, headers)
542
543
 
@@ -593,8 +594,8 @@ module Artifactory
593
594
  #
594
595
  def upload_with_checksum(repo, remote_path, checksum, properties = {})
595
596
  upload(repo, remote_path, properties,
596
- 'X-Checksum-Deploy' => true,
597
- 'X-Checksum-Sha1' => checksum,
597
+ "X-Checksum-Deploy" => true,
598
+ "X-Checksum-Sha1" => checksum
598
599
  )
599
600
  end
600
601
 
@@ -612,7 +613,7 @@ module Artifactory
612
613
  #
613
614
  def upload_from_archive(repo, remote_path, properties = {})
614
615
  upload(repo, remote_path, properties,
615
- 'X-Explode-Archive' => true,
616
+ "X-Explode-Archive" => true
616
617
  )
617
618
  end
618
619
 
@@ -628,7 +629,7 @@ module Artifactory
628
629
  # @return [String]
629
630
  #
630
631
  def relative_path
631
- @relative_path ||= uri.split('/api/storage', 2).last
632
+ @relative_path ||= uri.split("/api/storage", 2).last
632
633
  end
633
634
 
634
635
  #
@@ -664,7 +665,7 @@ module Artifactory
664
665
  param[:dry] = 1 if options[:dry_run]
665
666
  end
666
667
 
667
- endpoint = File.join('/api', action.to_s, relative_path) + "?#{to_query_string_parameters(params)}"
668
+ endpoint = File.join("/api", action.to_s, relative_path) + "?#{to_query_string_parameters(params)}"
668
669
 
669
670
  client.post(endpoint, {})
670
671
  end
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'rexml/document'
17
+ require "rexml/document"
18
18
 
19
19
  module Artifactory
20
20
  class Resource::Backup < Resource::Base
@@ -33,7 +33,7 @@ module Artifactory
33
33
  #
34
34
  def all(options = {})
35
35
  config = Resource::System.configuration(options)
36
- list_from_config('config/backups/backup', config, options)
36
+ list_from_config("config/backups/backup", config, options)
37
37
  end
38
38
 
39
39
  #
@@ -81,7 +81,7 @@ module Artifactory
81
81
  #
82
82
  def list_from_config(xpath, config, options = {})
83
83
  REXML::XPath.match(config, xpath).map do |r|
84
- hash = Util.xml_to_hash(r, 'excludedRepositories', false)
84
+ hash = Util.xml_to_hash(r, "excludedRepositories", false)
85
85
  from_hash(hash, options)
86
86
  end
87
87
  end
@@ -102,12 +102,12 @@ module Artifactory
102
102
  def find_from_config(xpath, config, options = {})
103
103
  name_node = REXML::XPath.match(config, xpath)
104
104
  return nil if name_node.empty?
105
- properties = Util.xml_to_hash(name_node[0].parent, 'excludedRepositories', false)
105
+ properties = Util.xml_to_hash(name_node[0].parent, "excludedRepositories", false)
106
106
  from_hash(properties, options)
107
107
  end
108
108
  end
109
109
 
110
- attribute :key, ->{ raise 'name missing!' }
110
+ attribute :key, -> { raise "name missing!" }
111
111
  attribute :enabled, true
112
112
  attribute :dir
113
113
  attribute :cron_exp
@@ -14,9 +14,9 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'cgi'
18
- require 'json'
19
- require 'uri'
17
+ require "cgi"
18
+ require "json"
19
+ require "uri"
20
20
 
21
21
  module Artifactory
22
22
  class Resource::Base
@@ -227,7 +227,7 @@ module Artifactory
227
227
  #
228
228
  def format_repos!(options)
229
229
  return options if options[:repos].nil? || options[:repos].empty?
230
- options[:repos] = Array(options[:repos]).compact.join(',')
230
+ options[:repos] = Array(options[:repos]).compact.join(",")
231
231
  options
232
232
  end
233
233
 
@@ -245,7 +245,7 @@ module Artifactory
245
245
  end
246
246
  end
247
247
 
248
- attribute :client, ->{ Artifactory.client }
248
+ attribute :client, -> { Artifactory.client }
249
249
 
250
250
  #
251
251
  # Create a new instance
@@ -360,7 +360,7 @@ module Artifactory
360
360
  if properties.empty?
361
361
  nil
362
362
  else
363
- properties.join('&')
363
+ properties.join("&")
364
364
  end
365
365
  end
366
366
 
@@ -383,7 +383,7 @@ module Artifactory
383
383
  private
384
384
 
385
385
  def short_classname
386
- @short_classname ||= self.class.name.split('::').last
386
+ @short_classname ||= self.class.name.split("::").last
387
387
  end
388
388
  end
389
389
  end
@@ -14,13 +14,13 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'time'
17
+ require "time"
18
18
 
19
19
  module Artifactory
20
20
  class Resource::Build < Resource::Base
21
- BUILD_SCHEMA_VERSION = '1.0.1'.freeze
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 }
24
24
 
25
25
  class << self
26
26
  #
@@ -39,9 +39,9 @@ module Artifactory
39
39
  #
40
40
  def all(name, options = {})
41
41
  client = extract_client!(options)
42
- client.get("/api/build/#{url_safe(name)}")['buildsNumbers'].map do |build_number|
42
+ client.get("/api/build/#{url_safe(name)}")["buildsNumbers"].map do |build_number|
43
43
  # Remove the leading / from the `uri` value. Converts `/484` to `484`.
44
- number = build_number['uri'].slice(1..-1)
44
+ number = build_number["uri"].slice(1..-1)
45
45
  find(name, number, client: client)
46
46
  end.compact.flatten
47
47
  rescue Error::HTTPError => e
@@ -75,7 +75,7 @@ module Artifactory
75
75
  def find(name, number, options = {})
76
76
  client = extract_client!(options)
77
77
  response = client.get("/api/build/#{url_safe(name)}/#{url_safe(number)}")
78
- from_hash(response['buildInfo'], client: client)
78
+ from_hash(response["buildInfo"], client: client)
79
79
  rescue Error::HTTPError => e
80
80
  raise unless e.code == 404
81
81
  nil
@@ -95,9 +95,9 @@ module Artifactory
95
95
  # Based on https://github.com/JFrogDev/build-info/blob/master/README.md#build-info-json-format
96
96
  attribute :properties, {}
97
97
  attribute :version, BUILD_SCHEMA_VERSION
98
- attribute :name, ->{ raise 'Build component missing!' }
99
- attribute :number, ->{ raise 'Build number missing!' }
100
- attribute :type, 'GENERIC'
98
+ attribute :name, -> { raise "Build component missing!" }
99
+ attribute :number, -> { raise "Build number missing!" }
100
+ attribute :type, "GENERIC"
101
101
  attribute :build_agent, {}
102
102
  attribute :agent, {}
103
103
  attribute :started, Time.now.utc.iso8601(3)
@@ -126,7 +126,7 @@ module Artifactory
126
126
  # the list of properties
127
127
  #
128
128
  def diff(previous_build_number)
129
- endpoint = api_path + '?' "diff=#{url_safe(previous_build_number)}"
129
+ endpoint = api_path + "?" "diff=#{url_safe(previous_build_number)}"
130
130
  client.get(endpoint, {})
131
131
  end
132
132
 
@@ -173,8 +173,8 @@ module Artifactory
173
173
  #
174
174
  def promote(target_repo, options = {})
175
175
  request_body = {}.tap do |body|
176
- body[:status] = options[:status] || 'promoted'
177
- body[:comment] = options[:comment] || ''
176
+ body[:status] = options[:status] || "promoted"
177
+ body[:comment] = options[:comment] || ""
178
178
  body[:ciUser] = options[:user] || Artifactory.username
179
179
  body[:dryRun] = options[:dry_run] || false
180
180
  body[:targetRepo] = target_repo
@@ -188,7 +188,7 @@ module Artifactory
188
188
 
189
189
  endpoint = "/api/build/promote/#{url_safe(name)}/#{url_safe(number)}"
190
190
  client.post(endpoint, JSON.fast_generate(request_body),
191
- 'Content-Type' => 'application/json'
191
+ "Content-Type" => "application/json"
192
192
  )
193
193
  end
194
194
 
@@ -204,8 +204,8 @@ module Artifactory
204
204
  file.write(to_json)
205
205
  file.rewind
206
206
 
207
- client.put('/api/build', file,
208
- 'Content-Type' => 'application/json'
207
+ client.put("/api/build", file,
208
+ "Content-Type" => "application/json"
209
209
  )
210
210
  true
211
211
  ensure
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'time'
17
+ require "time"
18
18
 
19
19
  module Artifactory
20
20
  class Resource::BuildComponent < Resource::Base
@@ -33,7 +33,7 @@ module Artifactory
33
33
  #
34
34
  def all(options = {})
35
35
  client = extract_client!(options)
36
- client.get('/api/build')['builds'].map do |component|
36
+ client.get("/api/build")["builds"].map do |component|
37
37
  from_hash(component, client: client)
38
38
  end.compact.flatten
39
39
  rescue Error::HTTPError => e
@@ -82,7 +82,7 @@ module Artifactory
82
82
  end
83
83
 
84
84
  attribute :uri
85
- attribute :name, ->{ raise 'Name missing!' }
85
+ attribute :name, -> { raise "Name missing!" }
86
86
  attribute :last_started
87
87
 
88
88
  #
@@ -117,7 +117,7 @@ module Artifactory
117
117
  #
118
118
  def delete(options = {})
119
119
  params = {}.tap do |param|
120
- param[:buildNumbers] = options[:build_numbers].join(',') if options[:build_numbers]
120
+ param[:buildNumbers] = options[:build_numbers].join(",") if options[:build_numbers]
121
121
  param[:artifacts] = 1 if options[:artifacts]
122
122
  param[:deleteAll] = 1 if options[:delete_all]
123
123
  end
@@ -31,8 +31,8 @@ module Artifactory
31
31
  #
32
32
  def all(options = {})
33
33
  client = extract_client!(options)
34
- client.get('/api/security/groups').map do |hash|
35
- from_url(hash['uri'], client: client)
34
+ client.get("/api/security/groups").map do |hash|
35
+ from_url(hash["uri"], client: client)
36
36
  end
37
37
  end
38
38
 
@@ -67,7 +67,7 @@ module Artifactory
67
67
 
68
68
  attribute :auto_join
69
69
  attribute :description
70
- attribute :name, ->{ raise 'Name missing!' }
70
+ attribute :name, -> { raise "Name missing!" }
71
71
  attribute :realm
72
72
  attribute :realm_attributes
73
73
 
@@ -118,7 +118,7 @@ module Artifactory
118
118
  #
119
119
  def headers
120
120
  @headers ||= {
121
- 'Content-Type' => 'application/vnd.org.jfrog.artifactory.security.Group+json'
121
+ "Content-Type" => "application/vnd.org.jfrog.artifactory.security.Group+json",
122
122
  }
123
123
  end
124
124
  end