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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/jenkins_api_client.gemspec +15 -136
  3. data/lib/jenkins_api_client/version.rb +2 -2
  4. metadata +6 -180
  5. data/.gitignore +0 -41
  6. data/.jenkins.yml +0 -9
  7. data/.travis.yml +0 -15
  8. data/CHANGELOG.md +0 -391
  9. data/CONTRIBUTORS.md +0 -3
  10. data/Gemfile +0 -20
  11. data/LICENCE +0 -21
  12. data/README.md +0 -454
  13. data/Rakefile +0 -107
  14. data/Vagrantfile +0 -83
  15. data/config/login.yml.example +0 -27
  16. data/jenkins_api_client_class_diagram.png +0 -0
  17. data/scripts/login_with_irb.rb +0 -54
  18. data/scripts/login_with_pry.rb +0 -54
  19. data/spec/func_tests/client_spec.rb +0 -109
  20. data/spec/func_tests/job_spec.rb +0 -669
  21. data/spec/func_tests/node_spec.rb.pending +0 -217
  22. data/spec/func_tests/plugin_spec.rb +0 -148
  23. data/spec/func_tests/spec_helper.rb +0 -41
  24. data/spec/func_tests/system_spec.rb +0 -84
  25. data/spec/func_tests/user_spec.rb +0 -49
  26. data/spec/func_tests/view_spec.rb +0 -276
  27. data/spec/unit_tests/build_queue_spec.rb +0 -152
  28. data/spec/unit_tests/client_spec.rb +0 -471
  29. data/spec/unit_tests/fake_http_response.rb +0 -9
  30. data/spec/unit_tests/fixtures/files/available_plugins.json +0 -1
  31. data/spec/unit_tests/fixtures/files/computer_sample.xml +0 -17
  32. data/spec/unit_tests/fixtures/files/installed_plugins.json +0 -1
  33. data/spec/unit_tests/fixtures/files/job_sample.xml +0 -16
  34. data/spec/unit_tests/fixtures/files/updatable_plugins.json +0 -1
  35. data/spec/unit_tests/job_spec.rb +0 -783
  36. data/spec/unit_tests/node_spec.rb +0 -342
  37. data/spec/unit_tests/plugin_settings/colllection_spec.rb +0 -62
  38. data/spec/unit_tests/plugin_settings/hipchat_spec.rb +0 -44
  39. data/spec/unit_tests/plugin_settings/workspace_cleanup_spec.rb +0 -31
  40. data/spec/unit_tests/plugin_spec.rb +0 -165
  41. data/spec/unit_tests/spec_helper.rb +0 -19
  42. data/spec/unit_tests/system_spec.rb +0 -76
  43. data/spec/unit_tests/user_spec.rb +0 -144
  44. data/spec/unit_tests/view_spec.rb +0 -149
  45. data/travis/hudson.model.UpdateCenter.xml +0 -7
  46. data/travis/jenkins_config.xml +0 -63
  47. data/travis/jenkins_config_with_crumb.xml +0 -67
  48. data/travis/setup.sh +0 -23
  49. data/travis/setup_crumb.sh +0 -11
  50. data/travis/spec.yml +0 -14
  51. data/travis/user_config.xml +0 -29
