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
@@ -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::Layout < 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/repoLayouts/repoLayout', config, options)
36
+ list_from_config("config/repoLayouts/repoLayout", config, options)
37
37
  end
38
38
 
39
39
  #
@@ -63,7 +63,7 @@ module Artifactory
63
63
  end
64
64
  end
65
65
 
66
- attribute :name, ->{ raise 'Name missing!' }
66
+ attribute :name, -> { raise "Name missing!" }
67
67
  attribute :artifact_path_pattern
68
68
  attribute :distinctive_descriptor_path_pattern, true
69
69
  attribute :descriptor_path_pattern
@@ -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::LDAPSetting < 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/security/ldapSettings/ldapSetting', config, options)
36
+ list_from_config("config/security/ldapSettings/ldapSetting", config, options)
37
37
  end
38
38
 
39
39
  #
@@ -63,6 +63,7 @@ module Artifactory
63
63
  end
64
64
 
65
65
  private
66
+
66
67
  #
67
68
  # List all the child text elements in the Artifactory configuration file
68
69
  # of a node matching the specified xpath
@@ -78,7 +79,7 @@ module Artifactory
78
79
  #
79
80
  def list_from_config(xpath, config, options = {})
80
81
  REXML::XPath.match(config, xpath).map do |r|
81
- hash = Util.xml_to_hash(r, 'search')
82
+ hash = Util.xml_to_hash(r, "search")
82
83
  from_hash(hash, options)
83
84
  end
84
85
  end
@@ -99,7 +100,7 @@ module Artifactory
99
100
  def find_from_config(xpath, config, options = {})
100
101
  name_node = REXML::XPath.match(config, xpath)
101
102
  return nil if name_node.empty?
102
- properties = Util.xml_to_hash(name_node[0].parent, 'search')
103
+ properties = Util.xml_to_hash(name_node[0].parent, "search")
103
104
  from_hash(properties, options)
104
105
  end
105
106
  end
@@ -107,7 +108,7 @@ module Artifactory
107
108
  # Ordered to match the artifactory xsd to make consuming the attributes
108
109
  # hash when writing artifactory xml more convenient.
109
110
  # http://bit.ly/UHMrHc
110
- attribute :key, ->{ raise 'name missing!' }
111
+ attribute :key, -> { raise "name missing!" }
111
112
  attribute :enabled, true
112
113
  attribute :ldap_url
113
114
  attribute :search_filter
@@ -116,6 +117,6 @@ module Artifactory
116
117
  attribute :manager_dn
117
118
  attribute :manager_password
118
119
  attribute :auto_create_user
119
- attribute :email_attribute, 'mail'
120
+ attribute :email_attribute, "mail"
120
121
  end
121
122
  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::MailServer < 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/mailServer', config, options)
36
+ list_from_config("config/mailServer", config, options)
37
37
  end
38
38
 
39
39
  #
@@ -64,7 +64,7 @@ module Artifactory
64
64
  end
65
65
 
66
66
  attribute :enabled
67
- attribute :host, ->{ raise 'host missing!' }
67
+ attribute :host, -> { raise "host missing!" }
68
68
  attribute :port
69
69
  attribute :username
70
70
  attribute :password
@@ -1,11 +1,11 @@
1
1
  module Artifactory
2
2
  class Resource::PermissionTarget < Resource::Base
3
3
  VERBOSE_PERMS = {
4
- 'd' => 'delete',
5
- 'm' => 'admin',
6
- 'n' => 'annotate',
7
- 'r' => 'read',
8
- 'w' => 'deploy',
4
+ "d" => "delete",
5
+ "m" => "admin",
6
+ "n" => "annotate",
7
+ "r" => "read",
8
+ "w" => "deploy",
9
9
  }
10
10
  class << self
11
11
  #
@@ -22,8 +22,8 @@ module Artifactory
22
22
  #
23
23
  def all(options = {})
24
24
  client = extract_client!(options)
25
- client.get('/api/security/permissions').map do |hash|
26
- from_url(hash['uri'], client: client)
25
+ client.get("/api/security/permissions").map do |hash|
26
+ from_url(hash["uri"], client: client)
27
27
  end
28
28
  end
29
29
 
@@ -61,7 +61,7 @@ module Artifactory
61
61
  #
62
62
  def from_hash(hash, options = {})
