artifactory 2.5.2 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Artifactory
4
4
  describe Resource::Plugin do
@@ -9,16 +9,16 @@ module Artifactory
9
9
  allow(client).to receive(:get).and_return(response) if defined?(response)
10
10
  end
11
11
 
12
- describe '.all' do
13
- let(:response) { ['a', 'b', 'c'] }
12
+ describe ".all" do
13
+ let(:response) { %w{a b c} }
14
14
 
15
- it 'gets /api/plugins' do
16
- expect(client).to receive(:get).with('/api/plugins').once
15
+ it "gets /api/plugins" do
16
+ expect(client).to receive(:get).with("/api/plugins").once
17
17
  described_class.all
18
18
  end
19
19
 
20
- it 'returns the plugins' do
21
- expect(described_class.all).to eq(['a', 'b', 'c'])
20
+ it "returns the plugins" do
21
+ expect(described_class.all).to eq(%w{a b c})
22
22
  end
23
23
  end
24
24
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Artifactory
4
4
  describe Resource::Repository do
@@ -9,208 +9,208 @@ module Artifactory
9
9
  allow(client).to receive(:get).and_return(response) if defined?(response)
10
10
  end
11
11
 
12
- describe '.all' do
12
+ describe ".all" do
13
13
  let(:response) do
14
14
  [
15
- { 'key' => 'a' },
16
- { 'key' => 'b' },
17
- { 'key' => 'c' },
15
+ { "key" => "a" },
16
+ { "key" => "b" },
17
+ { "key" => "c" },
18
18
  ]
19
19
  end
20
20
  before do
21
- allow(described_class).to receive(:find).with('a', client: client).and_return('a')
22
- allow(described_class).to receive(:find).with('b', client: client).and_return('b')
23
- allow(described_class).to receive(:find).with('c', client: client).and_return('c')
21
+ allow(described_class).to receive(:find).with("a", client: client).and_return("a")
22
+ allow(described_class).to receive(:find).with("b", client: client).and_return("b")
23
+ allow(described_class).to receive(:find).with("c", client: client).and_return("c")
24
24
  end
25
25
 
26
- it 'gets /api/repositories' do
27
- expect(client).to receive(:get).with('/api/repositories').once
26
+ it "gets /api/repositories" do
27
+ expect(client).to receive(:get).with("/api/repositories").once
28
28
  described_class.all
29
29
  end
30
30
 
31
- it 'returns the repositories' do
32
- expect(described_class.all).to eq(['a', 'b', 'c'])
31
+ it "returns the repositories" do
32
+ expect(described_class.all).to eq(%w{a b c})
33
33
  end
34
34
  end
35
35
 
36
- describe '.find' do
36
+ describe ".find" do
37
37
  let(:response) { {} }
38
38
 
39
39
  it 'gets /api/repositories/#{name}' do
40
- expect(client).to receive(:get).with('/api/repositories/libs-release-local').once
41
- described_class.find('libs-release-local')
40
+ expect(client).to receive(:get).with("/api/repositories/libs-release-local").once
41
+ described_class.find("libs-release-local")
42
42
  end
43
43
  end
44
44
 
45
- describe '.from_hash' do
45
+ describe ".from_hash" do
46
46
  let(:hash) do
