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,342 +0,0 @@
|
|
1
|
-
require File.expand_path('../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe JenkinsApi::Client::Node do
|
4
|
-
context "With properly initialized Client" do
|
5
|
-
before do
|
6
|
-
@client = double
|
7
|
-
mock_logger = Logger.new "/dev/null"
|
8
|
-
@client.should_receive(:logger).and_return(mock_logger)
|
9
|
-
@node = JenkinsApi::Client::Node.new(@client)
|
10
|
-
@sample_json_list_response = {
|
11
|
-
"computer" => [
|
12
|
-
"displayName" => "slave"
|
13
|
-
]
|
14
|
-
}
|
15
|
-
@sample_json_computer_response = {
|
16
|
-
"displayName" => "slave"
|
17
|
-
}
|
18
|
-
@offline_slave = {
|
19
|
-
"displayName" => "slave",
|
20
|
-
"offline" => true,
|
21
|
-
"temporarilyOffline" => true,
|
22
|
-
}
|
23
|
-
@online_slave = {
|
24
|
-
"displayName" => "slave",
|
25
|
-
"offline" => false,
|
26
|
-
"temporarilyOffline" => false,
|
27
|
-
}
|
28
|
-
@offline_slave_in_string = {
|
29
|
-
"displayName" => "slave",
|
30
|
-
"offline" => "true",
|
31
|
-
}
|
32
|
-
@online_slave_in_string = {
|
33
|
-
"displayName" => "slave",
|
34
|
-
"offline" => "false",
|
35
|
-
}
|
36
|
-
computer_sample_xml_filename = '../fixtures/files/computer_sample.xml'
|
37
|
-
@sample_computer_xml = File.read(
|
38
|
-
File.expand_path(computer_sample_xml_filename , __FILE__)
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "InstanceMethods" do
|
43
|
-
|
44
|
-
describe "#initialize" do
|
45
|
-
it "initializes by receiving an instance of client object" do
|
46
|
-
mock_logger = Logger.new "/dev/null"
|
47
|
-
@client.should_receive(:logger).and_return(mock_logger)
|
48
|
-
expect(
|
49
|
-
lambda{ JenkinsApi::Client::Node.new(@client) }
|
50
|
-
).not_to raise_error
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "#create_dumb_slave" do
|
55
|
-
it "creates a dumb slave by accepting required params" do
|
56
|
-
@client.should_receive(:api_post_request).and_return("302")
|
57
|
-
@node.create_dumb_slave(
|
58
|
-
:name => "test_slave",
|
59
|
-
:slave_host => "10.10.10.10",
|
60
|
-
:private_key_file => "/root/.ssh/id_rsa"
|
61
|
-
)
|
62
|
-
end
|
63
|
-
it "fails if name is not given" do
|
64
|
-
expect(
|
65
|
-
lambda{
|
66
|
-
@node.create_dumb_slave(
|
67
|
-
:slave_host => "10.10.10.10",
|
68
|
-
:private_key_file => "/root/.ssh/id_rsa"
|
69
|
-
)
|
70
|
-
}
|
71
|
-
).to raise_error
|
72
|
-
end
|
73
|
-
it "fails if slave_host is not given" do
|
74
|
-
expect(
|
75
|
-
lambda{
|
76
|
-
@node.create_dumb_slave(
|
77
|
-
:name => "test_slave",
|
78
|
-
:private_key_file => "/root/.ssh/id_rsa"
|
79
|
-
)
|
80
|
-
}
|
81
|
-
).to raise_error
|
82
|
-
end
|
83
|
-
it "fails if private_key_file is not given" do
|
84
|
-
expect(
|
85
|
-
lambda{
|
86
|
-
@node.create_dumb_slave(
|
87
|
-
:name => "test_slave",
|
88
|
-
:slave_host => "10.10.10.10"
|
89
|
-
)
|
90
|
-
}
|
91
|
-
).to raise_error
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "#create_dump_slave" do
|
96
|
-
|
97
|
-
it "just delegates to #create_dumb_slave" do
|
98
|
-
@node.should_receive(:create_dumb_slave)
|
99
|
-
@node.create_dump_slave(
|
100
|
-
:name => "test_slave",
|
101
|
-
:slave_host => "10.10.10.10",
|
102
|
-
:private_key_file => "/root/.ssh/id_rsa"
|
103
|
-
)
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
describe "#delete" do
|
108
|
-
it "gets the node name and deletes if exists" do
|
109
|
-
slave_name = "slave"
|
110
|
-
@client.should_receive(
|
111
|
-
:api_get_request
|
112
|
-
).with(
|
113
|
-
"/computer"
|
114
|
-
).and_return(
|
115
|
-
@sample_json_list_response
|
116
|
-
)
|
117
|
-
@client.should_receive(
|
118
|
-
:api_post_request
|
119
|
-
).with(
|
120
|
-
"/computer/#{slave_name}/doDelete"
|
121
|
-
).and_return(
|
122
|
-
"302"
|
123
|
-
)
|
124
|
-
@node.delete(slave_name).to_i.should == 302
|
125
|
-
end
|
126
|
-
it "fails if the given node doesn't exist in Jenkins" do
|
127
|
-
slave_name = "not_there"
|
128
|
-
@client.should_receive(
|
129
|
-
:api_get_request
|
130
|
-
).with(
|
131
|
-
"/computer"
|
132
|
-
).and_return(
|
133
|
-
@sample_json_list_response
|
134
|
-
)
|
135
|
-
expect(
|
136
|
-
lambda{ @node.delete(slave_name) }
|
137
|
-
).to raise_error
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
describe "#list" do
|
142
|
-
it "accepts filter and lists all nodes matching the filter" do
|
143
|
-
@client.should_receive(
|
144
|
-
:api_get_request
|
145
|
-
).with(
|
146
|
-
"/computer"
|
147
|
-
).and_return(
|
148
|
-
@sample_json_list_response
|
149
|
-
)
|
150
|
-
@node.list("slave").class.should == Array
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe "GeneralAttributes" do
|
155
|
-
general_attributes = JenkinsApi::Client::Node::GENERAL_ATTRIBUTES
|
156
|
-
general_attributes.each do |attribute|
|
157
|
-
describe "#get_#{attribute}" do
|
158
|
-
it "should get the #{attribute} attribute" do
|
159
|
-
@client.should_receive(
|
160
|
-
:api_get_request
|
161
|
-
).with(
|
162
|
-
"/computer",
|
163
|
-
"tree=#{attribute}[*[*[*]]]"
|
164
|
-
).and_return(
|
165
|
-
@sample_json_list_response
|
166
|
-
)
|
167
|
-
@node.method("get_#{attribute}").call
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
describe "NodeProperties" do
|
174
|
-
node_properties = JenkinsApi::Client::Node::NODE_PROPERTIES
|
175
|
-
node_properties.each do |property|
|
176
|
-
describe "#is_#{property}?" do
|
177
|
-
it "should get the #{property} property" do
|
178
|
-
@client.should_receive(
|
179
|
-
:api_get_request
|
180
|
-
).with(
|
181
|
-
"/computer/slave",
|
182
|
-
"tree=#{property}"
|
183
|
-
).and_return(
|
184
|
-
@sample_json_computer_response
|
185
|
-
)
|
186
|
-
@node.method("is_#{property}?").call("slave")
|
187
|
-
end
|
188
|
-
|
189
|
-
it "should get the #{property} property for master" do
|
190
|
-
@client.should_receive(
|
191
|
-
:api_get_request
|
192
|
-
).with(
|
193
|
-
"/computer/(master)",
|
194
|
-
"tree=#{property}"
|
195
|
-
).and_return(
|
196
|
-
@sample_json_computer_response
|
197
|
-
)
|
198
|
-
@node.method("is_#{property}?").call("master")
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
describe 'is_offline?' do
|
205
|
-
it "returns true if the node is offline" do
|
206
|
-
@client.should_receive(
|
207
|
-
:api_get_request
|
208
|
-
).with(
|
209
|
-
"/computer/slave",
|
210
|
-
"tree=offline"
|
211
|
-
).and_return(
|
212
|
-
@offline_slave
|
213
|
-
)
|
214
|
-
@node.method("is_offline?").call("slave").should be_true
|
215
|
-
end
|
216
|
-
|
217
|
-
it "returns false if the node is online" do
|
218
|
-
@client.should_receive(
|
219
|
-
:api_get_request
|
220
|
-
).with(
|
221
|
-
"/computer/slave",
|
222
|
-
"tree=offline"
|
223
|
-
).and_return(
|
224
|
-
@online_slave
|
225
|
-
)
|
226
|
-
@node.method("is_offline?").call("slave").should be_false
|
227
|
-
end
|
228
|
-
|
229
|
-
it "returns false if the node is online and have a string value on its attr" do
|
230
|
-
@client.should_receive(
|
231
|
-
:api_get_request
|
232
|
-
).with(
|
233
|
-
"/computer/slave",
|
234
|
-
"tree=offline"
|
235
|
-
).and_return(
|
236
|
-
@offline_slave_in_string
|
237
|
-
)
|
238
|
-
@node.method("is_offline?").call("slave").should be_true
|
239
|
-
end
|
240
|
-
|
241
|
-
it "returns false if the node is online and have a string value on its attr" do
|
242
|
-
@client.should_receive(
|
243
|
-
:api_get_request
|
244
|
-
).with(
|
245
|
-
"/computer/slave",
|
246
|
-
"tree=offline"
|
247
|
-
).and_return(
|
248
|
-
@online_slave_in_string
|
249
|
-
)
|
250
|
-
@node.method("is_offline?").call("slave").should be_false
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
describe "NodeAttributes" do
|
255
|
-
node_attributes = JenkinsApi::Client::Node::NODE_ATTRIBUTES
|
256
|
-
node_attributes.each do |attribute|
|
257
|
-
describe "#get_node_#{attribute}" do
|
258
|
-
it "should get the #{attribute} node attribute" do
|
259
|
-
@client.should_receive(
|
260
|
-
:api_get_request
|
261
|
-
).with(
|
262
|
-
"/computer/slave",
|
263
|
-
"tree=#{attribute}[*[*[*]]]"
|
264
|
-
).and_return(
|
265
|
-
@sample_json_computer_response
|
266
|
-
)
|
267
|
-
@node.method("get_node_#{attribute}").call("slave")
|
268
|
-
end
|
269
|
-
|
270
|
-
it "should get the #{attribute} node attribute for master" do
|
271
|
-
@client.should_receive(
|
272
|
-
:api_get_request
|
273
|
-
).with(
|
274
|
-
"/computer/(master)",
|
275
|
-
"tree=#{attribute}[*[*[*]]]"
|
276
|
-
).and_return(
|
277
|
-
@sample_json_computer_response
|
278
|
-
)
|
279
|
-
@node.method("get_node_#{attribute}").call("master")
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
describe "#get_config" do
|
286
|
-
it "accepts the node name and obtains the config xml from the server" do
|
287
|
-
@client.should_receive(:get_config).with(
|
288
|
-
"/computer/slave"
|
289
|
-
).and_return(
|
290
|
-
@sample_computer_xml
|
291
|
-
)
|
292
|
-
@node.get_config("slave")
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
describe "#post_config" do
|
297
|
-
it "accepts the node namd and config.xml and posts it to the server" do
|
298
|
-
@client.should_receive(:post_config)
|
299
|
-
@node.post_config("slave", @sample_computer_xml)
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
describe "#toggle_temporarilyOffline" do
|
304
|
-
it "successfully toggles an offline status of a node" do
|
305
|
-
@client.should_receive(:api_post_request).with(
|
306
|
-
"/computer/slave/toggleOffline?offlineMessage=foo%20bar"
|
307
|
-
).and_return("302")
|
308
|
-
@client.should_receive(
|
309
|
-
:api_get_request
|
310
|
-
).with(
|
311
|
-
"/computer/slave",
|
312
|
-
"tree=temporarilyOffline"
|
313
|
-
).and_return(
|
314
|
-
@offline_slave,
|
315
|
-
@online_slave
|
316
|
-
)
|
317
|
-
@node.method("toggle_temporarilyOffline").call("slave", "foo bar").should be_false
|
318
|
-
end
|
319
|
-
|
320
|
-
it "fails to toggle an offline status of a node" do
|
321
|
-
@client.should_receive(:api_post_request).with(
|
322
|
-
"/computer/slave/toggleOffline?offlineMessage=foo%20bar"
|
323
|
-
).and_return("302")
|
324
|
-
@client.should_receive(
|
325
|
-
:api_get_request
|
326
|
-
).with(
|
327
|
-
"/computer/slave",
|
328
|
-
"tree=temporarilyOffline"
|
329
|
-
).and_return(
|
330
|
-
@online_slave,
|
331
|
-
@online_slave
|
332
|
-
)
|
333
|
-
expect(
|
334
|
-
lambda{
|
335
|
-
@node.toggle_temporarilyOffline("slave", "foo bar")
|
336
|
-
}
|
337
|
-
).to raise_error
|
338
|
-
end
|
339
|
-
end
|
340
|
-
end
|
341
|
-
end
|
342
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe JenkinsApi::Client::PluginSettings::Collection do
|
4
|
-
let(:plugin_settings_collection) { JenkinsApi::Client::PluginSettings::Collection.new }
|
5
|
-
let(:plugin_setting) { JenkinsApi::Client::PluginSettings::Base.new }
|
6
|
-
|
7
|
-
describe '#initialize' do
|
8
|
-
it 'raises a InvalidType exception if given anything that is not a plugin setting' do
|
9
|
-
expect { JenkinsApi::Client::PluginSettings::Collection.new(Object.new) }.to raise_error(JenkinsApi::Client::PluginSettings::InvalidType)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '#add' do
|
14
|
-
context 'collection does not have member of given plugin setting' do
|
15
|
-
it 'adds the plugin to the collection' do
|
16
|
-
expect(plugin_settings_collection.add(plugin_setting).size).to eql(1)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'collection alreayd has member of same tyep as given plugin setting' do
|
21
|
-
it 'no-ops' do
|
22
|
-
plugin_settings_collection.add(plugin_setting)
|
23
|
-
expect(plugin_settings_collection.add(plugin_setting).size).to eql(1)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'raises a InvalidType exception if a non plugin setting is added' do
|
28
|
-
expect { plugin_settings_collection.add(Object.new) }.to raise_error(JenkinsApi::Client::PluginSettings::InvalidType)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#remove' do
|
33
|
-
context 'collection does not have member of given plugin setting' do
|
34
|
-
it 'no-ops' do
|
35
|
-
expect(plugin_settings_collection.remove(plugin_setting).size).to eql(0)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'collection already has member of same type as given plugin setting' do
|
40
|
-
it 'removes item with same type as given plugin setting from the collection' do
|
41
|
-
plugin_settings_collection.add(plugin_setting)
|
42
|
-
expect(plugin_settings_collection.remove(plugin_setting).size).to eql(0)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#configure' do
|
48
|
-
context 'collection is empty' do
|
49
|
-
it 'no-ops' do
|
50
|
-
expect { plugin_settings_collection.configure(Nokogiri::XML::Document.new)}.to_not raise_error
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'collection has plugins' do
|
55
|
-
it 'calls configure on each of its plugin members' do
|
56
|
-
plugin_settings_collection.add(plugin_setting)
|
57
|
-
expect(plugin_setting).to receive(:configure).once
|
58
|
-
plugin_settings_collection.configure(Nokogiri::XML::Document.new)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe JenkinsApi::Client::PluginSettings::Hipchat do
|
4
|
-
describe '#configure' do
|
5
|
-
context 'given a Nokogiri::XML::Builder object' do
|
6
|
-
it 'adds hipchat configuration to the properties tag with default opts' do
|
7
|
-
hipchat_settings = JenkinsApi::Client::PluginSettings::Hipchat.new
|
8
|
-
hipchat_settings.configure(xml_doc=Nokogiri::XML("<?xml version=\"1.0\"?>\n<properties>\n</properties>\n"))
|
9
|
-
|
10
|
-
expect(xml_doc.at_css('properties room').content).to eql('')
|
11
|
-
expect(xml_doc.at_css('properties startNotification').content).to eql('false')
|
12
|
-
expect(xml_doc.at_css('properties notifySuccess').content).to eql('false')
|
13
|
-
expect(xml_doc.at_css('properties notifyAborted').content).to eql('false')
|
14
|
-
expect(xml_doc.at_css('properties notifyNotBuilt').content).to eql('false')
|
15
|
-
expect(xml_doc.at_css('properties notifyUnstable').content).to eql('false')
|
16
|
-
expect(xml_doc.at_css('properties notifyFailure').content).to eql('false')
|
17
|
-
expect(xml_doc.at_css('properties notifyBackToNormal').content).to eql('false')
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'uses params if given' do
|
21
|
-
hipchat_settings = JenkinsApi::Client::PluginSettings::Hipchat.new({
|
22
|
-
:room => '10000',
|
23
|
-
:start_notification => true,
|
24
|
-
:notify_success => true,
|
25
|
-
:notify_aborted => true,
|
26
|
-
:notify_not_built => true,
|
27
|
-
:notify_unstable => true,
|
28
|
-
:notify_failure => true,
|
29
|
-
:notify_back_to_normal => true,
|
30
|
-
})
|
31
|
-
hipchat_settings.configure(xml_doc=Nokogiri::XML("<?xml version=\"1.0\"?>\n<properties>\n</properties>\n"))
|
32
|
-
|
33
|
-
expect(xml_doc.at_css('properties room').content).to eql('10000')
|
34
|
-
expect(xml_doc.at_css('properties startNotification').content).to eql('true')
|
35
|
-
expect(xml_doc.at_css('properties notifySuccess').content).to eql('true')
|
36
|
-
expect(xml_doc.at_css('properties notifyAborted').content).to eql('true')
|
37
|
-
expect(xml_doc.at_css('properties notifyNotBuilt').content).to eql('true')
|
38
|
-
expect(xml_doc.at_css('properties notifyUnstable').content).to eql('true')
|
39
|
-
expect(xml_doc.at_css('properties notifyFailure').content).to eql('true')
|
40
|
-
expect(xml_doc.at_css('properties notifyBackToNormal').content).to eql('true')
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|