63
63
  super.tap do |instance|
64
- %w(users groups).each do |key|
64
+ %w{users groups}.each do |key|
65
65
  if instance.principals[key] && !instance.principals[key].nil?
66
66
  instance.principals[key] = Hash[instance.principals[key].map { |k, v| [k, verbose(v)] } ]
67
67
  end
@@ -93,7 +93,7 @@ module Artifactory
93
93
  # @return [Hash]
94
94
  #
95
95
  def to_abbreviated
96
- { 'users' => abbreviate_principal(@users), 'groups' => abbreviate_principal(@groups) }
96
+ { "users" => abbreviate_principal(@users), "groups" => abbreviate_principal(@groups) }
97
97
  end
98
98
 
99
99
  private
@@ -103,7 +103,7 @@ module Artifactory
103
103
  #
104
104
  def abbreviate_permissions(array)
105
105
  inverse = VERBOSE_PERMS.invert
106
- if (inverse.keys & array).sort != array.sort then
106
+ if (inverse.keys & array).sort != array.sort
107
107
  raise "One of your principals contains an invalid permission. Valid permissions are #{inverse.keys.join(', ')}"
108
108
  end
109
109
  array.map { |elt| inverse[elt] }.sort
@@ -117,14 +117,14 @@ module Artifactory
117
117
  end
118
118
  end
119
119
 
120
- attribute :name, ->{ raise 'Name missing!' }
121
- attribute :includes_pattern, '**'
122
- attribute :excludes_pattern, ''
120
+ attribute :name, -> { raise "Name missing!" }
121
+ attribute :includes_pattern, "**"
122
+ attribute :excludes_pattern, ""
123
123
  attribute :repositories
124
- attribute :principals, { 'users' => {}, 'groups' => {} }
124
+ attribute :principals, { "users" => {}, "groups" => {} }
125
125
 
126
126
  def client_principal
127
- @client_principal ||= Principal.new(principals['users'], principals['groups'])
127
+ @client_principal ||= Principal.new(principals["users"], principals["groups"])
128
128
  end
129
129
 
130
130
  #
@@ -136,9 +136,9 @@ module Artifactory
136
136
  #
137
137
  def delete
138
138
  client.delete(api_path)
139
- true
140
- rescue Error::HTTPError
141
- false
139
+ true
140
+ rescue Error::HTTPError
141
+ false
142
142
  end
143
143
 
144
144
  #
@@ -148,7 +148,7 @@ module Artifactory
148
148
  # @return [Boolean]
149
149
  #
150
150
  def save
151
- send("#{:principals}=", client_principal.to_abbreviated)
151
+ send("principals=", client_principal.to_abbreviated)
152
152
  client.put(api_path, to_json, headers)
153
153
  true
154
154
  end
@@ -199,7 +199,7 @@ module Artifactory
199
199
  #
200
200
  def headers
201
201
  @headers ||= {
202
- 'Content-Type' => 'application/vnd.org.jfrog.artifactory.security.PermissionTarget+json'
202
+ "Content-Type" => "application/vnd.org.jfrog.artifactory.security.PermissionTarget+json",
203
203
  }
204
204
  end
205
205
  end
@@ -31,7 +31,7 @@ module Artifactory
31
31
  #
32
32
  def all(options = {})
33
33
  client = extract_client!(options)
34
- client.get('/api/plugins')
34
+ client.get("/api/plugins")
35
35
  end
36
36
  end
37
37
  end
@@ -31,8 +31,8 @@ module Artifactory
31
31
  #
32
32
  def all(options = {})
33
33
  client = extract_client!(options)
34
- client.get('/api/repositories').map do |hash|
35
- find(hash['key'], client: client)
34
+ client.get("/api/repositories").map do |hash|
35
+ find(hash["key"], client: client)
36
36
  end.compact
37
37
  end
38
38
 
@@ -67,21 +67,21 @@ module Artifactory
67
67
 
68
68
  attribute :blacked_out, false
69
69
  attribute :description
70
- attribute :checksum_policy_type, 'client-checksums'
71
- attribute :excludes_pattern, ''
70
+ attribute :checksum_policy_type, "client-checksums"
71
+ attribute :excludes_pattern, ""
72
72
  attribute :handle_releases, true
73
73
  attribute :handle_snapshots, true
