jira-ruby 2.3.0 → 3.0.0.beta1
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/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/CI.yml +28 -0
- data/.github/workflows/codeql.yml +100 -0
- data/.github/workflows/rubocop.yml +18 -0
- data/.rubocop.yml +188 -0
- data/Gemfile +11 -3
- data/Guardfile +2 -0
- data/README.md +94 -18
- data/Rakefile +3 -4
- data/jira-ruby.gemspec +11 -17
- data/lib/jira/base.rb +37 -28
- data/lib/jira/base_factory.rb +4 -1
- data/lib/jira/client.rb +64 -46
- data/lib/jira/has_many_proxy.rb +4 -2
- data/lib/jira/http_client.rb +17 -13
- data/lib/jira/http_error.rb +4 -0
- data/lib/jira/jwt_client.rb +18 -42
- data/lib/jira/oauth_client.rb +6 -3
- data/lib/jira/railtie.rb +2 -0
- data/lib/jira/request_client.rb +5 -1
- data/lib/jira/resource/agile.rb +7 -9
- data/lib/jira/resource/applinks.rb +5 -3
- data/lib/jira/resource/attachment.rb +43 -3
- data/lib/jira/resource/board.rb +5 -3
- data/lib/jira/resource/board_configuration.rb +2 -0
- data/lib/jira/resource/comment.rb +2 -0
- data/lib/jira/resource/component.rb +2 -0
- data/lib/jira/resource/createmeta.rb +3 -1
- data/lib/jira/resource/field.rb +9 -4
- data/lib/jira/resource/filter.rb +2 -0
- data/lib/jira/resource/issue.rb +35 -44
- data/lib/jira/resource/issue_picker_suggestions.rb +4 -1
- data/lib/jira/resource/issue_picker_suggestions_issue.rb +2 -0
- data/lib/jira/resource/issuelink.rb +2 -0
- data/lib/jira/resource/issuelinktype.rb +2 -0
- data/lib/jira/resource/issuetype.rb +2 -0
- data/lib/jira/resource/priority.rb +2 -0
- data/lib/jira/resource/project.rb +4 -2
- data/lib/jira/resource/rapidview.rb +5 -3
- data/lib/jira/resource/remotelink.rb +2 -0
- data/lib/jira/resource/resolution.rb +2 -0
- data/lib/jira/resource/serverinfo.rb +2 -0
- data/lib/jira/resource/sprint.rb +14 -23
- data/lib/jira/resource/status.rb +7 -1
- data/lib/jira/resource/status_category.rb +10 -0
- data/lib/jira/resource/suggested_issue.rb +2 -0
- data/lib/jira/resource/transition.rb +2 -0
- data/lib/jira/resource/user.rb +3 -1
- data/lib/jira/resource/version.rb +2 -0
- data/lib/jira/resource/watcher.rb +2 -1
- data/lib/jira/resource/webhook.rb +4 -2
- data/lib/jira/resource/worklog.rb +3 -2
- data/lib/jira/version.rb +3 -1
- data/lib/jira-ruby.rb +5 -3
- data/lib/tasks/generate.rake +4 -2
- data/spec/data/files/short.txt +1 -0
- data/spec/integration/attachment_spec.rb +3 -3
- data/spec/integration/comment_spec.rb +8 -8
- data/spec/integration/component_spec.rb +7 -7
- data/spec/integration/field_spec.rb +3 -3
- data/spec/integration/issue_spec.rb +20 -16
- data/spec/integration/issuelinktype_spec.rb +3 -3
- data/spec/integration/issuetype_spec.rb +3 -3
- data/spec/integration/priority_spec.rb +3 -3
- data/spec/integration/project_spec.rb +7 -7
- data/spec/integration/rapidview_spec.rb +9 -9
- data/spec/integration/resolution_spec.rb +3 -3
- data/spec/integration/status_category_spec.rb +20 -0
- data/spec/integration/status_spec.rb +4 -8
- data/spec/integration/transition_spec.rb +2 -2
- data/spec/integration/user_spec.rb +22 -8
- data/spec/integration/version_spec.rb +7 -7
- data/spec/integration/watcher_spec.rb +17 -18
- data/spec/integration/webhook.rb +5 -4
- data/spec/integration/worklog_spec.rb +8 -8
- data/spec/jira/base_factory_spec.rb +2 -1
- data/spec/jira/base_spec.rb +55 -41
- data/spec/jira/client_spec.rb +48 -34
- data/spec/jira/has_many_proxy_spec.rb +3 -3
- data/spec/jira/http_client_spec.rb +94 -27
- data/spec/jira/http_error_spec.rb +2 -2
- data/spec/jira/oauth_client_spec.rb +8 -6
- data/spec/jira/request_client_spec.rb +4 -4
- data/spec/jira/resource/agile_spec.rb +28 -28
- data/spec/jira/resource/attachment_spec.rb +142 -52
- data/spec/jira/resource/board_spec.rb +21 -20
- data/spec/jira/resource/createmeta_spec.rb +48 -48
- data/spec/jira/resource/field_spec.rb +30 -12
- data/spec/jira/resource/filter_spec.rb +4 -4
- data/spec/jira/resource/issue_picker_suggestions_spec.rb +17 -17
- data/spec/jira/resource/issue_spec.rb +43 -37
- data/spec/jira/resource/jira_picker_suggestions_issue_spec.rb +3 -3
- data/spec/jira/resource/project_factory_spec.rb +3 -2
- data/spec/jira/resource/project_spec.rb +16 -16
- data/spec/jira/resource/sprint_spec.rb +70 -3
- data/spec/jira/resource/status_spec.rb +21 -0
- data/spec/jira/resource/user_factory_spec.rb +4 -4
- data/spec/jira/resource/worklog_spec.rb +3 -3
- data/spec/mock_responses/sprint/1.json +13 -0
- data/spec/mock_responses/status/1.json +8 -1
- data/spec/mock_responses/status.json +40 -5
- data/spec/mock_responses/statuscategory/1.json +7 -0
- data/spec/mock_responses/statuscategory.json +30 -0
- data/spec/mock_responses/{user_username=admin.json → user_accountId=1234567890abcdef01234567.json} +2 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/clients_helper.rb +3 -5
- data/spec/support/shared_examples/integration.rb +25 -28
- metadata +25 -257
- data/.travis.yml +0 -9
- data/example.rb +0 -232
- data/http-basic-example.rb +0 -113
- data/lib/jira/resource/sprint_report.rb +0 -8
- data/lib/jira/tasks.rb +0 -0
- data/spec/jira/jwt_uri_builder_spec.rb +0 -59
|
@@ -5,7 +5,7 @@ describe JIRA::HttpClient do
|
|
|
5
5
|
options = JIRA::Client::DEFAULT_OPTIONS
|
|
6
6
|
.merge(JIRA::HttpClient::DEFAULT_OPTIONS)
|
|
7
7
|
.merge(basic_auth_credentials)
|
|
8
|
-
|
|
8
|
+
described_class.new(options)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
let(:basic_cookie_client) do
|
|
@@ -13,12 +13,12 @@ describe JIRA::HttpClient do
|
|
|
13
13
|
.merge(JIRA::HttpClient::DEFAULT_OPTIONS)
|
|
14
14
|
.merge(use_cookies: true)
|
|
15
15
|
.merge(basic_auth_credentials)
|
|
16
|
-
|
|
16
|
+
described_class.new(options)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
let(:custom_ssl_version_client) do
|
|
20
20
|
options = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(ssl_version: :TLSv1_2)
|
|
21
|
-
|
|
21
|
+
described_class.new(options)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
let(:basic_cookie_client_with_context_path) do
|
|
@@ -26,7 +26,7 @@ describe JIRA::HttpClient do
|
|
|
26
26
|
use_cookies: true,
|
|
27
27
|
context_path: '/context'
|
|
28
28
|
)
|
|
29
|
-
|
|
29
|
+
described_class.new(options)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
let(:basic_cookie_client_with_additional_cookies) do
|
|
@@ -37,7 +37,7 @@ describe JIRA::HttpClient do
|
|
|
37
37
|
additional_cookies: ['sessionToken=abc123', 'internal=true']
|
|
38
38
|
)
|
|
39
39
|
.merge(basic_auth_credentials)
|
|
40
|
-
|
|
40
|
+
described_class.new(options)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
let(:basic_client_cert_client) do
|
|
@@ -46,13 +46,13 @@ describe JIRA::HttpClient do
|
|
|
46
46
|
cert: 'public certificate contents',
|
|
47
47
|
key: 'private key contents'
|
|
48
48
|
)
|
|
49
|
-
|
|
49
|
+
described_class.new(options)
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
let(:basic_client_with_no_auth_credentials) do
|
|
53
53
|
options = JIRA::Client::DEFAULT_OPTIONS
|
|
54
54
|
.merge(JIRA::HttpClient::DEFAULT_OPTIONS)
|
|
55
|
-
|
|
55
|
+
described_class.new(options)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
let(:basic_auth_credentials) do
|
|
@@ -66,7 +66,14 @@ describe JIRA::HttpClient do
|
|
|
66
66
|
proxy_username: 'proxyUsername',
|
|
67
67
|
proxy_password: 'proxyPassword'
|
|
68
68
|
)
|
|
69
|
-
|
|
69
|
+
described_class.new(options)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
let(:basic_client_with_max_retries) do
|
|
73
|
+
options = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(
|
|
74
|
+
max_retries: 2
|
|
75
|
+
)
|
|
76
|
+
described_class.new(options)
|
|
70
77
|
end
|
|
71
78
|
|
|
72
79
|
let(:response) do
|
|
@@ -81,6 +88,35 @@ describe JIRA::HttpClient do
|
|
|
81
88
|
response
|
|
82
89
|
end
|
|
83
90
|
|
|
91
|
+
context 'simple client' do
|
|
92
|
+
let(:client) do
|
|
93
|
+
options_local = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(
|
|
94
|
+
proxy_address: 'proxyAddress',
|
|
95
|
+
proxy_port: 42,
|
|
96
|
+
proxy_username: 'proxyUsername',
|
|
97
|
+
proxy_password: 'proxyPassword'
|
|
98
|
+
)
|
|
99
|
+
described_class.new(options_local)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe 'HttpClient#basic_auth_http_conn' do
|
|
103
|
+
subject(:http_conn) { basic_client.basic_auth_http_conn }
|
|
104
|
+
|
|
105
|
+
it 'creates an instance of Net:HTTP for a basic auth client' do
|
|
106
|
+
expect(http_conn.class).to eq(Net::HTTP)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'the connection created has no proxy' do
|
|
110
|
+
http_conn
|
|
111
|
+
|
|
112
|
+
expect(http_conn.proxy_address).to be_nil
|
|
113
|
+
expect(http_conn.proxy_port).to be_nil
|
|
114
|
+
expect(http_conn.proxy_user).to be_nil
|
|
115
|
+
expect(http_conn.proxy_pass).to be_nil
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
84
120
|
it 'creates an instance of Net:HTTP for a basic auth client' do
|
|
85
121
|
expect(basic_client.basic_auth_http_conn.class).to eq(Net::HTTP)
|
|
86
122
|
end
|
|
@@ -111,7 +147,8 @@ describe JIRA::HttpClient do
|
|
|
111
147
|
basic_auth_http_conn = double
|
|
112
148
|
request = double
|
|
113
149
|
allow(basic_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
|
|
114
|
-
expect(request).to receive(:basic_auth).with(basic_client.options[:username],
|
|
150
|
+
expect(request).to receive(:basic_auth).with(basic_client.options[:username],
|
|
151
|
+
basic_client.options[:password]).exactly(5).times.and_return(request)
|
|
115
152
|
expect(basic_auth_http_conn).to receive(:request).exactly(5).times.with(request).and_return(response)
|
|
116
153
|
%i[delete get head].each do |method|
|
|
117
154
|
expect(Net::HTTP.const_get(method.to_s.capitalize)).to receive(:new).with('/path', headers).and_return(request)
|
|
@@ -130,7 +167,8 @@ describe JIRA::HttpClient do
|
|
|
130
167
|
basic_auth_http_conn = double
|
|
131
168
|
request = double
|
|
132
169
|
allow(basic_cookie_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
|
|
133
|
-
expect(request).to receive(:basic_auth).with(basic_cookie_client.options[:username],
|
|
170
|
+
expect(request).to receive(:basic_auth).with(basic_cookie_client.options[:username],
|
|
171
|
+
basic_cookie_client.options[:password]).exactly(5).times.and_return(request)
|
|
134
172
|
expect(cookie_response).to receive(:get_fields).with('set-cookie').exactly(5).times
|
|
135
173
|
expect(basic_auth_http_conn).to receive(:request).exactly(5).times.with(request).and_return(cookie_response)
|
|
136
174
|
%i[delete get head].each do |method|
|
|
@@ -151,7 +189,8 @@ describe JIRA::HttpClient do
|
|
|
151
189
|
basic_auth_http_conn = double
|
|
152
190
|
request = double
|
|
153
191
|
allow(client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
|
|
154
|
-
expect(request).to receive(:basic_auth).with(client.options[:username],
|
|
192
|
+
expect(request).to receive(:basic_auth).with(client.options[:username],
|
|
193
|
+
client.options[:password]).exactly(5).times.and_return(request)
|
|
155
194
|
expect(request).to receive(:add_field).with('Cookie', 'sessionToken=abc123; internal=true').exactly(5).times
|
|
156
195
|
expect(cookie_response).to receive(:get_fields).with('set-cookie').exactly(5).times
|
|
157
196
|
expect(basic_auth_http_conn).to receive(:request).exactly(5).times.with(request).and_return(cookie_response)
|
|
@@ -174,7 +213,8 @@ describe JIRA::HttpClient do
|
|
|
174
213
|
expect(Net::HTTP::Get).to receive(:new).with('/foo', headers).and_return(http_request)
|
|
175
214
|
|
|
176
215
|
expect(basic_auth_http_conn).to receive(:request).with(http_request).and_return(response)
|
|
177
|
-
expect(http_request).to receive(:basic_auth).with(basic_client.options[:username],
|
|
216
|
+
expect(http_request).to receive(:basic_auth).with(basic_client.options[:username],
|
|
217
|
+
basic_client.options[:password]).and_return(http_request)
|
|
178
218
|
allow(basic_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
|
|
179
219
|
basic_client.make_request(:get, '/foo', body, headers)
|
|
180
220
|
end
|
|
@@ -187,7 +227,8 @@ describe JIRA::HttpClient do
|
|
|
187
227
|
expect(Net::HTTP::Get).to receive(:new).with('/foo', headers).and_return(http_request)
|
|
188
228
|
|
|
189
229
|
expect(basic_auth_http_conn).to receive(:request).with(http_request).and_return(response)
|
|
190
|
-
expect(http_request).to receive(:basic_auth).with(basic_client.options[:username],
|
|
230
|
+
expect(http_request).to receive(:basic_auth).with(basic_client.options[:username],
|
|
231
|
+
basic_client.options[:password]).and_return(http_request)
|
|
191
232
|
allow(basic_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
|
|
192
233
|
basic_client.make_request(:get, 'http://mydomain.com/foo', body, headers)
|
|
193
234
|
end
|
|
@@ -254,19 +295,29 @@ describe JIRA::HttpClient do
|
|
|
254
295
|
expect(proxy_configuration.proxy_pass).to be_nil
|
|
255
296
|
end
|
|
256
297
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
298
|
+
context 'client has proxy settings' do
|
|
299
|
+
subject(:proxy_conn) { proxy_client.basic_auth_http_conn }
|
|
300
|
+
|
|
301
|
+
let(:proxy_client) do
|
|
302
|
+
options_local = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(
|
|
303
|
+
proxy_address: 'proxyAddress',
|
|
304
|
+
proxy_port: 42,
|
|
305
|
+
proxy_username: 'proxyUsername',
|
|
306
|
+
proxy_password: 'proxyPassword'
|
|
307
|
+
)
|
|
308
|
+
described_class.new(options_local)
|
|
309
|
+
end
|
|
261
310
|
|
|
262
|
-
|
|
263
|
-
|
|
311
|
+
describe 'HttpClient#basic_auth_http_conn' do
|
|
312
|
+
it 'creates a Net:HTTP instance for a basic auth client setting up a proxied http connection' do
|
|
313
|
+
expect(proxy_conn.class).to eq(Net::HTTP)
|
|
264
314
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
315
|
+
expect(proxy_conn.proxy_address).to eq(proxy_client.options[:proxy_address])
|
|
316
|
+
expect(proxy_conn.proxy_port).to eq(proxy_client.options[:proxy_port])
|
|
317
|
+
expect(proxy_conn.proxy_user).to eq(proxy_client.options[:proxy_username])
|
|
318
|
+
expect(proxy_conn.proxy_pass).to eq(proxy_client.options[:proxy_password])
|
|
319
|
+
end
|
|
320
|
+
end
|
|
270
321
|
end
|
|
271
322
|
|
|
272
323
|
it 'can use client certificates' do
|
|
@@ -286,10 +337,25 @@ describe JIRA::HttpClient do
|
|
|
286
337
|
end
|
|
287
338
|
|
|
288
339
|
it 'can use a certificate authority file' do
|
|
289
|
-
client =
|
|
340
|
+
client = described_class.new(JIRA::Client::DEFAULT_OPTIONS.merge(ca_file: '/opt/custom.ca.pem'))
|
|
290
341
|
expect(client.http_conn(client.uri).ca_file).to eql('/opt/custom.ca.pem')
|
|
291
342
|
end
|
|
292
343
|
|
|
344
|
+
it 'allows overriding max_retries' do
|
|
345
|
+
http_conn = double
|
|
346
|
+
uri = double
|
|
347
|
+
host = double
|
|
348
|
+
port = double
|
|
349
|
+
expect(uri).to receive(:host).and_return(host)
|
|
350
|
+
expect(uri).to receive(:port).and_return(port)
|
|
351
|
+
expect(Net::HTTP).to receive(:new).with(host, port).and_return(http_conn)
|
|
352
|
+
expect(http_conn).to receive(:use_ssl=).with(basic_client.options[:use_ssl]).and_return(http_conn)
|
|
353
|
+
expect(http_conn).to receive(:verify_mode=).with(basic_client.options[:ssl_verify_mode]).and_return(http_conn)
|
|
354
|
+
expect(http_conn).to receive(:read_timeout=).with(basic_client.options[:read_timeout]).and_return(http_conn)
|
|
355
|
+
expect(http_conn).to receive(:max_retries=).with(basic_client_with_max_retries.options[:max_retries]).and_return(http_conn)
|
|
356
|
+
expect(basic_client_with_max_retries.http_conn(uri)).to eq(http_conn)
|
|
357
|
+
end
|
|
358
|
+
|
|
293
359
|
it 'returns a http connection' do
|
|
294
360
|
http_conn = double
|
|
295
361
|
uri = double
|
|
@@ -307,7 +373,7 @@ describe JIRA::HttpClient do
|
|
|
307
373
|
let(:data) { {} }
|
|
308
374
|
let(:headers) { { 'X-Atlassian-Token' => 'no-check' } }
|
|
309
375
|
let(:basic_auth_http_conn) { double }
|
|
310
|
-
let(:request) { double('Http Request', path:
|
|
376
|
+
let(:request) { double('Http Request', path:) }
|
|
311
377
|
let(:response) { double('response') }
|
|
312
378
|
|
|
313
379
|
before do
|
|
@@ -318,7 +384,8 @@ describe JIRA::HttpClient do
|
|
|
318
384
|
end
|
|
319
385
|
|
|
320
386
|
it 'performs a basic http client request' do
|
|
321
|
-
expect(request).to receive(:basic_auth).with(basic_client.options[:username],
|
|
387
|
+
expect(request).to receive(:basic_auth).with(basic_client.options[:username],
|
|
388
|
+
basic_client.options[:password]).and_return(request)
|
|
322
389
|
|
|
323
390
|
subject
|
|
324
391
|
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe JIRA::HTTPError do
|
|
4
|
+
subject { described_class.new(response) }
|
|
5
|
+
|
|
4
6
|
let(:response) do
|
|
5
7
|
response = double('response')
|
|
6
8
|
allow(response).to receive(:code).and_return(401)
|
|
@@ -8,8 +10,6 @@ describe JIRA::HTTPError do
|
|
|
8
10
|
response
|
|
9
11
|
end
|
|
10
12
|
|
|
11
|
-
subject { described_class.new(response) }
|
|
12
|
-
|
|
13
13
|
it 'takes the response object as an argument' do
|
|
14
14
|
expect(subject.response).to eq(response)
|
|
15
15
|
end
|
|
@@ -4,7 +4,7 @@ describe JIRA::OauthClient do
|
|
|
4
4
|
let(:oauth_client) do
|
|
5
5
|
options = { consumer_key: 'foo', consumer_secret: 'bar' }
|
|
6
6
|
options = JIRA::Client::DEFAULT_OPTIONS.merge(options)
|
|
7
|
-
|
|
7
|
+
described_class.new(options)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
let(:response) do
|
|
@@ -124,7 +124,6 @@ describe JIRA::OauthClient do
|
|
|
124
124
|
it 'performs a request' do
|
|
125
125
|
expect(access_token).to receive(:send).with(:get, '/foo', headers).and_return(response)
|
|
126
126
|
|
|
127
|
-
|
|
128
127
|
oauth_client.request(:get, '/foo', body, headers)
|
|
129
128
|
end
|
|
130
129
|
|
|
@@ -136,7 +135,8 @@ describe JIRA::OauthClient do
|
|
|
136
135
|
|
|
137
136
|
it 'signs the access_token and performs the request' do
|
|
138
137
|
expect(access_token).to receive(:sign!).with(an_instance_of(Net::HTTP::Post::Multipart))
|
|
139
|
-
expect(oauth_client.consumer).to receive_message_chain(:http,
|
|
138
|
+
expect(oauth_client.consumer).to receive_message_chain(:http,
|
|
139
|
+
:request).with(an_instance_of(Net::HTTP::Post::Multipart))
|
|
140
140
|
|
|
141
141
|
subject
|
|
142
142
|
end
|
|
@@ -147,7 +147,7 @@ describe JIRA::OauthClient do
|
|
|
147
147
|
let(:oauth__2legged_client) do
|
|
148
148
|
options = { consumer_key: 'foo', consumer_secret: 'bar', auth_type: :oauth_2legged }
|
|
149
149
|
options = JIRA::Client::DEFAULT_OPTIONS.merge(options)
|
|
150
|
-
|
|
150
|
+
described_class.new(options)
|
|
151
151
|
end
|
|
152
152
|
|
|
153
153
|
it 'responds to the http methods adding oauth_token parameter' do
|
|
@@ -169,11 +169,13 @@ describe JIRA::OauthClient do
|
|
|
169
169
|
mock_access_token = double
|
|
170
170
|
allow(oauth__2legged_client).to receive(:access_token).and_return(mock_access_token)
|
|
171
171
|
%i[delete get head].each do |method|
|
|
172
|
-
expect(mock_access_token).to receive(method).with('/path?any_param=toto&oauth_token=',
|
|
172
|
+
expect(mock_access_token).to receive(method).with('/path?any_param=toto&oauth_token=',
|
|
173
|
+
headers).and_return(response)
|
|
173
174
|
oauth__2legged_client.make_request(method, '/path?any_param=toto', '', headers)
|
|
174
175
|
end
|
|
175
176
|
%i[post put].each do |method|
|
|
176
|
-
expect(mock_access_token).to receive(method).with('/path?any_param=toto&oauth_token=', '',
|
|
177
|
+
expect(mock_access_token).to receive(method).with('/path?any_param=toto&oauth_token=', '',
|
|
178
|
+
headers).and_return(response)
|
|
177
179
|
oauth__2legged_client.make_request(method, '/path?any_param=toto', '', headers)
|
|
178
180
|
end
|
|
179
181
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe JIRA::RequestClient do
|
|
4
|
-
let(:request_client) {
|
|
4
|
+
let(:request_client) { described_class.new }
|
|
5
5
|
|
|
6
6
|
describe '#request' do
|
|
7
7
|
subject(:request) { request_client.request(:get, '/foo', '', {}) }
|
|
@@ -15,7 +15,7 @@ describe JIRA::RequestClient do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it 'raises an exception' do
|
|
18
|
-
expect{ subject }.to raise_exception(JIRA::HTTPError)
|
|
18
|
+
expect { subject }.to raise_exception(JIRA::HTTPError)
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -34,8 +34,8 @@ describe JIRA::RequestClient do
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it 'raises an exception' do
|
|
37
|
-
expect{ subject }.to raise_exception(JIRA::HTTPError)
|
|
37
|
+
expect { subject }.to raise_exception(JIRA::HTTPError)
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
|
-
end
|
|
41
|
+
end
|
|
@@ -9,34 +9,34 @@ describe JIRA::Resource::Agile do
|
|
|
9
9
|
let(:response) { double }
|
|
10
10
|
|
|
11
11
|
describe '#all' do
|
|
12
|
-
it '
|
|
12
|
+
it 'queries url without parameters' do
|
|
13
13
|
expect(client).to receive(:get).with('/jira/rest/agile/1.0/board').and_return(response)
|
|
14
14
|
expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
described_class.all(client)
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
describe '#get_backlog_issues' do
|
|
21
|
-
it '
|
|
21
|
+
it 'queries the url without parameters' do
|
|
22
22
|
expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/backlog?maxResults=100').and_return(response)
|
|
23
23
|
expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
described_class.get_backlog_issues(client, 1)
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
describe '#get_board_issues' do
|
|
30
|
-
it '
|
|
30
|
+
it 'queries correct url without parameters' do
|
|
31
31
|
expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/issue?').and_return(response)
|
|
32
32
|
expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))
|
|
33
33
|
|
|
34
34
|
expect(client).to receive(:get).with('/jira/rest/api/2/search?jql=id+IN%2810546%2C+10547%2C+10556%2C+10557%2C+10558%2C+10559%2C+10600%2C+10601%2C+10604%29').and_return(response)
|
|
35
35
|
expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))
|
|
36
36
|
|
|
37
|
-
issues =
|
|
37
|
+
issues = described_class.get_board_issues(client, 1)
|
|
38
38
|
expect(issues).to be_an(Array)
|
|
39
|
-
expect(issues.size).to
|
|
39
|
+
expect(issues.size).to be(9)
|
|
40
40
|
|
|
41
41
|
issues.each do |issue|
|
|
42
42
|
expect(issue.class).to eq(JIRA::Resource::Issue)
|
|
@@ -44,16 +44,16 @@ describe JIRA::Resource::Agile do
|
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
it '
|
|
47
|
+
it 'queries correct url with parameters' do
|
|
48
48
|
expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/issue?startAt=50').and_return(response)
|
|
49
49
|
expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))
|
|
50
50
|
|
|
51
51
|
expect(client).to receive(:get).with('/jira/rest/api/2/search?jql=id+IN%2810546%2C+10547%2C+10556%2C+10557%2C+10558%2C+10559%2C+10600%2C+10601%2C+10604%29').and_return(response)
|
|
52
52
|
expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))
|
|
53
53
|
|
|
54
|
-
issues =
|
|
54
|
+
issues = described_class.get_board_issues(client, 1, startAt: 50)
|
|
55
55
|
expect(issues).to be_an(Array)
|
|
56
|
-
expect(issues.size).to
|
|
56
|
+
expect(issues.size).to be(9)
|
|
57
57
|
|
|
58
58
|
issues.each do |issue|
|
|
59
59
|
expect(issue.class).to eq(JIRA::Resource::Issue)
|
|
@@ -63,73 +63,73 @@ describe JIRA::Resource::Agile do
|
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
describe '#get_sprints' do
|
|
66
|
-
it '
|
|
66
|
+
it 'queries correct url without parameters' do
|
|
67
67
|
expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?maxResults=100').and_return(response)
|
|
68
68
|
expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
described_class.get_sprints(client, 1)
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
it '
|
|
73
|
+
it 'queries correct url with parameters' do
|
|
74
74
|
expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?startAt=50&maxResults=100').and_return(response)
|
|
75
75
|
expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
described_class.get_sprints(client, 1, startAt: 50)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
it '
|
|
80
|
+
it 'works with pagination starting at 0' do
|
|
81
81
|
expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?maxResults=1&startAt=0').and_return(response)
|
|
82
82
|
expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
described_class.get_sprints(client, 1, maxResults: 1, startAt: 0)
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
it '
|
|
87
|
+
it 'works with pagination not starting at 0' do
|
|
88
88
|
expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?maxResults=1&startAt=1').and_return(response)
|
|
89
89
|
expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
described_class.get_sprints(client, 1, maxResults: 1, startAt: 1)
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
describe '#get_sprint_issues' do
|
|
96
|
-
it '
|
|
96
|
+
it 'queries correct url without parameters' do
|
|
97
97
|
expect(client).to receive(:get).with('/jira/rest/agile/1.0/sprint/1/issue?maxResults=100').and_return(response)
|
|
98
98
|
expect(response).to receive(:body).and_return(get_mock_response('sprint/1_issues.json'))
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
described_class.get_sprint_issues(client, 1)
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
it '
|
|
103
|
+
it 'queries correct url with parameters' do
|
|
104
104
|
expect(client).to receive(:get).with('/jira/rest/agile/1.0/sprint/1/issue?startAt=50&maxResults=100').and_return(response)
|
|
105
105
|
expect(response).to receive(:body).and_return(get_mock_response('sprint/1_issues.json'))
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
described_class.get_sprint_issues(client, 1, startAt: 50)
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
describe '#get_projects_full' do
|
|
112
|
-
it '
|
|
112
|
+
it 'queries correct url without parameters' do
|
|
113
113
|
expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/project/full').and_return(response)
|
|
114
114
|
expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
described_class.get_projects_full(client, 1)
|
|
117
117
|
end
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
describe '#get_projects' do
|
|
121
|
-
it '
|
|
121
|
+
it 'queries correct url without parameters' do
|
|
122
122
|
expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/project?maxResults=100').and_return(response)
|
|
123
123
|
expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
described_class.get_projects(client, 1)
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
-
it '
|
|
128
|
+
it 'queries correct url with parameters' do
|
|
129
129
|
expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/project?startAt=50&maxResults=100').and_return(response)
|
|
130
130
|
expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
described_class.get_projects(client, 1, startAt: 50)
|
|
133
133
|
end
|
|
134
134
|
end
|
|
135
135
|
end
|