@@ -1,49 +0,0 @@
1
- #
2
- # Specifying JenkinsApi::Client::User class capabilities
3
- # Author: Doug Henderson <dougforpres@gmail.com>
4
- #
5
-
6
- require File.expand_path('../spec_helper', __FILE__)
7
- require 'yaml'
8
-
9
- describe JenkinsApi::Client::User do
10
- context "With properly initialized client" do
11
- before(:all) do
12
- @creds_file = '~/.jenkins_api_client/spec.yml'
13
- @valid_post_responses = [200, 201, 302]
14
- begin
15
- @client = JenkinsApi::Client.new(
16
- YAML.load_file(File.expand_path(@creds_file, __FILE__))
17
- )
18
- rescue Exception => e
19
- puts "WARNING: Credentials are not set properly."
20
- puts e.message
21
- end
22
- end
23
-
24
- describe "InstanceMethods" do
25
-
26
- describe "#list" do
27
- it "Should be able to get a list of users" do
28
- @client.user.list.should be_an_instance_of(Hash)
29
- end
30
- end
31
-
32
- describe "#get" do
33
- it "Should be able to get a specific user" do
34
- # Actually, we're gonna get every user in the main user list
35
- users = @client.user.list
36
-
37
- users.each do |id, user|
38
- id.should eq(user['id'])
39
- fetched = @client.user.get(id)
40
- fetched.should eq(user)
41
- end
42
-
43
- end
44
- end
45
-
46
- end
47
-
48
- end
49
- end
@@ -1,276 +0,0 @@
1
- #
2
- # Specifying JenkinsApi::Client::View class capabilities
3
- # Author Kannan Manickam <arangamani.kannan@gmail.com>
4
- #
5
-
6
- require File.expand_path('../spec_helper', __FILE__)
7
- require 'yaml'
8
-
9
- describe JenkinsApi::Client::View do
10
- context "With properly initialized client" do
11
- before(:all) do
12
- @creds_file = '~/.jenkins_api_client/spec.yml'
13
- @valid_post_responses = [200, 201, 302]
14
- @node_name = 'master'
15
- begin
16
- @client = JenkinsApi::Client.new(
17
- YAML.load_file(File.expand_path(@creds_file, __FILE__))
18
- )
19
- rescue Exception => e
20
- puts "WARNING: Credentials are not set properly."
21
- puts e.message
22
- end
23
-
24
- # Create a view that can be used for tests
25
- @valid_post_responses.should include(
26
- @client.view.create("general_purpose_view").to_i
27
- )
28
- end
29
-
30
- describe "InstanceMethods" do
31
-
32
- describe "#list" do
33
- it "Should be able to list all views" do
34
- @client.view.list.class.should == Array
35
- end
36
- end
37
-
38
- describe "#create" do
39
- it "accepts the name of the view and creates the view" do
40
- name = "test_view"
41
- @valid_post_responses.should include(
42
- @client.view.create(name).to_i
43
- )
44
- @client.view.list(name).include?(name).should be_true
45
- @valid_post_responses.should include(
46
- @client.view.delete(name).to_i
47
- )
48
- end
49
- it "accepts spaces and other characters in the view name" do
50
- name = "test view with spaces and {special characters}"
51
- @valid_post_responses.should include(
52
- @client.view.create(name).to_i
53
- )
54
- @client.view.list(name).include?(name).should be_true
55
- @valid_post_responses.should include(
56
- @client.view.delete(name).to_i
57
- )
58
- end
59
- it "accepts the name of view and creates a listview" do
60
- name = "test_view"
61
- @valid_post_responses.should include(
62
- @client.view.create(name, "listview").to_i
63
- )
64
- @client.view.list(name).include?(name).should be_true
65
- @valid_post_responses.should include(
66
- @client.view.delete(name).to_i
67
- )
68
- end
69
- it "accepts the name of view and creates a myview" do
70
- name = "test_view"
71
- @valid_post_responses.should include(
72
- @client.view.create(name, "myview").to_i
73
- )
74
- @client.view.list(name).include?(name).should be_true
75
- @valid_post_responses.should include(
76
- @client.view.delete(name).to_i
77
- )
78
- end
79
- it "raises an error when unsupported view type is specified" do
80
- expect(
81
- lambda { @client.view.create(name, "awesomeview") }
82
- ).to raise_error
83
- end
84
- it "raises proper error if the view already exists" do
85
- name = "duplicate_view"
86
- @valid_post_responses.should include(
87
- @client.view.create(name, "listview").to_i
88
- )
89
- @client.view.list(name).include?(name).should be_true
90
- expect(
91
- lambda { @client.view.create(name, "listview") }
92
- ).to raise_error(JenkinsApi::Exceptions::ViewAlreadyExists)
93
- @valid_post_responses.should include(
94
- @client.view.delete(name).to_i
95
- )
96
- end
97
- end
98
-
99
- describe "#create_list_view" do
100
-
101
- def test_and_validate(params)
102
- name = params[:name]
103
- @valid_post_responses.should include(
104
- @client.view.create_list_view(params).to_i
105
- )
106
- @client.view.list(name).include?(name).should be_true
107
- @valid_post_responses.should include(
108
- @client.view.delete(name).to_i
109
- )
110
- @client.view.list(name).include?(name).should be_false
111
- end
112
-
113
- it "accepts just the name of the view and creates the view" do
114
- params = {
115
- :name => "test_list_view"
116
- }
117
- test_and_validate(params)
118
- end
119
-
120
- it "accepts description as an option" do
121
- params = {
122
- :name => "test_list_view",
123
- :description => "test list view created for functional test"
124
- }
125
- test_and_validate(params)
126
- end
127
-
128
- it "accepts filter_queue as an option" do
129
- params = {
130
- :name => "test_list_view",
131
- :filter_queue => true
132
- }
133
- test_and_validate(params)
134
- end
135
-
136
- it "accepts filter_executors as an option" do
137
- params = {
138
- :name => "test_list_view",
139
- :filter_executors => true
140
- }
141
- test_and_validate(params)
142
- end
143
-
144
- it "accepts regex as an option" do
145
- params = {
146
- :name => "test_list_view",
147
- :regex => "^test.*"
148
- }
149
- test_and_validate(params)
150
- end
151
- it "raises an error when the input parameters is not a Hash" do
152
- expect(
153
- lambda {
154
- @client.view.create_list_view("a_string")
155
- }
156
- ).to raise_error(ArgumentError)
157
- end
158
- it "raises an error when the required name paremeter is missing" do
159
- expect(
160
- lambda {
161
- @client.view.create_list_view(:description => "awesomeview")
162
- }
163
- ).to raise_error(ArgumentError)
164
- end
165
- end
166
-
167
- describe "#delete" do
168
- name = "test_view_to_delete"
169
- before(:all) do
170
- @valid_post_responses.should include(
171
- @client.view.create(name).to_i
172
- )
173
- end
174
- it "accepts the name of the view and deletes from Jenkins" do
175
- @client.view.list(name).include?(name).should be_true
176
- @valid_post_responses.should include(
177
- @client.view.delete(name).to_i
178
- )
179
- @client.view.list(name).include?(name).should be_false
180
- end
181
- end
182
-
183
- describe "#list_jobs" do
184
- it "accepts the view name and lists all jobs in the view" do
185
- @client.view.list_jobs("general_purpose_view").class.should == Array
186
- end
187
- end
188
-
189
- describe "#exists?" do
190
- it "accepts the vie name and returns true if the view exists" do
191
- @client.view.exists?("general_purpose_view").should be_true
192
- end
193
- end
194
-
195
- describe "#add_job" do
196
- before(:all) do
197
- @valid_post_responses.should include(
198
- @client.job.create_freestyle(
199
- :name => "test_job_for_view"
200
- ).to_i
201
- )
202
- end
203
- it "accepts the job and and adds it to the specified view" do
204
- @valid_post_responses.should include(
205
- @client.view.add_job(
206
- "general_purpose_view",
207
- "test_job_for_view"
208
- ).to_i
209
- )
210
- @client.view.list_jobs(
211
- "general_purpose_view"
212
- ).include?("test_job_for_view").should be_true
213
- end
214
- end
215
-
216
- describe "#remove_job" do
217
- before(:all) do
218
- unless @client.job.exists?("test_job_for_view")
219
- @valid_post_responses.should include(
220
- @client.job.create_freestyle(
221
- :name => "test_job_for_view"
222
- ).to_i
223
- )
224
- end
225
- unless @client.view.list_jobs(
226
- "general_purpose_view").include?("test_job_for_view")
227
- @valid_post_responses.should include(
228
- @client.view.add_job(
229
- "general_purpose_job",
230
- "test_job_for_view"
231
- ).to_i
232
- )
233
- end
234
- end
235
- it "accepts the job name and removes it from the specified view" do
236
- @valid_post_responses.should include(
237
- @client.view.remove_job(
238
- "general_purpose_view",
239
- "test_job_for_view"
240
- ).to_i
241
- )
242
- end
243
- end
244
-
245
- describe "#get_config" do
246
- it "obtaines the view config.xml from the server" do
247
- expect(
248
- lambda { @client.view.get_config("general_purpose_view") }
249
- ).not_to raise_error
250
- end
251
- end
252
-
253
- describe "#post_config" do
254
- it "posts the given config.xml to the jenkins server's view" do
255
- expect(
256
- lambda {
257
- xml = @client.view.get_config("general_purpose_view")
258
- @client.view.post_config("general_purpose_view", xml)
259
- }
260
- ).not_to raise_error
261
- end
262
- end
263
- end
264
-
265
- after(:all) do
266
- @valid_post_responses.should include(
267
- @client.view.delete("general_purpose_view").to_i
268
- )
269
- if @client.job.exists?("test_job_for_view")
270
- @valid_post_responses.should include(
271
- @client.job.delete("test_job_for_view").to_i
272
- )
273
- end
274
- end
275
- end
276
- end
@@ -1,152 +0,0 @@
1
- require File.expand_path('../spec_helper', __FILE__)
2
-
3
- describe JenkinsApi::Client::BuildQueue 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
- @queue = JenkinsApi::Client::BuildQueue.new(@client)
10
- @sample_queue_json = {
11
- "items" => [
12
- {
13
- "actions" => [
14
- {
15
- "causes" => [
16
- {
17
-
18
- }
19
- ]
20
- }
21
- ],
22
- "blocked" => true,
23
- "buildable" => false,
24
- "id" => 2,
25
- "inQueueSince" => 1362906942731,
26
- "params" => "",
27
- "stuck" => false,
28
- "task" => {
29
- "name" => "queue_test",
30
- "url" => "http://localhost:8080/job/queue_test/",
31
- "color" => "grey_anime"
32
- },
33
- "why" => "Build #1 is already in progress (ETA:N/A)",
34
- "buildStartMilliseconds" => 1362906942832
35
- }
36
- ]
37
- }
38
- end
39
-
40
- describe "InstanceMethods" do
41
- describe "#initialize" do
42
- it "initializes by receiving an instance of client object" do
43
- mock_logger = Logger.new "/dev/null"
44
- @client.should_receive(:logger).and_return(mock_logger)
45
- expect(
46
- lambda{ JenkinsApi::Client::BuildQueue.new(@client) }
47
- ).not_to raise_error
48
- end
49
- end
50
-
51
- describe "#size" do
52
- it "returns the size of the queue" do
53
- @client.should_receive(:api_get_request).with("/queue").and_return(
54
- @sample_queue_json
55
- )
56
- @queue.size
57
- end
58
- end
59
-
60
- describe "#list" do
61
- it "returns the list of tasks in the queue" do
62
- @client.should_receive(:api_get_request).with("/queue").and_return(
63
- @sample_queue_json
64
- )
65
- @queue.list.class.should == Array
66
- end
67
- end
68
-
69
- describe "#get_age" do
70
- it "returns the age of a task" do
71
- @client.should_receive(:api_get_request).with("/queue").and_return(
72
- @sample_queue_json
73
- )
74
- @queue.get_age("queue_test").class.should == Float
75
- end
76
- end
77
-
78
- describe "#get_details" do
79
- it "returns the details of a task in the queue" do
80
- @client.should_receive(:api_get_request).with("/queue").and_return(
81
- @sample_queue_json
82
- )
83
- @queue.get_details("queue_test").class.should == Hash
84
- end
85
- end
86
-
87
- describe "#get_causes" do
88
- it "returns the causes of a task in queue" do
89
- @client.should_receive(:api_get_request).with("/queue").and_return(
90
- @sample_queue_json
91
- )
92
- @queue.get_causes("queue_test").class.should == Array
93
- end
94
- end
95
-
96
- describe "#get_reason" do
97
- it "returns the reason of a task in queue" do
98
- @client.should_receive(:api_get_request).with("/queue").and_return(
99
- @sample_queue_json
100
- )
101
- @queue.get_reason("queue_test").class.should == String
102
- end
103
- end
104
-
105
- describe "#get_eta" do
106
- it "returns the ETA of a task in queue" do
107
- @client.should_receive(:api_get_request).with("/queue").and_return(
108
- @sample_queue_json
109
- )
110
- @queue.get_eta("queue_test").class.should == String
111
- end
112
- end
113
-
114
- describe "#get_params" do
115
- it "returns the params of a task in queue" do
116
- @client.should_receive(:api_get_request).with("/queue").and_return(
117
- @sample_queue_json
118
- )
119
- @queue.get_params("queue_test").class.should == String
120
- end
121
- end
122
-
123
- describe "#is_buildable?" do
124
- it "returns true if the job is buildable" do
125
- @client.should_receive(:api_get_request).with("/queue").and_return(
126
- @sample_queue_json
127
- )
128
- @queue.is_buildable?("queue_test").should == false
129
- end
130
- end
131
-
132
- describe "#is_blocked?" do
133
- it "returns true if the job is blocked" do
134
- @client.should_receive(:api_get_request).with("/queue").and_return(
135
- @sample_queue_json
136
- )
137
- @queue.is_blocked?("queue_test").should == true
138
- end
139
- end
140
-
141
- describe "#is_stuck?" do
142
- it "returns true if the job is stuck" do
143
- @client.should_receive(:api_get_request).with("/queue").and_return(
144
- @sample_queue_json
145
- )
146
- @queue.is_stuck?("queue_test").should == false
147
- end
148
- end
149
-
150
- end
151
- end
152
- end