74
- attribute :includes_pattern, '**/*'
75
- attribute :key, ->{ raise 'Key is missing!' }
74
+ attribute :includes_pattern, "**/*"
75
+ attribute :key, -> { raise "Key is missing!" }
76
76
  attribute :max_unique_snapshots, 0
77
77
  attribute :notes
78
- attribute :package_type, 'generic'
78
+ attribute :package_type, "generic"
79
79
  attribute :property_sets, []
80
- attribute :repo_layout_ref, 'simple-default'
81
- attribute :rclass, 'local'
82
- attribute :snapshot_version_behavior, 'non-unique'
80
+ attribute :repo_layout_ref, "simple-default"
81
+ attribute :rclass, "local"
82
+ attribute :snapshot_version_behavior, "non-unique"
83
83
  attribute :suppress_pom_consistency_checks, false
84
- attribute :url, ''
84
+ attribute :url, ""
85
85
  attribute :yum_root_depth, 0
86
86
  attribute :calculate_yum_metadata, false
87
87
 
@@ -154,7 +154,7 @@ module Artifactory
154
154
  #
155
155
  def artifacts
156
156
  @artifacts ||= Collection::Artifact.new(self, repos: key) do
157
- Resource::Artifact.search(name: '.*', repos: key)
157
+ Resource::Artifact.search(name: ".*", repos: key)
158
158
  end
159
159
  end
160
160
 
@@ -169,7 +169,7 @@ module Artifactory
169
169
  includeRootPath: 0,
170
170
  })
171
171
 
172
- response['children']
172
+ response["children"]
173
173
  end
174
174
 
175
175
  #
@@ -204,7 +204,7 @@ module Artifactory
204
204
  #
205
205
  def headers
206
206
  @headers ||= {
207
- 'Content-Type' => content_type
207
+ "Content-Type" => content_type,
208
208
  }
209
209
  end
210
210
 
@@ -216,12 +216,12 @@ module Artifactory
216
216
  #
217
217
  def content_type
218
218
  case rclass.to_s.downcase
219
- when 'local'
220
- 'application/vnd.org.jfrog.artifactory.repositories.LocalRepositoryConfiguration+json'
221
- when 'remote'
222
- 'application/vnd.org.jfrog.artifactory.repositories.RemoteRepositoryConfiguration+json'
223
- when 'virtual'
224
- 'application/vnd.org.jfrog.artifactory.repositories.VirtualRepositoryConfiguration+json'
219
+ when "local"
220
+ "application/vnd.org.jfrog.artifactory.repositories.LocalRepositoryConfiguration+json"
221
+ when "remote"
222
+ "application/vnd.org.jfrog.artifactory.repositories.RemoteRepositoryConfiguration+json"
223
+ when "virtual"
224
+ "application/vnd.org.jfrog.artifactory.repositories.VirtualRepositoryConfiguration+json"
225
225
  else
226
226
  raise "Unknown Repository type `#{rclass}'!"
227
227
  end
@@ -34,7 +34,7 @@ module Artifactory
34
34
  #
35
35
  def info(options = {})
36
36
  client = extract_client!(options)
37
- client.get('/api/system')
37
+ client.get("/api/system")
38
38
  end
39
39
 
40
40
  #
@@ -59,7 +59,7 @@ module Artifactory
59
59
  #
60
60
  def ping(options = {})
61
61
  client = extract_client!(options)
62
- !!client.get('/api/system/ping')
62
+ !!client.get("/api/system/ping")
63
63
  rescue Error::ConnectionError
64
64
  false
65
65
  end
@@ -81,7 +81,7 @@ module Artifactory
81
81
  #
82
82
  def configuration(options = {})
83
83
  client = extract_client!(options)
84
- response = client.get('/api/system/configuration')
84
+ response = client.get("/api/system/configuration")
85
85
 
86
86
  REXML::Document.new(response)
87
87
  end
@@ -106,8 +106,8 @@ module Artifactory
106
106
 
107
107
  # The Artifactory api requires a content type of 'application/xml'.
108
108
  # See http://bit.ly/1l2IvZY
109
- headers = { 'Content-Type' => 'application/xml' }
110
- client.post('/api/system/configuration', xml, headers)
109
+ headers = { "Content-Type" => "application/xml" }
110
+ client.post("/api/system/configuration", xml, headers)
111
111
  end