47
47
  {
48
- 'key' => 'libs-release-local',
49
- 'description' => 'Local repository for in-house libraries',
50
- 'notes' => '',
51
- 'includesPattern' => '**/*',
52
- 'excludesPattern' => '',
53
- 'enableNuGetSupport' => false,
54
- 'enableGemsSupport' => false,
55
- 'checksumPolicyType' => 'server-generated-checksums',
56
- 'handleReleases' => true,
57
- 'handleSnapshots' => false,
58
- 'maxUniqueSnapshots' => 10,
59
- 'snapshotVersionBehavior' => 'unique',
60
- 'suppressPomConsistencyChecks' => true,
61
- 'blackedOut' => false,
62
- 'propertySets' => ['artifactory'],
63
- 'archiveBrowsingEnabled' => false,
64
- 'calculateYumMetadata' => false,
65
- 'yumRootDepth' => 3,
66
- 'rclass' => 'local',
67
- 'url' => 'someurl',
48
+ "key" => "libs-release-local",
49
+ "description" => "Local repository for in-house libraries",
50
+ "notes" => "",
51
+ "includesPattern" => "**/*",
52
+ "excludesPattern" => "",
53
+ "enableNuGetSupport" => false,
54
+ "enableGemsSupport" => false,
55
+ "checksumPolicyType" => "server-generated-checksums",
56
+ "handleReleases" => true,
57
+ "handleSnapshots" => false,
58
+ "maxUniqueSnapshots" => 10,
59
+ "snapshotVersionBehavior" => "unique",
60
+ "suppressPomConsistencyChecks" => true,
61
+ "blackedOut" => false,
62
+ "propertySets" => ["artifactory"],
63
+ "archiveBrowsingEnabled" => false,
64
+ "calculateYumMetadata" => false,
65
+ "yumRootDepth" => 3,
66
+ "rclass" => "local",
67
+ "url" => "someurl",
68
68
  }
69
69
  end
70
70
 
71
- it 'creates a new instance' do
71
+ it "creates a new instance" do
72
72
  instance = described_class.from_hash(hash)
73
73
  expect(instance.blacked_out).to be_falsey
74
- expect(instance.description).to eq('Local repository for in-house libraries')
75
- expect(instance.checksum_policy_type).to eq('server-generated-checksums')
76
- expect(instance.excludes_pattern).to eq('')
74
+ expect(instance.description).to eq("Local repository for in-house libraries")
75
+ expect(instance.checksum_policy_type).to eq("server-generated-checksums")
76
+ expect(instance.excludes_pattern).to eq("")
77
77
  expect(instance.handle_releases).to be_truthy
78
78
  expect(instance.handle_snapshots).to be_falsey
79
- expect(instance.includes_pattern).to eq('**/*')
80
- expect(instance.key).to eq('libs-release-local')
79
+ expect(instance.includes_pattern).to eq("**/*")
80
+ expect(instance.key).to eq("libs-release-local")
81
81
  expect(instance.max_unique_snapshots).to eq(10)
82
- expect(instance.notes).to eq('')
83
- expect(instance.package_type).to eq('generic')
84
- expect(instance.property_sets).to eq(['artifactory'])
85
- expect(instance.rclass).to eq('local')
86
- expect(instance.repo_layout_ref).to eq('simple-default')
87
- expect(instance.snapshot_version_behavior).to eq('unique')
82
+ expect(instance.notes).to eq("")
83
+ expect(instance.package_type).to eq("generic")
84
+ expect(instance.property_sets).to eq(["artifactory"])
85
+ expect(instance.rclass).to eq("local")
86
+ expect(instance.repo_layout_ref).to eq("simple-default")
87
+ expect(instance.snapshot_version_behavior).to eq("unique")
88
88
  expect(instance.suppress_pom_consistency_checks).to be_truthy
89
- expect(instance.url).to eq('someurl')
89
+ expect(instance.url).to eq("someurl")
90
90
  expect(instance.yum_root_depth).to eq(3)
91
91
  expect(instance.calculate_yum_metadata).to eq(false)
92
92
  end
93
93
  end
94
94
 
95
- describe '#save' do
95
+ describe "#save" do
96
96
  let(:client) { double }
97
97
  before do
98
98
  subject.client = client
99
- subject.key = 'libs-release-local'
99
+ subject.key = "libs-release-local"
100
100
  end
101
101
 
102
- context 'when the repository is new' do
102
+ context "when the repository is new" do
103
103
  before do
