jenkins_api_client 1.4.5 → 1.5.2
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.
- checksums.yaml +4 -4
- data/jenkins_api_client.gemspec +15 -136
- data/lib/jenkins_api_client/version.rb +2 -2
- metadata +6 -180
- data/.gitignore +0 -41
- data/.jenkins.yml +0 -9
- data/.travis.yml +0 -15
- data/CHANGELOG.md +0 -391
- data/CONTRIBUTORS.md +0 -3
- data/Gemfile +0 -20
- data/LICENCE +0 -21
- data/README.md +0 -454
- data/Rakefile +0 -107
- data/Vagrantfile +0 -83
- data/config/login.yml.example +0 -27
- data/jenkins_api_client_class_diagram.png +0 -0
- data/scripts/login_with_irb.rb +0 -54
- data/scripts/login_with_pry.rb +0 -54
- data/spec/func_tests/client_spec.rb +0 -109
- data/spec/func_tests/job_spec.rb +0 -669
- data/spec/func_tests/node_spec.rb.pending +0 -217
- data/spec/func_tests/plugin_spec.rb +0 -148
- data/spec/func_tests/spec_helper.rb +0 -41
- data/spec/func_tests/system_spec.rb +0 -84
- data/spec/func_tests/user_spec.rb +0 -49
- data/spec/func_tests/view_spec.rb +0 -276
- data/spec/unit_tests/build_queue_spec.rb +0 -152
- data/spec/unit_tests/client_spec.rb +0 -471
- data/spec/unit_tests/fake_http_response.rb +0 -9
- data/spec/unit_tests/fixtures/files/available_plugins.json +0 -1
- data/spec/unit_tests/fixtures/files/computer_sample.xml +0 -17
- data/spec/unit_tests/fixtures/files/installed_plugins.json +0 -1
- data/spec/unit_tests/fixtures/files/job_sample.xml +0 -16
- data/spec/unit_tests/fixtures/files/updatable_plugins.json +0 -1
- data/spec/unit_tests/job_spec.rb +0 -783
- data/spec/unit_tests/node_spec.rb +0 -342
- data/spec/unit_tests/plugin_settings/colllection_spec.rb +0 -62
- data/spec/unit_tests/plugin_settings/hipchat_spec.rb +0 -44
- data/spec/unit_tests/plugin_settings/workspace_cleanup_spec.rb +0 -31
- data/spec/unit_tests/plugin_spec.rb +0 -165
- data/spec/unit_tests/spec_helper.rb +0 -19
- data/spec/unit_tests/system_spec.rb +0 -76
- data/spec/unit_tests/user_spec.rb +0 -144
- data/spec/unit_tests/view_spec.rb +0 -149
- data/travis/hudson.model.UpdateCenter.xml +0 -7
- data/travis/jenkins_config.xml +0 -63
- data/travis/jenkins_config_with_crumb.xml +0 -67
- data/travis/setup.sh +0 -23
- data/travis/setup_crumb.sh +0 -11
- data/travis/spec.yml +0 -14
- data/travis/user_config.xml +0 -29
@@ -1,471 +0,0 @@
|
|
1
|
-
require File.expand_path('../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe JenkinsApi::Client do
|
4
|
-
context "With valid credentials given" do
|
5
|
-
before do
|
6
|
-
@client = JenkinsApi::Client.new(
|
7
|
-
:server_ip => '127.0.0.1',
|
8
|
-
:server_port => 8080,
|
9
|
-
:username => 'username',
|
10
|
-
:password => 'password',
|
11
|
-
:log_location => '/dev/null'
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#initialize" do
|
16
|
-
it "initializes without exception" do
|
17
|
-
expect(
|
18
|
-
lambda do
|
19
|
-
JenkinsApi::Client.new(
|
20
|
-
:server_ip => '127.0.0.1',
|
21
|
-
:server_port => 8080,
|
22
|
-
:username => 'username',
|
23
|
-
:password => 'password'
|
24
|
-
)
|
25
|
-
end
|
26
|
-
).not_to raise_error
|
27
|
-
end
|
28
|
-
|
29
|
-
it "initialize without exception if username/password not specified" do
|
30
|
-
expect(
|
31
|
-
lambda do
|
32
|
-
JenkinsApi::Client.new({
|
33
|
-
:server_ip => '127.0.0.1',
|
34
|
-
:server_port => 8080
|
35
|
-
})
|
36
|
-
end
|
37
|
-
).not_to raise_error
|
38
|
-
end
|
39
|
-
|
40
|
-
it "initializes with server_url without exception" do
|
41
|
-
expect(
|
42
|
-
lambda do
|
43
|
-
JenkinsApi::Client.new(
|
44
|
-
:server_url => 'http://localhost',
|
45
|
-
:username => 'username',
|
46
|
-
:password => 'password'
|
47
|
-
)
|
48
|
-
end
|
49
|
-
).not_to raise_error
|
50
|
-
end
|
51
|
-
|
52
|
-
it "initializes the username and password from server_url" do
|
53
|
-
client = JenkinsApi::Client.new(
|
54
|
-
:server_url => 'http://someuser:asdf@localhost'
|
55
|
-
)
|
56
|
-
|
57
|
-
client.instance_variable_get('@username').should == 'someuser'
|
58
|
-
client.instance_variable_get('@password').should == 'asdf'
|
59
|
-
end
|
60
|
-
|
61
|
-
it "uses explicit username, password over one in the server_url" do
|
62
|
-
client = JenkinsApi::Client.new(
|
63
|
-
:server_url => 'http://someuser:asdf@localhost',
|
64
|
-
:username => 'otheruser',
|
65
|
-
:password => '1234'
|
66
|
-
)
|
67
|
-
|
68
|
-
client.instance_variable_get('@username').should == 'otheruser'
|
69
|
-
client.instance_variable_get('@password').should == '1234'
|
70
|
-
end
|
71
|
-
|
72
|
-
it "initializes with proxy args without exception" do
|
73
|
-
expect(
|
74
|
-
lambda do
|
75
|
-
JenkinsApi::Client.new(
|
76
|
-
:server_ip => '127.0.0.1',
|
77
|
-
:server_port => 8080,
|
78
|
-
:username => 'username',
|
79
|
-
:password => 'password',
|
80
|
-
:proxy_ip => '127.0.0.1',
|
81
|
-
:proxy_port => 8081
|
82
|
-
)
|
83
|
-
end
|
84
|
-
).not_to raise_error
|
85
|
-
end
|
86
|
-
|
87
|
-
it "errors on bad proxy args" do
|
88
|
-
expect(
|
89
|
-
lambda do
|
90
|
-
JenkinsApi::Client.new(
|
91
|
-
:server_ip => '127.0.0.1',
|
92
|
-
:server_port => 8080,
|
93
|
-
:username => 'username',
|
94
|
-
:password => 'password',
|
95
|
-
:proxy_ip => '127.0.0.1'
|
96
|
-
)
|
97
|
-
end
|
98
|
-
).to raise_error
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "#SubClassAccessorMethods" do
|
103
|
-
describe "#job" do
|
104
|
-
it "Should return a Client::Job object" do
|
105
|
-
client = JenkinsApi::Client.new(
|
106
|
-
:server_ip => '127.0.0.1',
|
107
|
-
:server_port => 8080,
|
108
|
-
:username => 'username',
|
109
|
-
:password => 'password'
|
110
|
-
)
|
111
|
-
client.job.class.should == JenkinsApi::Client::Job
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe "#node" do
|
116
|
-
it "Should return a Client::Node object" do
|
117
|
-
client = JenkinsApi::Client.new(
|
118
|
-
:server_ip => '127.0.0.1',
|
119
|
-
:server_port => 8080,
|
120
|
-
:username => 'username',
|
121
|
-
:password => 'password'
|
122
|
-
)
|
123
|
-
client.node.class.should == JenkinsApi::Client::Node
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe "#view" do
|
128
|
-
it "Should return a Client::View object" do
|
129
|
-
client = JenkinsApi::Client.new(
|
130
|
-
:server_ip => '127.0.0.1',
|
131
|
-
:server_port => 8080,
|
132
|
-
:username => 'username',
|
133
|
-
:password => 'password'
|
134
|
-
)
|
135
|
-
client.view.class.should == JenkinsApi::Client::View
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
describe "#system" do
|
140
|
-
it "Should return a Client::System object" do
|
141
|
-
client = JenkinsApi::Client.new(
|
142
|
-
:server_ip => '127.0.0.1',
|
143
|
-
:server_port => 8080,
|
144
|
-
:username => 'username',
|
145
|
-
:password => 'password'
|
146
|
-
)
|
147
|
-
client.system.class.should == JenkinsApi::Client::System
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
describe "#queue" do
|
152
|
-
it "Should return a Client::BuildQueue object" do
|
153
|
-
client = JenkinsApi::Client.new(
|
154
|
-
:server_ip => '127.0.0.1',
|
155
|
-
:server_port => 8080,
|
156
|
-
:username => 'username',
|
157
|
-
:password => 'password'
|
158
|
-
)
|
159
|
-
client.queue.class.should == JenkinsApi::Client::BuildQueue
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
describe "InstanceMethods" do
|
165
|
-
describe "#get_root" do
|
166
|
-
it "is defined with no parameters" do
|
167
|
-
@client.respond_to?(:get_root).should be_true
|
168
|
-
@client.method(:get_root).parameters.size.should == 0
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
describe "#api_get_request" do
|
173
|
-
it "defined and should accept url_prefix, tree, and url_suffix" do
|
174
|
-
@client.respond_to?(:api_get_request).should be_true
|
175
|
-
@client.method(:api_get_request).parameters.size.should == 4
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
describe "#api_post_request" do
|
180
|
-
it "is defined and should accept url_prefix" do
|
181
|
-
@client.respond_to?(:api_post_request).should be_true
|
182
|
-
@client.method(:api_post_request).parameters.size.should == 3
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
describe "#get_config" do
|
187
|
-
it "is defined and should accept url_prefix" do
|
188
|
-
@client.respond_to?(:get_config).should be_true
|
189
|
-
@client.method(:get_config).parameters.size.should == 1
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
describe "#post_config" do
|
194
|
-
it "is defined and should accept url_prefix and xml" do
|
195
|
-
@client.respond_to?(:post_config).should be_true
|
196
|
-
@client.method(:post_config).parameters.size.should == 2
|
197
|
-
end
|
198
|
-
|
199
|
-
it "sets the content type with charset as UTF-8 for the multi-byte content" do
|
200
|
-
url_prefix = '/prefix'
|
201
|
-
xml = '<dummy>dummy</dummy>'
|
202
|
-
content_type = 'application/xml;charset=UTF-8'
|
203
|
-
|
204
|
-
expect(@client).to receive(:post_data).with(url_prefix, xml, content_type)
|
205
|
-
@client.post_config(url_prefix, xml)
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
describe "#post_json" do
|
210
|
-
it "is defined and should accept url_prefix and json" do
|
211
|
-
@client.respond_to?(:post_json).should be_true
|
212
|
-
@client.method(:post_json).parameters.size.should == 2
|
213
|
-
end
|
214
|
-
|
215
|
-
it "sets the content type with charset as UTF-8 for the multi-byte content" do
|
216
|
-
url_prefix = '/prefix'
|
217
|
-
json = '{ "dummy": "dummy" }'
|
218
|
-
content_type = 'application/json;charset=UTF-8'
|
219
|
-
|
220
|
-
expect(@client).to receive(:post_data).with(url_prefix, json, content_type)
|
221
|
-
@client.post_json(url_prefix, json)
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
describe "#get_jenkins_version" do
|
226
|
-
it "is defined and accepts no parameters" do
|
227
|
-
@client.respond_to?(:get_jenkins_version).should be_true
|
228
|
-
@client.method(:get_jenkins_version).parameters.size.should == 0
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
describe "#get_hudson_version" do
|
233
|
-
it "is defined and accepts no parameters" do
|
234
|
-
@client.respond_to?(:get_hudson_version).should be_true
|
235
|
-
@client.method(:get_hudson_version).parameters.size.should == 0
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
describe "#get_server_date" do
|
240
|
-
it "is defined and accepts no parameters" do
|
241
|
-
@client.respond_to?(:get_server_date).should be_true
|
242
|
-
@client.method(:get_server_date).parameters.size.should == 0
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
describe "#exec_script" do
|
247
|
-
it "is defined and should accept script to execute" do
|
248
|
-
@client.respond_to?(:exec_script).should be_true
|
249
|
-
@client.method(:exec_script).parameters.size.should == 1
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
describe "#exec_cli" do
|
254
|
-
it "is defined and should execute the CLI" do
|
255
|
-
@client.respond_to?(:exec_cli).should be_true
|
256
|
-
@client.method(:exec_cli).parameters.size.should == 2
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
describe "#deconstruct_version_string" do
|
261
|
-
it "is defined and accepts a single param" do
|
262
|
-
@client.respond_to?(:deconstruct_version_string).should be_true
|
263
|
-
@client.method(:deconstruct_version_string).parameters.size.should == 1
|
264
|
-
end
|
265
|
-
|
266
|
-
it "takes a version string in the form 'a.b' and returns an array [a,b,c]" do
|
267
|
-
TEST_2_PART_VERSION_STRING = "1.002"
|
268
|
-
version = @client.deconstruct_version_string(TEST_2_PART_VERSION_STRING)
|
269
|
-
version.should_not be_nil
|
270
|
-
version.should_not be_empty
|
271
|
-
version.size.should eql 3
|
272
|
-
version[0].should eql 1
|
273
|
-
version[1].should eql 2
|
274
|
-
version[2].should eql 0
|
275
|
-
end
|
276
|
-
|
277
|
-
it "takes a version string in the form 'a.b.c' and returns an array [a,b]" do
|
278
|
-
TEST_3_PART_VERSION_STRING = "1.002.3"
|
279
|
-
version = @client.deconstruct_version_string(TEST_3_PART_VERSION_STRING)
|
280
|
-
version.should_not be_nil
|
281
|
-
version.should_not be_empty
|
282
|
-
version.size.should eql 3
|
283
|
-
version[0].should eql 1
|
284
|
-
version[1].should eql 2
|
285
|
-
version[2].should eql 3
|
286
|
-
end
|
287
|
-
|
288
|
-
it "should fail if parameter is not a string" do
|
289
|
-
expect(
|
290
|
-
lambda { @client.deconstruct_version_string(1) }
|
291
|
-
).to raise_error(NoMethodError) # match for fixnum
|
292
|
-
end
|
293
|
-
|
294
|
-
it "should return nil if parameter is not a string in the form '\d+.\d+(.\d+)'" do
|
295
|
-
@client.deconstruct_version_string("A.B").should be_nil
|
296
|
-
@client.deconstruct_version_string("1").should be_nil
|
297
|
-
@client.deconstruct_version_string("1.").should be_nil
|
298
|
-
@client.deconstruct_version_string("1.2.3.4").should be_nil
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
describe "#compare_versions" do
|
303
|
-
it "is defined and accepts two params" do
|
304
|
-
@client.respond_to?(:compare_versions).should be_true
|
305
|
-
@client.method(:compare_versions).parameters.size.should == 2
|
306
|
-
end
|
307
|
-
|
308
|
-
it "should correctly compare version numbers" do
|
309
|
-
@client.compare_versions("1.0", "1.0").should eql(0)
|
310
|
-
@client.compare_versions("1.0", "1.1").should eql(-1)
|
311
|
-
@client.compare_versions("1.1", "1.0").should eql(1)
|
312
|
-
@client.compare_versions("2.0", "1.99").should eql(1)
|
313
|
-
@client.compare_versions("1.10", "1.2").should eql(1)
|
314
|
-
|
315
|
-
@client.compare_versions("1.0.0", "1.0.0").should eql(0)
|
316
|
-
@client.compare_versions("1.0", "1.0.1").should eql(-1)
|
317
|
-
@client.compare_versions("1.1", "1.0.1").should eql(1)
|
318
|
-
@client.compare_versions("2.0.0", "1.999.99").should eql(1)
|
319
|
-
@client.compare_versions("1.0.10", "1.0.2").should eql(1)
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
describe "#use_crumbs?" do
|
324
|
-
it "returns true if the server has useCrumbs on" do
|
325
|
-
expect(@client).to receive(:api_get_request).with("", "tree=useCrumbs") {
|
326
|
-
{
|
327
|
-
"useCrumbs" => true
|
328
|
-
}
|
329
|
-
}
|
330
|
-
@client.use_crumbs?.should == true
|
331
|
-
end
|
332
|
-
|
333
|
-
it "returns false if the server has useCrumbs off" do
|
334
|
-
expect(@client).to receive(:api_get_request).with("", "tree=useCrumbs") {
|
335
|
-
{
|
336
|
-
"useCrumbs" => false
|
337
|
-
}
|
338
|
-
}
|
339
|
-
@client.use_crumbs?.should == false
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
describe "#use_security?" do
|
344
|
-
it "returns true if the server has useSecurity on" do
|
345
|
-
expect(@client).to receive(:api_get_request).with("", "tree=useSecurity") {
|
346
|
-
{
|
347
|
-
"useSecurity" => true
|
348
|
-
}
|
349
|
-
}
|
350
|
-
@client.use_security?.should == true
|
351
|
-
end
|
352
|
-
|
353
|
-
it "returns false if the server has useSecurity off" do
|
354
|
-
expect(@client).to receive(:api_get_request).with("", "tree=useSecurity") {
|
355
|
-
{
|
356
|
-
"useSecurity" => false
|
357
|
-
}
|
358
|
-
}
|
359
|
-
@client.use_security?.should == false
|
360
|
-
end
|
361
|
-
end
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
|
-
context "With some required parameters missing" do
|
366
|
-
context "#initialize" do
|
367
|
-
it "Should fail if server_ip and server_url are missing" do
|
368
|
-
expect(
|
369
|
-
lambda do
|
370
|
-
JenkinsApi::Client.new({
|
371
|
-
:bogus => '127.0.0.1',
|
372
|
-
:bogus_url => 'http://localhost',
|
373
|
-
:server_port => 8080,
|
374
|
-
:username => 'username',
|
375
|
-
:password => 'password'
|
376
|
-
})
|
377
|
-
end
|
378
|
-
).to raise_error
|
379
|
-
end
|
380
|
-
|
381
|
-
it "Should fail if password is missing" do
|
382
|
-
expect(
|
383
|
-
lambda do
|
384
|
-
JenkinsApi::Client.new({
|
385
|
-
:server_ip => '127.0.0.1',
|
386
|
-
:server_port => 8080,
|
387
|
-
:username => 'username',
|
388
|
-
:bogus => 'password'
|
389
|
-
})
|
390
|
-
end
|
391
|
-
).to raise_error
|
392
|
-
end
|
393
|
-
|
394
|
-
it "Should fail if proxy_ip is specified but proxy_port is not" do
|
395
|
-
expect(
|
396
|
-
lambda do
|
397
|
-
JenkinsApi::Client.new({
|
398
|
-
:bogus => '127.0.0.1',
|
399
|
-
:server_port => 8080,
|
400
|
-
:username => 'username',
|
401
|
-
:password => 'password',
|
402
|
-
:proxy_ip => '127.0.0.1',
|
403
|
-
})
|
404
|
-
end
|
405
|
-
).to raise_error
|
406
|
-
end
|
407
|
-
|
408
|
-
it "Should fail if proxy_port is specified but proxy_ip is not" do
|
409
|
-
expect(
|
410
|
-
lambda do
|
411
|
-
JenkinsApi::Client.new({
|
412
|
-
:bogus => '127.0.0.1',
|
413
|
-
:server_port => 8080,
|
414
|
-
:username => 'username',
|
415
|
-
:password => 'password',
|
416
|
-
:proxy_port => 8081,
|
417
|
-
})
|
418
|
-
end
|
419
|
-
).to raise_error
|
420
|
-
end
|
421
|
-
end
|
422
|
-
end
|
423
|
-
|
424
|
-
context "With logging configuration" do
|
425
|
-
|
426
|
-
it "Should fail if logger is not a Logger object" do
|
427
|
-
expect(
|
428
|
-
lambda do
|
429
|
-
JenkinsApi::Client.new({
|
430
|
-
:server_ip => '127.0.0.1',
|
431
|
-
:logger => 'testing',
|
432
|
-
})
|
433
|
-
end
|
434
|
-
).to raise_error
|
435
|
-
end
|
436
|
-
|
437
|
-
it "Should set logger instance variable to Logger" do
|
438
|
-
client = JenkinsApi::Client.new(
|
439
|
-
:server_ip => '127.0.0.1',
|
440
|
-
:logger => Logger.new(STDOUT),
|
441
|
-
)
|
442
|
-
|
443
|
-
client.instance_variable_get('@logger').class.should == Logger
|
444
|
-
end
|
445
|
-
|
446
|
-
it "Should fail if logger and log_level are both set" do
|
447
|
-
expect(
|
448
|
-
lambda do
|
449
|
-
JenkinsApi::Client.new({
|
450
|
-
:server_ip => '127.0.0.1',
|
451
|
-
:logger => Logger.new(STDOUT),
|
452
|
-
:log_level => Logger::INFO,
|
453
|
-
})
|
454
|
-
end
|
455
|
-
).to raise_error
|
456
|
-
end
|
457
|
-
|
458
|
-
it "Should fail if logger and log_location are both set" do
|
459
|
-
expect(
|
460
|
-
lambda do
|
461
|
-
JenkinsApi::Client.new({
|
462
|
-
:server_ip => '127.0.0.1',
|
463
|
-
:logger => Logger.new(STDOUT),
|
464
|
-
:log_location => 'test.log',
|
465
|
-
})
|
466
|
-
end
|
467
|
-
).to raise_error
|
468
|
-
end
|
469
|
-
|
470
|
-
end
|
471
|
-
end
|