112
112
 
113
113
  #
@@ -127,7 +127,7 @@ module Artifactory
127
127
  #
128
128
  def version(options = {})
129
129
  client = extract_client!(options)
130
- client.get('/api/system/version')
130
+ client.get("/api/system/version")
131
131
  end
132
132
  end
133
133
  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::URLBase < Resource::Base
@@ -33,7 +33,7 @@ module Artifactory
33
33
  #
34
34
  def all(options = {})
35
35
  config = Resource::System.configuration(options)
36
- simple_text_from_config('config/urlBase', config, options)
36
+ simple_text_from_config("config/urlBase", config, options)
37
37
  end
38
38
 
39
39
  #
@@ -63,6 +63,7 @@ module Artifactory
63
63
  end
64
64
 
65
65
  private
66
+
66
67
  #
67
68
  # List all the text elements in the Artifactory configuration file
68
69
  # matching the given xpath. Ignore any children of elements that match the xpath.
@@ -85,6 +86,6 @@ module Artifactory
85
86
  end
86
87
  end
87
88
 
88
- attribute :url_base, ->{ raise 'URL base missing!' }
89
+ attribute :url_base, -> { raise "URL base missing!" }
89
90
  end
90
91
  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/users').map do |hash|
35
- from_url(hash['uri'], client: client)
34
+ client.get("/api/security/users").map do |hash|
35
+ from_url(hash["uri"], client: client)
36
36
  end
37
37
  end
38
38
 
@@ -70,7 +70,7 @@ module Artifactory
70
70
  attribute :groups, []
71
71
  attribute :internal_password_disabled, false
72
72
  attribute :last_logged_in
73
- attribute :name, -> { raise 'Name missing' }
73
+ attribute :name, -> { raise "Name missing" }
74
74
  attribute :password # write only, never returned
75
75
  attribute :profile_updatable, true
76
76
  attribute :realm
@@ -122,7 +122,7 @@ module Artifactory
122
122
  #
123
123
  def headers
124
124
  @headers ||= {
125
- 'Content-Type' => 'application/vnd.org.jfrog.artifactory.security.User+json'
125
+ "Content-Type" => "application/vnd.org.jfrog.artifactory.security.User+json",
126
126
  }
127
127
  end
128
128
  end
@@ -30,10 +30,10 @@ module Artifactory
30
30
  def underscore(string)
31
31
  string
32
32
  .to_s
33
- .gsub(/::/, '/')
34
- .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
35
- .gsub(/([a-z\d])([A-Z])/,'\1_\2')
36
- .tr('-', '_')
33
+ .gsub(/::/, "/")
34
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
35
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
36
+ .tr("-", "_")
37
37
  .downcase
38
38
  end
39
39
 
@@ -48,12 +48,12 @@ module Artifactory
48
48
  def camelize(string, lowercase = false)
49
49
  result = string
50
50
  .to_s
51
- .split('_')
51
+ .split("_")
52
52
  .map { |e| e.capitalize }
53
53
  .join
54
54
 
55
55
  if lowercase
56
- result[0,1].downcase + result[1..-1]
56
+ result[0, 1].downcase + result[1..-1]
57
57
  else
58
58
  result
59
59
  end
@@ -71,7 +71,7 @@ module Artifactory
71
71
  length = options[:length] || 30
72
72
 
73
73
  if string.length > length
74
- string[0..length-3] + '...'
74
+ string[0..length - 3] + "..."
75
75
  else
76
76
  string
77
77
  end
@@ -119,7 +119,7 @@ module Artifactory
119
119
  # @param [REXML] element
120
120
  # xml element
121
121
  #
122
- def xml_to_hash(element, child_with_children = '', unique_children = true)
122
+ def xml_to_hash(element, child_with_children = "", unique_children = true)
123
123
  properties = {}
124
124
  element.each_element_with_text do |e|
125
125
  if e.name.eql?(child_with_children)
@@ -141,8 +141,8 @@ module Artifactory
141
141
  end
142
142
 
143
143
  def to_type(string)
144
- return true if string.eql?('true')
145
- return false if string.eql?('false')
144
+ return true if string.eql?("true")
145
+ return false if string.eql?("false")
146
146
  return string.to_i if numeric?(string)
147
147
  return string
148
148
  end