104
104
  allow(described_class).to receive(:find).with(subject.key, client: client).and_return(nil)
105
105
  end
106
106
 
107
- it 'PUTS the file to the server' do
107
+ it "PUTS the file to the server" do
108
108
  expect(client).to receive(:put).with("/api/repositories/#{subject.key}", kind_of(String), kind_of(Hash))
109
109
  subject.save
110
110
  end
111
111
  end
112
112
 
113
- context 'when the repository exists' do
113
+ context "when the repository exists" do
114
114
  before do
115
- allow(described_class).to receive(:find).with(subject.key, client: client).and_return({key: subject.key})
115
+ allow(described_class).to receive(:find).with(subject.key, client: client).and_return({ key: subject.key })
116
116
  end
117
117
 
118
- it 'POSTS the file to the server' do
118
+ it "POSTS the file to the server" do
119
119
  expect(client).to receive(:post).with("/api/repositories/#{subject.key}", kind_of(String), kind_of(Hash))
120
120
  subject.save
121
121
  end
122
122
  end
123
123
  end
124
124
 
125
- describe '#upload' do
125
+ describe "#upload" do
126
126
  let(:client) { double(put: {}) }
127
127
  let(:file) { double(File) }
128
- let(:path) { '/fake/path' }
128
+ let(:path) { "/fake/path" }
129
129
  before do
130
130
  subject.client = client
