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,9 +1,9 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Artifactory
4
4
  describe Resource::Artifact do
5
5
  let(:client) { double(:client) }
6
- let(:endpoint_host) { 'http://33.33.33.11' }
6
+ let(:endpoint_host) { "http://33.33.33.11" }
7
7
  let(:endpoint) { "#{endpoint_host}/" }
8
8
 
9
9
  before(:each) do
@@ -11,34 +11,34 @@ module Artifactory
11
11
  allow(client).to receive(:get).and_return(response) if defined?(response)
12
12
  end
13
13
 
14
- describe '.search' do
15
- let(:response) { { 'results' => [] } }
14
+ describe ".search" do
15
+ let(:response) { { "results" => [] } }
16
16
 
17
- it 'calls /api/search/artifact' do
18
- expect(client).to receive(:get).with('/api/search/artifact', {}).once
17
+ it "calls /api/search/artifact" do
18
+ expect(client).to receive(:get).with("/api/search/artifact", {}).once
19
19
  described_class.search
20
20
  end
21
21
 
22
- it 'slices the correct parameters' do
23
- expect(client).to receive(:get).with('/api/search/artifact',
24
- name: 'name',
25
- repos: 'repo',
22
+ it "slices the correct parameters" do
23
+ expect(client).to receive(:get).with("/api/search/artifact",
24
+ name: "name",
25
+ repos: "repo"
26
26
  ).once
27
27
  described_class.search(
28
- name: 'name',
29
- repos: 'repo',
30
- fizz: 'foo',
28
+ name: "name",
29
+ repos: "repo",
30
+ fizz: "foo"
31
31
  )
32
32
  end
33
33
 
34
- it 'returns an array of objects' do
34
+ it "returns an array of objects" do
35
35
  expect(described_class.search).to be_a(Array)
36
36
  end
37
37
  end
38
38
 
39
- describe '#upload' do
39
+ describe "#upload" do
40
40
  let(:client) { double(put: {}) }
41
- let(:local_path) { '/local/path' }
41
+ let(:local_path) { "/local/path" }
42
42
  let(:file) { double(File) }
43
43
 
44
44
  subject { described_class.new(client: client, local_path: local_path) }
@@ -47,303 +47,303 @@ module Artifactory
47
47
  allow(File).to receive(:new).with(/\A(\w:)?#{local_path}\z/).and_return(file)
48
48
  end
49
49
 
50
- context 'when the artifact is a file path' do
51
- it 'PUTs the file at the path to the server' do
52
- expect(client).to receive(:put).with('libs-release-local/remote/path', file, {})
53
- subject.upload('libs-release-local', '/remote/path')
50
+ context "when the artifact is a file path" do
51
+ it "PUTs the file at the path to the server" do
52
+ expect(client).to receive(:put).with("libs-release-local/remote/path", file, {})
53
+ subject.upload("libs-release-local", "/remote/path")
54
54
  end
55
55
  end
56
56
 
57
- context 'when the md5 is available' do
58
- subject { described_class.new(client: client, local_path: local_path, checksums: { 'md5' => 'ABCDEF123456' } ) }
57
+ context "when the md5 is available" do
58
+ subject { described_class.new(client: client, local_path: local_path, checksums: { "md5" => "ABCDEF123456" } ) }
59
59
 
60
- it 'PUTs the file with the checksum headers set' do
61
- expect(client).to receive(:put).with('libs-release-local/remote/path', file, { 'X-Checksum-Md5' => 'ABCDEF123456' } )
62
- subject.upload('libs-release-local', '/remote/path')
60
+ it "PUTs the file with the checksum headers set" do
61
+ expect(client).to receive(:put).with("libs-release-local/remote/path", file, { "X-Checksum-Md5" => "ABCDEF123456" } )
62
+ subject.upload("libs-release-local", "/remote/path")
63
63
  end
64
64
  end
65
65
 
66
- context 'when the sha1 is available' do
67
- subject { described_class.new(client: client, local_path: local_path, checksums: { 'sha1' => 'SHA1' } ) }
66
+ context "when the sha1 is available" do
67
+ subject { described_class.new(client: client, local_path: local_path, checksums: { "sha1" => "SHA1" } ) }
68
68
 
69
- it 'PUTs the file with the checksum headers set' do
70
- expect(client).to receive(:put).with('libs-release-local/remote/path', file, { 'X-Checksum-Sha1' => 'SHA1' } )
71
- subject.upload('libs-release-local', '/remote/path')
69
+ it "PUTs the file with the checksum headers set" do
70
+ expect(client).to receive(:put).with("libs-release-local/remote/path", file, { "X-Checksum-Sha1" => "SHA1" } )
71
+ subject.upload("libs-release-local", "/remote/path")
72
72
  end
73
73
  end
74
74
 
75
- context 'when matrix properties are given' do
76
- it 'converts the hash into matrix properties' do
77
- expect(client).to receive(:put).with('libs-release-local;branch=master;user=Seth/remote/path', file, {})
75
+ context "when matrix properties are given" do
76
+ it "converts the hash into matrix properties" do
77
+ expect(client).to receive(:put).with("libs-release-local;branch=master;user=Seth/remote/path", file, {})
78
78
 
79
- subject.upload('libs-release-local', '/remote/path',
80
- branch: 'master',
81
- user: 'Seth',
79
+ subject.upload("libs-release-local", "/remote/path",
80
+ branch: "master",
81
+ user: "Seth"
82
82
  )
83
83
  end
84
84
 
85
85
  it 'converts spaces to "+" characters' do
86
- expect(client).to receive(:put).with('libs-release-local;user=Seth+Vargo/remote/path', file, {})
86
+ expect(client).to receive(:put).with("libs-release-local;user=Seth+Vargo/remote/path", file, {})
87
87
 
88
- subject.upload('libs-release-local', '/remote/path',
89
- user: 'Seth Vargo',
88
+ subject.upload("libs-release-local", "/remote/path",
89
+ user: "Seth Vargo"
90
90
  )
91
91
  end
92
92
 
93
93
  it 'converts "+" to "%2B"' do
94
- expect(client).to receive(:put).with('libs-release-local;version=12.0.0-alpha.1%2B20140826080510.git.50.f5ff271/remote/path', file, {})
94
+ expect(client).to receive(:put).with("libs-release-local;version=12.0.0-alpha.1%2B20140826080510.git.50.f5ff271/remote/path", file, {})
95
95
 
96
- subject.upload('libs-release-local', '/remote/path',
97
- version: '12.0.0-alpha.1+20140826080510.git.50.f5ff271',
96
+ subject.upload("libs-release-local", "/remote/path",
97
+ version: "12.0.0-alpha.1+20140826080510.git.50.f5ff271"
98
98
  )
99
99
  end
100
100
  end
101
101
 
102
- context 'when custom headers are given' do
103
- it 'passes the headers to the client' do
104
- headers = { 'Content-Type' => 'text/plain' }
105
- expect(client).to receive(:put).with('libs-release-local/remote/path', file, headers)
102
+ context "when custom headers are given" do
103
+ it "passes the headers to the client" do
104
+ headers = { "Content-Type" => "text/plain" }
105
+ expect(client).to receive(:put).with("libs-release-local/remote/path", file, headers)
106
106
 
107
- subject.upload('libs-release-local', '/remote/path', {}, headers)
107
+ subject.upload("libs-release-local", "/remote/path", {}, headers)
108
108
  end
109
109
  end
110
110
  end
111
111
 
112
- describe '#upload_checksum' do
113
- it 'uploads checksum.sha1' do
114
- value = 'ABCD1234'
112
+ describe "#upload_checksum" do
113
+ it "uploads checksum.sha1" do
114
+ value = "ABCD1234"
115
115
 
116
- tempfile = double('Tempfile').as_null_object
117
- expect(Tempfile).to receive(:new).with('checksum.sha1') { tempfile }
116
+ tempfile = double("Tempfile").as_null_object
117
+ expect(Tempfile).to receive(:new).with("checksum.sha1") { tempfile }
118
118
  expect(tempfile).to receive(:write).with(value).once
119
119
  expect(client).to receive(:put).with(
120
120
  "libs-release-local/remote/path.sha1",
121
121
  tempfile
122
122
  )
123
- subject.upload_checksum('libs-release-local', '/remote/path', 'sha1', value)
123
+ subject.upload_checksum("libs-release-local", "/remote/path", "sha1", value)
124
124
  end
125
125
  end
126
126
 
127
- describe '#upload_with_checksum' do
128
- it 'delegates to #upload' do
127
+ describe "#upload_with_checksum" do
128
+ it "delegates to #upload" do
129
129
  expect(subject).to receive(:upload).with(
130
- 'libs-release-local',
131
- '/remote/path',
132
- { branch: 'master' },
130
+ "libs-release-local",
131
+ "/remote/path",
132
+ { branch: "master" },
133
133
  {
134
- 'X-Checksum-Deploy' => true,
135
- 'X-Checksum-Sha1' => 'ABCD1234',
136
- },
134
+ "X-Checksum-Deploy" => true,
135
+ "X-Checksum-Sha1" => "ABCD1234",
136
+ }
137
137
  )
138
- subject.upload_with_checksum('libs-release-local', '/remote/path', 'ABCD1234',
139
- { branch: 'master' },
138
+ subject.upload_with_checksum("libs-release-local", "/remote/path", "ABCD1234",
139
+ { branch: "master" }
140
140
  )
141
141
  end
142
142
  end
143
143
 
144
- describe '#upload_from_archive' do
145
- it 'delegates to #upload' do
144
+ describe "#upload_from_archive" do
145
+ it "delegates to #upload" do
146
146
  expect(subject).to receive(:upload).with(
147
- 'libs-release-local',
148
- '/remote/path',
147
+ "libs-release-local",
148
+ "/remote/path",
149
149
  {},
150
- { 'X-Explode-Archive' => true },
150
+ { "X-Explode-Archive" => true }
151
151
  )
152
- subject.upload_from_archive('libs-release-local', '/remote/path')
152
+ subject.upload_from_archive("libs-release-local", "/remote/path")
153
153
  end
154
154
 
155
- it 'receives empty response' do
155
+ it "receives empty response" do
156
156
  file = double(File)
157
157
  allow(File).to receive(:new).and_return( file )
158
158
  expect(client).to receive(:put).with(
159
159
  "libs-release-local/remote/path",
160
160
  file,
161
- { 'X-Explode-Archive' => true },
161
+ { "X-Explode-Archive" => true }
162
162
  )
163
- subject.local_path = '/local/path'
164
- subject.upload_from_archive('libs-release-local', '/remote/path')
163
+ subject.local_path = "/local/path"
164
+ subject.upload_from_archive("libs-release-local", "/remote/path")
165
165
  end
166
166
 
167
167
  end
168
168
 
169
- describe '.gavc_search' do
170
- let(:response) { { 'results' => [] } }
169
+ describe ".gavc_search" do
170
+ let(:response) { { "results" => [] } }
171
171
 
172
- it 'calls /api/search/gavc' do
173
- expect(client).to receive(:get).with('/api/search/gavc', {}).once
172
+ it "calls /api/search/gavc" do
173
+ expect(client).to receive(:get).with("/api/search/gavc", {}).once
174
174
  described_class.gavc_search
175
175
  end
176
176
 
177
- it 'renames the parameters' do
178
- expect(client).to receive(:get).with('/api/search/gavc',
179
- g: 'group',
180
- a: 'name',
181
- v: 'version',
182
- c: 'classifier',
177
+ it "renames the parameters" do
178
+ expect(client).to receive(:get).with("/api/search/gavc",
179
+ g: "group",
180
+ a: "name",
181
+ v: "version",
182
+ c: "classifier"
183
183
  ).once
184
184
  described_class.gavc_search(
185
- group: 'group',
186
- name: 'name',
187
- version: 'version',
188
- classifier: 'classifier',
185
+ group: "group",
186
+ name: "name",
187
+ version: "version",
188
+ classifier: "classifier"
189
189
  )
190
190
  end
191
191
 
192
- it 'slices the correct parameters' do
193
- expect(client).to receive(:get).with('/api/search/gavc',
194
- g: 'group',
195
- a: 'name',
192
+ it "slices the correct parameters" do
193
+ expect(client).to receive(:get).with("/api/search/gavc",
194
+ g: "group",
195
+ a: "name"
196
196
  ).once
197
197
  described_class.gavc_search(
198
- group:'group',
199
- name: 'name',
200
- fizz: 'foo',
198
+ group: "group",
199
+ name: "name",
200
+ fizz: "foo"
201
201
  )
202
202
  end
203
203
 
204
- it 'returns an array of objects' do
204
+ it "returns an array of objects" do
205
205
  expect(described_class.gavc_search).to be_a(Array)
206
206
  end
207
207
  end
208
208
 
209
- describe '.property_search' do
210
- let(:response) { { 'results' => [] } }
209
+ describe ".property_search" do
210
+ let(:response) { { "results" => [] } }
211
211
 
212
- it 'calls /api/search/prop' do
213
- expect(client).to receive(:get).with('/api/search/prop', {}).once
212
+ it "calls /api/search/prop" do
213
+ expect(client).to receive(:get).with("/api/search/prop", {}).once
214
214
  described_class.property_search
215
215
  end
216
216
 
217
- it 'passes all the parameters' do
218
- expect(client).to receive(:get).with('/api/search/prop',
219
- p1: 'v1',
220
- p2: 'v2',
217
+ it "passes all the parameters" do
218
+ expect(client).to receive(:get).with("/api/search/prop",
219
+ p1: "v1",
220
+ p2: "v2"
221
221
  ).once
222
222
  described_class.property_search(
223
- p1: 'v1',
224
- p2: 'v2',
223
+ p1: "v1",
224
+ p2: "v2"
225
225
  )
226
226
  end
227
227
 
228
- it 'returns an array of objects' do
228
+ it "returns an array of objects" do
229
229
  expect(described_class.property_search).to be_a(Array)
230
230
  end
231
231
  end
232
232
 
233
- describe '.checksum_search' do
234
- let(:response) { { 'results' => [] } }
233
+ describe ".checksum_search" do
234
+ let(:response) { { "results" => [] } }
235
235
 
236
- it 'calls /api/search/checksum' do
237
- expect(client).to receive(:get).with('/api/search/checksum', {}).once
236
+ it "calls /api/search/checksum" do
237
+ expect(client).to receive(:get).with("/api/search/checksum", {}).once
238
238
  described_class.checksum_search
239
239
  end
240
240
 
241
- it 'slices the correct parameters' do
242
- expect(client).to receive(:get).with('/api/search/checksum',
243
- md5: 'MD5123',
244
- sha1: 'SHA456',
241
+ it "slices the correct parameters" do
242
+ expect(client).to receive(:get).with("/api/search/checksum",
243
+ md5: "MD5123",
244
+ sha1: "SHA456"
245
245
  ).once
246
246
  described_class.checksum_search(
247
- md5: 'MD5123',
248
- sha1: 'SHA456',
249
- fizz: 'foo',
247
+ md5: "MD5123",
248
+ sha1: "SHA456",
249
+ fizz: "foo"
250
250
  )
251
251
  end
252
252
 
253
- it 'returns an array of objects' do
253
+ it "returns an array of objects" do
254
254
  expect(described_class.checksum_search).to be_a(Array)
255
255
  end
256
256
  end
257
257
 
258
- describe '.usage_search' do
259
- let(:response) { { 'results' => [] } }
258
+ describe ".usage_search" do
259
+ let(:response) { { "results" => [] } }
260
260
 
261
- it 'calls /api/search/usage' do
262
- expect(client).to receive(:get).with('/api/search/usage', {}).once
261
+ it "calls /api/search/usage" do
262
+ expect(client).to receive(:get).with("/api/search/usage", {}).once
263
263
  described_class.usage_search
264
264
  end
265
265
 
266
- it 'slices the correct parameters' do
267
- expect(client).to receive(:get).with('/api/search/usage',
266
+ it "slices the correct parameters" do
267
+ expect(client).to receive(:get).with("/api/search/usage",
268
268
  notUsedSince: 1414800000000,
269
- createdBefore: 1414871200000,
269
+ createdBefore: 1414871200000
270
270
  ).once
271
271
  described_class.usage_search(
272
272
  notUsedSince: 1414800000000,
273
273
  createdBefore: 1414871200000,
274
- fizz: 'foo',
274
+ fizz: "foo"
275
275
  )
276
276
  end
277
277
 
278
- it 'returns an array of objects' do
278
+ it "returns an array of objects" do
279
279
  expect(described_class.usage_search).to be_a(Array)
280
280
  end
281
281
  end
282
282
 
283
- describe '.creation_search' do
284
- let(:response) { { 'results' => [] } }
283
+ describe ".creation_search" do
284
+ let(:response) { { "results" => [] } }
285
285
 
286
- it 'calls /api/search/creation' do
287
- expect(client).to receive(:get).with('/api/search/creation', {}).once
286
+ it "calls /api/search/creation" do
287
+ expect(client).to receive(:get).with("/api/search/creation", {}).once
288
288
  described_class.creation_search
289
289
  end
290
290
 
291
- it 'slices the correct parameters' do
292
- expect(client).to receive(:get).with('/api/search/creation',
291
+ it "slices the correct parameters" do
292
+ expect(client).to receive(:get).with("/api/search/creation",
293
293
  from: 1414800000000,
294
- to: 1414871200000,
294
+ to: 1414871200000
295
295
  ).once
296
296
  described_class.creation_search(
297
297
  from: 1414800000000,
298
298
  to: 1414871200000,
299
- fizz: 'foo',
299
+ fizz: "foo"
300
300
  )
301
301
  end
302
302
 
303
- it 'returns an array of objects' do
303
+ it "returns an array of objects" do
304
304
  expect(described_class.creation_search).to be_a(Array)
305
305
  end
306
306
  end
307
307
 
308
- describe '.versions' do
309
- let(:response) { { 'results' => [] } }
308
+ describe ".versions" do
309
+ let(:response) { { "results" => [] } }
310
310
 
311
- it 'calls /api/search/versions' do
312
- expect(client).to receive(:get).with('/api/search/versions', {}).once
311
+ it "calls /api/search/versions" do
312
+ expect(client).to receive(:get).with("/api/search/versions", {}).once
313
313
  described_class.versions
314
314
  end
315
315
 
316
- it 'renames the parameters' do
317
- expect(client).to receive(:get).with('/api/search/versions',
318
- g: 'group',
319
- a: 'name',
320
- v: 'version',
316
+ it "renames the parameters" do
317
+ expect(client).to receive(:get).with("/api/search/versions",
318
+ g: "group",
319
+ a: "name",
320
+ v: "version"
321
321
  ).once
322
322
  described_class.versions(
323
- group: 'group',
324
- name: 'name',
325
- version: 'version',
323
+ group: "group",
324
+ name: "name",
325
+ version: "version"
326
326
  )
327
327
  end
328
328
 
329
- it 'slices the correct parameters' do
330
- expect(client).to receive(:get).with('/api/search/versions',
331
- g: 'group',
332
- a: 'name',
329
+ it "slices the correct parameters" do
330
+ expect(client).to receive(:get).with("/api/search/versions",
331
+ g: "group",
332
+ a: "name"
333
333
  ).once
334
334
  described_class.versions(
335
- group:'group',
336
- name: 'name',
337
- fizz: 'foo',
335
+ group: "group",
336
+ name: "name",
337
+ fizz: "foo"
338
338
  )
339
339
  end
340
340
 
341
- it 'returns an array of objects' do
341
+ it "returns an array of objects" do
342
342
  expect(described_class.versions).to be_a(Array)
343
343
  end
344
344
 
345
- it 'returns an empty array when the server responses with a 404' do
346
- allow(client).to receive(:get).and_raise(Error::HTTPError.new('status' => 404))
345
+ it "returns an empty array when the server responses with a 404" do
346
+ allow(client).to receive(:get).and_raise(Error::HTTPError.new("status" => 404))
347
347
 
348
348
  result = described_class.versions
349
349
  expect(result).to be_a(Array)
@@ -351,228 +351,228 @@ module Artifactory
351
351
  end
352
352
  end
353
353
 
354
- describe '.latest_version' do
355
- let(:response) { '1.2-SNAPSHOT' }
354
+ describe ".latest_version" do
355
+ let(:response) { "1.2-SNAPSHOT" }
356
356
 
357
- it 'calls /api/search/latestVersion' do
358
- expect(client).to receive(:get).with('/api/search/latestVersion', {}).once
357
+ it "calls /api/search/latestVersion" do
358
+ expect(client).to receive(:get).with("/api/search/latestVersion", {}).once
359
359
  described_class.latest_version
360
360
  end
361
361
 
362
- it 'renames the parameters' do
363
- expect(client).to receive(:get).with('/api/search/latestVersion',
364
- g: 'group',
365
- a: 'name',
366
- v: 'version',
362
+ it "renames the parameters" do
363
+ expect(client).to receive(:get).with("/api/search/latestVersion",
364
+ g: "group",
365
+ a: "name",
366
+ v: "version"
367
367
  ).once
368
368
  described_class.latest_version(
369
- group: 'group',
370
- name: 'name',
371
- version: 'version',
369
+ group: "group",
370
+ name: "name",
371
+ version: "version"
372
372
  )
373
373
  end
374
374
 
375
- it 'slices the correct parameters' do
376
- expect(client).to receive(:get).with('/api/search/latestVersion',
377
- g: 'group',
378
- a: 'name',
375
+ it "slices the correct parameters" do
376
+ expect(client).to receive(:get).with("/api/search/latestVersion",
377
+ g: "group",
378
+ a: "name"
379
379
  ).once
380
380
  described_class.latest_version(
381
- group:'group',
382
- name: 'name',
383
- fizz: 'foo',
381
+ group: "group",
382
+ name: "name",
383
+ fizz: "foo"
384
384
  )
385
385
  end
386
386
 
387
- it 'returns the latest version' do
388
- expect(described_class.latest_version).to eq('1.2-SNAPSHOT')
387
+ it "returns the latest version" do
388
+ expect(described_class.latest_version).to eq("1.2-SNAPSHOT")
389
389
  end
390
390
 
391
- it 'returns an nil when the server responses with a 404' do
392
- allow(client).to receive(:get).and_raise(Error::HTTPError.new('status' => 404))
391
+ it "returns an nil when the server responses with a 404" do
392
+ allow(client).to receive(:get).and_raise(Error::HTTPError.new("status" => 404))
393
393
 
394
394
  expect(described_class.latest_version).to be_nil
395
395
  end
396
396
  end
397
397
 
398
- describe '.from_url' do
398
+ describe ".from_url" do
399
399
  let(:response) { {} }
400
400
 
401
- it 'constructs a new instance from the result' do
401
+ it "constructs a new instance from the result" do
402
402
  expect(client).to receive(:endpoint).and_return(endpoint)
403
403
  expect(described_class).to receive(:from_hash).once
404
- described_class.from_url('/some/artifact/path.deb')
404
+ described_class.from_url("/some/artifact/path.deb")
405
405
  end
406
406
  end
407
407
 
408
- describe '.from_hash' do
408
+ describe ".from_hash" do
409
409
  let(:hash) do
410
410
  {
411
- 'uri' => 'http://localhost:8080/artifactory/api/storage/libs-release-local/org/acme/lib/ver/lib-ver.pom',
412
- 'downloadUri' => 'http://localhost:8080/artifactory/libs-release-local/org/acme/lib/ver/lib-ver.pom',
413
- 'repo' => 'libs-release-local',
414
- 'path' => '/org/acme/lib/ver/lib-ver.pom',
415
- 'remoteUrl' => 'http://some-remote-repo/mvn/org/acme/lib/ver/lib-ver.pom',
416
- 'created' => '2014-01-01 10:00 UTC',
417
- 'createdBy' => 'userY',
418
- 'lastModified' => '2014-01-01 11:00 UTC',
419
- 'modifiedBy' => 'userX',
420
- 'lastUpdated' => '2014-01-01 12:00 UTC',
421
- 'size' => '1024',
422
- 'mimeType' => 'application/pom+xml',
423
- 'checksums' => { 'md5' => 'MD5123', 'sha1' => 'SHA456' },
424
- 'originalChecksums'=> { 'md5' => 'MD5123', 'sha1' => 'SHA456' },
411
+ "uri" => "http://localhost:8080/artifactory/api/storage/libs-release-local/org/acme/lib/ver/lib-ver.pom",
412
+ "downloadUri" => "http://localhost:8080/artifactory/libs-release-local/org/acme/lib/ver/lib-ver.pom",
413
+ "repo" => "libs-release-local",
414
+ "path" => "/org/acme/lib/ver/lib-ver.pom",
415
+ "remoteUrl" => "http://some-remote-repo/mvn/org/acme/lib/ver/lib-ver.pom",
416
+ "created" => "2014-01-01 10:00 UTC",
417
+ "createdBy" => "userY",
418
+ "lastModified" => "2014-01-01 11:00 UTC",
419
+ "modifiedBy" => "userX",
420
+ "lastUpdated" => "2014-01-01 12:00 UTC",
421
+ "size" => "1024",
422
+ "mimeType" => "application/pom+xml",
423
+ "checksums" => { "md5" => "MD5123", "sha1" => "SHA456" },
424
+ "originalChecksums" => { "md5" => "MD5123", "sha1" => "SHA456" },
425
425
  }
426
426
  end
427
427
 
428
- it 'creates a new instance' do
428
+ it "creates a new instance" do
429
429
  instance = described_class.from_hash(hash)
430
430
  expect(instance).to be_a(described_class)
431
- expect(instance.uri).to eq('http://localhost:8080/artifactory/api/storage/libs-release-local/org/acme/lib/ver/lib-ver.pom')
431
+ expect(instance.uri).to eq("http://localhost:8080/artifactory/api/storage/libs-release-local/org/acme/lib/ver/lib-ver.pom")
432
432
  expect(instance.client).to be(client)
433
- expect(instance.created).to eq(Time.parse('2014-01-01 10:00 UTC'))
434
- expect(instance.download_uri).to eq('http://localhost:8080/artifactory/libs-release-local/org/acme/lib/ver/lib-ver.pom')
435
- expect(instance.last_modified).to eq(Time.parse('2014-01-01 11:00 UTC'))
436
- expect(instance.last_updated).to eq(Time.parse('2014-01-01 12:00 UTC'))
437
- expect(instance.md5).to eq('MD5123')
438
- expect(instance.mime_type).to eq('application/pom+xml')
439
- expect(instance.sha1).to eq('SHA456')
433
+ expect(instance.created).to eq(Time.parse("2014-01-01 10:00 UTC"))
434
+ expect(instance.download_uri).to eq("http://localhost:8080/artifactory/libs-release-local/org/acme/lib/ver/lib-ver.pom")
435
+ expect(instance.last_modified).to eq(Time.parse("2014-01-01 11:00 UTC"))
436
+ expect(instance.last_updated).to eq(Time.parse("2014-01-01 12:00 UTC"))
437
+ expect(instance.md5).to eq("MD5123")
438
+ expect(instance.mime_type).to eq("application/pom+xml")
439
+ expect(instance.sha1).to eq("SHA456")
440
440
  expect(instance.size).to eq(1024)
441
441
  end
442
442
  end
443
443
 
444
- describe '#copy' do
445
- let(:destination) { '/to/here' }
444
+ describe "#copy" do
445
+ let(:destination) { "/to/here" }
446
446
  let(:options) { Hash.new }
447
447
  before { allow(subject).to receive(:copy_or_move) }
448
448
 
449
- it 'delegates to #copy_or_move' do
449
+ it "delegates to #copy_or_move" do
450
450
  expect(subject).to receive(:copy_or_move).with(:copy, destination, options)
451
451
  subject.copy(destination, options)
452
452
  end
453
453
  end
454
454
 
455
- describe '#delete' do
455
+ describe "#delete" do
456
456
  let(:client) { double }
457
457
 
458
- it 'sends DELETE to the client' do
458
+ it "sends DELETE to the client" do
459
459
  subject.client = client
460
- subject.download_uri = '/artifact.deb'
460
+ subject.download_uri = "/artifact.deb"
461
461
 
462
462
  expect(client).to receive(:delete)
463
463
  subject.delete
464
464
  end
465
465
  end
466
466
 
467
- describe '#move' do
468
- let(:destination) { '/to/here' }
467
+ describe "#move" do
468
+ let(:destination) { "/to/here" }
469
469
  let(:options) { Hash.new }
470
470
  before { allow(subject).to receive(:copy_or_move) }
471
471
 
472
- it 'delegates to #copy_or_move' do
472
+ it "delegates to #copy_or_move" do
473
473
  expect(subject).to receive(:copy_or_move).with(:move, destination, options)
474
474
  subject.move(destination, options)
475
475
  end
476
476
  end
477
477
 
478
- describe '#properties' do
478
+ describe "#properties" do
479
479
  let(:properties) do
480
- { 'artifactory.licenses' => ['Apache-2.0'] }
480
+ { "artifactory.licenses" => ["Apache-2.0"] }
481
481
  end
482
482
  let(:response) do
483
- { 'properties' => properties }
483
+ { "properties" => properties }
484
484
  end
485
485
  let(:client) { double(get: response) }
486
- let(:relative_path) { '/api/storage/some-repo/path/artifact.deb' }
487
- let(:artifact_uri) { File.join('http://33.33.33.11', relative_path) }
486
+ let(:relative_path) { "/api/storage/some-repo/path/artifact.deb" }
487
+ let(:artifact_uri) { File.join("http://33.33.33.11", relative_path) }
488
488
 
489
489
  before do
490
490
  subject.client = client
491
491
  subject.uri = artifact_uri
492
492
  end
493
493
 
494
- it 'gets the properties from the server' do
494
+ it "gets the properties from the server" do
495
495
  expect(client).to receive(:get).with(relative_path, properties: nil).once
496
496
  expect(subject.properties).to eq(properties)
497
497
  end
498
498
 
499
- it 'caches the response' do
499
+ it "caches the response" do
500
500
  subject.properties
501
501
  expect(subject.instance_variable_get(:@properties)).to eq(properties)
502
502
  end
503
503
  end
504
504
 
505
- describe '#compliance' do
505
+ describe "#compliance" do
506
506
  let(:compliance) do
507
- { 'licenses' => [{ 'name' => 'LGPL v3' }] }
507
+ { "licenses" => [{ "name" => "LGPL v3" }] }
508
508
  end
509
509
  let(:client) { double(get: compliance) }
510
- let(:uri) { '/artifact.deb' }
510
+ let(:uri) { "/artifact.deb" }
511
511
 
512
512
  before do
513
- subject.client = client
513
+ subject.client = client
514
514
  subject.uri = uri
515
515
  end
516
516
 
517
- it 'gets the compliance from the server' do
518
- expect(client).to receive(:get).with('/api/compliance/artifact.deb').once
517
+ it "gets the compliance from the server" do
518
+ expect(client).to receive(:get).with("/api/compliance/artifact.deb").once
519
519
  expect(subject.compliance).to eq(compliance)
520
520
  end
521
521
 
522
- it 'caches the response' do
522
+ it "caches the response" do
523
523
  subject.compliance
524
524
  expect(subject.instance_variable_get(:@compliance)).to eq(compliance)
525
525
  end
526
526
  end
527
527
 
528
- describe '#download' do
529
- it 'download content to directory' do
530
- Dir.mktmpdir('artifact_download') do |tmpdir|
531
- subject.download_uri = '/artifact.deb'
528
+ describe "#download" do
529
+ it "download content to directory" do
530
+ Dir.mktmpdir("artifact_download") do |tmpdir|
531
+ subject.download_uri = "/artifact.deb"
532
532
 
533
- expect(client).to receive(:get) { 'some content' }
533
+ expect(client).to receive(:get) { "some content" }
534
534
  subject.download(tmpdir)
535
- expect(Dir.entries(tmpdir)).to include('artifact.deb')
535
+ expect(Dir.entries(tmpdir)).to include("artifact.deb")
536
536
  end
537
537
  end
538
538
 
539
- it 'download content to directory with filename' do
540
- Dir.mktmpdir('artifact_download') do |tmpdir|
541
- subject.download_uri = '/artifact.deb'
539
+ it "download content to directory with filename" do
540
+ Dir.mktmpdir("artifact_download") do |tmpdir|
541
+ subject.download_uri = "/artifact.deb"
542
542
 
543
- expect(client).to receive(:get) { 'some content' }
544
- subject.download(tmpdir, {filename: 'foobar.deb'})
545
- expect(Dir.entries(tmpdir)).to include('foobar.deb')
543
+ expect(client).to receive(:get) { "some content" }
544
+ subject.download(tmpdir, { filename: "foobar.deb" })
545
+ expect(Dir.entries(tmpdir)).to include("foobar.deb")
546
546
  end
547
547
  end
548
548
  end
549
549
 
550
- describe '#relative_path' do
550
+ describe "#relative_path" do
551
551
  before { described_class.send(:public, :relative_path) }
552
552
 
553
- it 'parses the relative path' do
554
- subject.uri = '/api/storage/foo/bar/zip'
555
- expect(subject.relative_path).to eq('/foo/bar/zip')
553
+ it "parses the relative path" do
554
+ subject.uri = "/api/storage/foo/bar/zip"
555
+ expect(subject.relative_path).to eq("/foo/bar/zip")
556
556
  end
557
557
  end
558
558
 
559
- describe '#copy_or_move' do
559
+ describe "#copy_or_move" do
560
560
  let(:client) { double }
561
561
  before do
562
562
  described_class.send(:public, :copy_or_move)
563
563
 
564
- subject.client = client
565
- subject.uri = '/api/storage/foo/bar/artifact.deb'
564
+ subject.client = client
565
+ subject.uri = "/api/storage/foo/bar/artifact.deb"
566
566
  end
567
567
 
568
- it 'sends POST to the client with parsed params' do
569
- expect(client).to receive(:post).with('/api/move/foo/bar/artifact.deb?to=/to/path', {})
570
- subject.copy_or_move(:move, '/to/path')
568
+ it "sends POST to the client with parsed params" do
569
+ expect(client).to receive(:post).with("/api/move/foo/bar/artifact.deb?to=/to/path", {})
570
+ subject.copy_or_move(:move, "/to/path")
571
571
  end
572
572
 
573
- it 'adds the correct parameters to the request' do
574
- expect(client).to receive(:post).with('/api/move/foo/bar/artifact.deb?to=/to/path&failFast=1&dry=1', {})
575
- subject.copy_or_move(:move, '/to/path', fail_fast: true, dry_run: true)
573
+ it "adds the correct parameters to the request" do
574
+ expect(client).to receive(:post).with("/api/move/foo/bar/artifact.deb?to=/to/path&failFast=1&dry=1", {})
575
+ subject.copy_or_move(:move, "/to/path", fail_fast: true, dry_run: true)
576
576
  end
577
577
  end
578
578
  end