131
- subject.key = 'libs-release-local'
131
+ subject.key = "libs-release-local"
132
132
  allow(File).to receive(:new).with(/\A(\w:)?#{path}\z/).and_return(file)
133
133
  end
134
134
 
135
- context 'when the artifact is a file path' do
136
- it 'PUTs the file at the path to the server' do
137
- expect(client).to receive(:put).with('libs-release-local/remote/path', file, {})
135
+ context "when the artifact is a file path" do
136
+ it "PUTs the file at the path to the server" do
137
+ expect(client).to receive(:put).with("libs-release-local/remote/path", file, {})
138
138
 
139
- subject.upload(path, '/remote/path')
139
+ subject.upload(path, "/remote/path")
140
140
  end
141
141
  end
142
142
 
143
- context 'when matrix properties are given' do
144
- it 'converts the hash into matrix properties' do
145
- expect(client).to receive(:put).with('libs-release-local;branch=master;user=Seth+Vargo%2B1/remote/path', file, {})
143
+ context "when matrix properties are given" do
144
+ it "converts the hash into matrix properties" do
145
+ expect(client).to receive(:put).with("libs-release-local;branch=master;user=Seth+Vargo%2B1/remote/path", file, {})
146
146
 
147
- subject.upload(path, '/remote/path',
148
- branch: 'master',
149
- user: 'Seth Vargo+1',
147
+ subject.upload(path, "/remote/path",
148
+ branch: "master",
149
+ user: "Seth Vargo+1"
150
150
  )
151
151
  end
152
152
 
153
- it 'converts the hash into matrix properties' do
154
- expect(client).to receive(:put).with('libs-release-local;branch=master;user=Seth/remote/path', file, {})
153
+ it "converts the hash into matrix properties" do
154
+ expect(client).to receive(:put).with("libs-release-local;branch=master;user=Seth/remote/path", file, {})
155
155
 
156
- subject.upload(path, '/remote/path',
157
- branch: 'master',
158
- user: 'Seth',
156
+ subject.upload(path, "/remote/path",
157
+ branch: "master",
158
+ user: "Seth"
159
159
  )
160
160
  end
161
161
 
162
162
  it 'converts spaces to "+" characters' do
163
- expect(client).to receive(:put).with('libs-release-local;user=Seth+Vargo/remote/path', file, {})
163
+ expect(client).to receive(:put).with("libs-release-local;user=Seth+Vargo/remote/path", file, {})
164
164
 
165
- subject.upload(path, '/remote/path',
166
- user: 'Seth Vargo',
165
+ subject.upload(path, "/remote/path",
166
+ user: "Seth Vargo"
167
167
  )
168
168
  end
169
169
 
170
170
  it 'converts "+" to "%2B"' do
171
- expect(client).to receive(:put).with('libs-release-local;version=12.0.0-alpha.1%2B20140826080510.git.50.f5ff271/remote/path', file, {})
171
+ expect(client).to receive(:put).with("libs-release-local;version=12.0.0-alpha.1%2B20140826080510.git.50.f5ff271/remote/path", file, {})
172
172
 
173
- subject.upload(path, '/remote/path',
174
- version: '12.0.0-alpha.1+20140826080510.git.50.f5ff271',
173
+ subject.upload(path, "/remote/path",
174
+ version: "12.0.0-alpha.1+20140826080510.git.50.f5ff271"
175
175
  )
176
176
  end
177
177
  end
178
178
 
179
- context 'when custom headers are given' do
180
- it 'passes the headers to the client' do
181
- headers = { 'Content-Type' => 'text/plain' }
182
- expect(client).to receive(:put).with('libs-release-local/remote/path', file, headers)
179
+ context "when custom headers are given" do
180
+ it "passes the headers to the client" do
181
+ headers = { "Content-Type" => "text/plain" }
182
+ expect(client).to receive(:put).with("libs-release-local/remote/path", file, headers)
183
183
 
184
- subject.upload(path, '/remote/path', {}, headers)
184
+ subject.upload(path, "/remote/path", {}, headers)
185
185
  end
186
186
  end
187
187
  end
188
188
 
189
- describe '#artifacts' do
190
- before { subject.key = 'libs-release-local' }
189
+ describe "#artifacts" do
190
+ before { subject.key = "libs-release-local" }
191
191
 
192
- it 'returns an artifact collection' do
192
+ it "returns an artifact collection" do
193
193
  expect(subject.artifacts).to be_a(Collection::Artifact)
194
194
  end
195
195
  end
196
196
 
197
- describe '#upload_with_checksum' do
198
- it 'delecates to artifact' do
199
- artifact = double('Artifact')
197
+ describe "#upload_with_checksum" do
198
+ it "delecates to artifact" do
199
+ artifact = double("Artifact")
200
200
  allow(Resource::Artifact).to receive(:new) { artifact }
201
- subject.key = 'libs-release-local'
201
+ subject.key = "libs-release-local"
202
202
  expect(artifact).to receive(:upload_with_checksum).once
203
- subject.upload_with_checksum('/local/path', '/remote/path', 'checksum', {properties: :foobar})
203
+ subject.upload_with_checksum("/local/path", "/remote/path", "checksum", { properties: :foobar })
204
204
  end
205
205
  end
206
206
 
207
- describe '#upload_from_archive' do
208
- it 'delecates to artifact' do
209
- artifact = double('Artifact')
207
+ describe "#upload_from_archive" do
208
+ it "delecates to artifact" do
209
+ artifact = double("Artifact")
210
210
  allow(Resource::Artifact).to receive(:new) { artifact }
211
- subject.key = 'libs-release-local'
211
+ subject.key = "libs-release-local"
212
212
  expect(artifact).to receive(:upload_from_archive).once
213
- subject.upload_from_archive('/local/path', '/remote/path', {properties: :foobar})
213
+ subject.upload_from_archive("/local/path", "/remote/path", { properties: :foobar })
214
214
  end
215
215
  end
216
216
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Artifactory
4
4
  describe Resource::System do
@@ -9,35 +9,35 @@ module Artifactory
9
9
  allow(client).to receive(:get).and_return(response) if defined?(response)
10
10
  end
11
11
 
12
- describe '.info' do
13
- let(:response) { 'This is the response...' }
12
+ describe ".info" do
13
+ let(:response) { "This is the response..." }
14
14
 
15
- it 'calls /api/system' do
16
- expect(client).to receive(:get).with('/api/system').once
15
+ it "calls /api/system" do
16
+ expect(client).to receive(:get).with("/api/system").once
17
17
  described_class.info
18
18
  end
19
19
 
20
- it 'returns the plan-text body' do
20
+ it "returns the plan-text body" do
21
21
  expect(described_class.info).to eq(response)
22
22
  end
23
23
  end
24
24
 
25
- describe '.ping' do
26
- let(:response) { '' }
25
+ describe ".ping" do
26
+ let(:response) { "" }
27
27
 
28
- it 'gets /api/system/ping' do
29
- expect(client).to receive(:get).with('/api/system/ping').once
28
+ it "gets /api/system/ping" do
29
+ expect(client).to receive(:get).with("/api/system/ping").once
30
30
  described_class.ping
31
31
  end
32
32
 
33
- context 'when the system is ok' do
34
- it 'returns true' do
33
+ context "when the system is ok" do
34
+ it "returns true" do
35
35
  expect(described_class.ping).to be_truthy
36
36
  end
37
37
  end
38
38
 
39
- context 'when the system is not running' do
40
- it 'returns false' do
39
+ context "when the system is not running" do
40
+ it "returns false" do
41
41
  allow(client).to receive(:get)
42
42
  .and_raise(Error::ConnectionError.new(Artifactory.endpoint))
43
43
  expect(described_class.ping).to be_falsey
@@ -45,44 +45,44 @@ module Artifactory
45
45
  end
46
46
  end
47
47
 
48
- describe '.configuration' do
49
- let(:response) { '<config></config>' }
48
+ describe ".configuration" do
49
+ let(:response) { "<config></config>" }
50
50
 
51
- it 'gets /api/system/configuration' do
52
- expect(client).to receive(:get).with('/api/system/configuration').once
51
+ it "gets /api/system/configuration" do
52
+ expect(client).to receive(:get).with("/api/system/configuration").once
53
53
  described_class.configuration
54
54
  end
55
55
 
56
- it 'returns the xml' do
56
+ it "returns the xml" do
57
57
  expect(described_class.configuration).to be_a(REXML::Document)
58
58
  end
59
59
  end
60
60
 
61
- describe '.update_configuration' do
61
+ describe ".update_configuration" do
62
62
  let(:xml) { double(:xml) }
63
- let(:response) { double(body: '...') }
63
+ let(:response) { double(body: "...") }
64
64
  before { allow(client).to receive(:post).and_return(response) }
65
65
 
66
- it 'posts /api/system/configuration' do
67
- headers = { 'Content-Type' => 'application/xml' }
68
- expect(client).to receive(:post).with('/api/system/configuration', xml, headers).once
66
+ it "posts /api/system/configuration" do
67
+ headers = { "Content-Type" => "application/xml" }
68
+ expect(client).to receive(:post).with("/api/system/configuration", xml, headers).once
69
69
  described_class.update_configuration(xml)
70
70
  end
71
71
 
72
- it 'returns the body of the response' do
72
+ it "returns the body of the response" do
73
73
  expect(described_class.update_configuration(xml)).to eq(response)
74
74
  end
75
75
  end
76
76
 
77
- describe '.version' do
78
- let(:response) { double(json: { 'foo' => 'bar' }) }
77
+ describe ".version" do
78
+ let(:response) { double(json: { "foo" => "bar" }) }
79
79
 
80
- it 'gets /api/system/version' do
81
- expect(client).to receive(:get).with('/api/system/version').once
80
+ it "gets /api/system/version" do
81
+ expect(client).to receive(:get).with("/api/system/version").once
82
82
  described_class.version
83
83
  end
84
84
 
85
- it 'returns the parsed JSON of the response' do
85
+ it "returns the parsed JSON of the response" do
86
86
  expect(described_class.version).to eq(response)
87
87
  end
88
88
  end