jira-ruby 3.0.0.beta1 → 3.0.0.beta2
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/workflows/CI.yml +1 -0
- data/.github/workflows/codeql.yml +0 -4
- data/.gitignore +3 -1
- data/.rubocop.yml +1 -69
- data/.yardopts +4 -0
- data/lib/jira/base.rb +5 -13
- data/lib/jira/client.rb +59 -4
- data/lib/jira/has_many_proxy.rb +30 -28
- data/lib/jira/http_client.rb +64 -1
- data/lib/jira/oauth_client.rb +62 -0
- data/lib/jira/request_client.rb +26 -1
- data/lib/jira/resource/attachment.rb +88 -3
- data/lib/jira/resource/field.rb +4 -8
- data/lib/jira/resource/issue.rb +64 -4
- data/lib/jira/resource/issue_picker_suggestions.rb +1 -1
- data/lib/jira/resource/issuelink.rb +4 -3
- data/lib/jira/resource/watcher.rb +1 -1
- data/lib/jira/resource/webhook.rb +5 -1
- data/lib/jira/version.rb +1 -1
- data/lib/tasks/generate.rake +1 -1
- data/spec/integration/project_spec.rb +1 -1
- data/spec/integration/rapidview_spec.rb +1 -1
- data/spec/integration/user_spec.rb +12 -3
- data/spec/integration/watcher_spec.rb +6 -2
- data/spec/integration/{webhook.rb → webhook_spec.rb} +8 -1
- data/spec/jira/base_factory_spec.rb +11 -2
- data/spec/jira/base_spec.rb +80 -57
- data/spec/jira/client_spec.rb +20 -18
- data/spec/jira/http_client_spec.rb +2 -2
- data/spec/jira/oauth_client_spec.rb +8 -4
- data/spec/jira/resource/agile_spec.rb +2 -2
- data/spec/jira/resource/attachment_spec.rb +36 -13
- data/spec/jira/resource/board_spec.rb +5 -5
- data/spec/jira/resource/field_spec.rb +23 -24
- data/spec/jira/resource/issue_spec.rb +18 -18
- data/spec/jira/resource/project_spec.rb +6 -6
- data/spec/jira/resource/sprint_spec.rb +20 -8
- data/spec/jira/resource/status_spec.rb +1 -1
- data/spec/jira/resource/user_factory_spec.rb +2 -2
- data/spec/jira/resource/worklog_spec.rb +1 -1
- data/spec/support/clients_helper.rb +2 -2
- data/spec/support/mock_client.rb +9 -0
- data/spec/support/mock_response.rb +8 -0
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 433679cf875ed954de485aea9bf822e89fe31a03455ea4c42feb6ccd09b625f4
|
4
|
+
data.tar.gz: f76496cfd565688dd0297579ee63398969770537c3507caa84e2b03ae4a9babe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b4c890643c64efc50bc67e80d9583aeff780cceeef08264cefc2a5b9efca858f5b622dfba366c7a7bfbc1c5ffbd9e34d9abb460f5bb10dc7ad39ef5717d2566
|
7
|
+
data.tar.gz: 4b8c10a1873d6aabe8be992c10df1a743d0701db5a96a4306cf0082f6adb3bf9e55f1e08b518bf0aa93f4eb3cf25e431bb778de59cd70ec07319e8ad206c1d49
|
data/.github/workflows/CI.yml
CHANGED
@@ -16,14 +16,10 @@ on:
|
|
16
16
|
branches: [ "master" ]
|
17
17
|
paths-ignore:
|
18
18
|
- '**/*.md'
|
19
|
-
- 'http-basic-example.rb'
|
20
|
-
- 'example.rb'
|
21
19
|
pull_request:
|
22
20
|
branches: [ "master" ]
|
23
21
|
paths-ignore:
|
24
22
|
- '**/*.md'
|
25
|
-
- 'http-basic-example.rb'
|
26
|
-
- 'example.rb'
|
27
23
|
schedule:
|
28
24
|
- cron: '0 13 * * *'
|
29
25
|
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
|
1
|
+
plugins:
|
2
2
|
- rubocop-rspec
|
3
3
|
|
4
4
|
AllCops:
|
5
5
|
Exclude:
|
6
|
-
- 'example.rb'
|
7
|
-
- 'http-basic-example.rb'
|
8
6
|
- 'vendor/**/*'
|
9
7
|
NewCops: enable
|
10
8
|
TargetRubyVersion: 3.1
|
@@ -28,18 +26,6 @@ Style/FrozenStringLiteralComment:
|
|
28
26
|
#
|
29
27
|
# We are going to disable these and fix in pull requests
|
30
28
|
##
|
31
|
-
Layout/ClosingHeredocIndentation:
|
32
|
-
Enabled: false
|
33
|
-
|
34
|
-
Layout/EmptyLineAfterGuardClause:
|
35
|
-
Enabled: false
|
36
|
-
|
37
|
-
Layout/EmptyLinesAroundMethodBody:
|
38
|
-
Enabled: false
|
39
|
-
|
40
|
-
Layout/HashAlignment:
|
41
|
-
Enabled: false
|
42
|
-
|
43
29
|
Layout/LineLength:
|
44
30
|
Enabled: false
|
45
31
|
|
@@ -55,12 +41,6 @@ Lint/IneffectiveAccessModifier:
|
|
55
41
|
Lint/MissingSuper:
|
56
42
|
Enabled: false
|
57
43
|
|
58
|
-
Lint/RedundantCopDisableDirective:
|
59
|
-
Enabled: false
|
60
|
-
|
61
|
-
Lint/UselessAssignment:
|
62
|
-
Enabled: false
|
63
|
-
|
64
44
|
Metrics/AbcSize:
|
65
45
|
Enabled: false
|
66
46
|
|
@@ -79,9 +59,6 @@ Metrics/PerceivedComplexity:
|
|
79
59
|
Naming/AccessorMethodName:
|
80
60
|
Enabled: false
|
81
61
|
|
82
|
-
Naming/BlockForwarding:
|
83
|
-
Enabled: false
|
84
|
-
|
85
62
|
Naming/HeredocDelimiterNaming:
|
86
63
|
Enabled: false
|
87
64
|
|
@@ -91,15 +68,6 @@ Naming/PredicateName:
|
|
91
68
|
Naming/VariableNumber:
|
92
69
|
Enabled: false
|
93
70
|
|
94
|
-
RSpec/AnyInstance:
|
95
|
-
Enabled: false
|
96
|
-
|
97
|
-
RSpec/BeEq:
|
98
|
-
Enabled: false
|
99
|
-
|
100
|
-
RSpec/ContextWording:
|
101
|
-
Enabled: false
|
102
|
-
|
103
71
|
RSpec/ExampleLength:
|
104
72
|
Enabled: false
|
105
73
|
|
@@ -115,9 +83,6 @@ RSpec/InstanceVariable:
|
|
115
83
|
RSpec/LeakyConstantDeclaration:
|
116
84
|
Enabled: false
|
117
85
|
|
118
|
-
RSpec/MessageChain:
|
119
|
-
Enabled: false
|
120
|
-
|
121
86
|
RSpec/MessageSpies:
|
122
87
|
Enabled: false
|
123
88
|
|
@@ -133,56 +98,23 @@ RSpec/NamedSubject:
|
|
133
98
|
RSpec/NestedGroups:
|
134
99
|
Enabled: false
|
135
100
|
|
136
|
-
RSpec/NoExpectationExample:
|
137
|
-
Enabled: false
|
138
|
-
|
139
|
-
RSpec/PredicateMatcher:
|
140
|
-
Enabled: false
|
141
|
-
|
142
101
|
RSpec/ReceiveMessages:
|
143
102
|
Enabled: false
|
144
103
|
|
145
|
-
RSpec/RepeatedSubjectCall:
|
146
|
-
Enabled: false
|
147
|
-
|
148
104
|
RSpec/SpecFilePathFormat:
|
149
105
|
Enabled: false
|
150
106
|
|
151
|
-
RSpec/SpecFilePathSuffix:
|
152
|
-
Enabled: false
|
153
|
-
|
154
107
|
RSpec/StubbedMock:
|
155
108
|
Enabled: false
|
156
109
|
|
157
110
|
RSpec/SubjectStub:
|
158
111
|
Enabled: false
|
159
112
|
|
160
|
-
RSpec/VerifiedDoubleReference:
|
161
|
-
Enabled: false
|
162
|
-
|
163
113
|
RSpec/VerifiedDoubles:
|
164
114
|
Enabled: false
|
165
115
|
|
166
|
-
Security/Open:
|
167
|
-
Enabled: false
|
168
|
-
|
169
|
-
Style/ArgumentsForwarding:
|
170
|
-
Enabled: false
|
171
|
-
|
172
|
-
Style/CaseEquality:
|
173
|
-
Enabled: false
|
174
|
-
|
175
|
-
Style/ClassAndModuleChildren:
|
176
|
-
Enabled: false
|
177
|
-
|
178
116
|
Style/MissingRespondToMissing:
|
179
117
|
Enabled: false
|
180
118
|
|
181
|
-
Style/OpenStructUse:
|
182
|
-
Enabled: false
|
183
|
-
|
184
119
|
Style/OptionalBooleanParameter:
|
185
120
|
Enabled: false
|
186
|
-
|
187
|
-
Style/SymbolProc:
|
188
|
-
Enabled: false
|
data/.yardopts
ADDED
data/lib/jira/base.rb
CHANGED
@@ -291,11 +291,7 @@ module JIRA
|
|
291
291
|
# and returns true when found, otherwise proxies the
|
292
292
|
# call to the superclass.
|
293
293
|
def respond_to?(method_name, _include_all = false)
|
294
|
-
|
295
|
-
true
|
296
|
-
else
|
297
|
-
super(method_name)
|
298
|
-
end
|
294
|
+
attrs.key?(method_name.to_s) || super(method_name)
|
299
295
|
end
|
300
296
|
|
301
297
|
# Overrides method_missing to check the attribute hash
|
@@ -366,7 +362,7 @@ module JIRA
|
|
366
362
|
rescue JIRA::HTTPError => e
|
367
363
|
begin
|
368
364
|
set_attrs_from_response(e.response) # Merge error status generated by JIRA REST API
|
369
|
-
rescue JSON::ParserError
|
365
|
+
rescue JSON::ParserError
|
370
366
|
set_attrs('exception' => {
|
371
367
|
'class' => e.response.class.name,
|
372
368
|
'code' => e.response.code,
|
@@ -383,9 +379,9 @@ module JIRA
|
|
383
379
|
# not nil or is not a json response.
|
384
380
|
def set_attrs_from_response(response)
|
385
381
|
return if response.body.nil? || (response.body.length < 2)
|
382
|
+
|
386
383
|
json = self.class.parse_json(response.body)
|
387
384
|
set_attrs(json)
|
388
|
-
|
389
385
|
end
|
390
386
|
|
391
387
|
# Set the current attributes from a hash. If clobber is true, any existing
|
@@ -520,15 +516,11 @@ module JIRA
|
|
520
516
|
end
|
521
517
|
|
522
518
|
def self.query_params_for_single_fetch(options)
|
523
|
-
options.
|
524
|
-
QUERY_PARAMS_FOR_SINGLE_FETCH.include? k
|
525
|
-
end.to_h
|
519
|
+
options.slice(*QUERY_PARAMS_FOR_SINGLE_FETCH)
|
526
520
|
end
|
527
521
|
|
528
522
|
def self.query_params_for_search(options)
|
529
|
-
options.
|
530
|
-
QUERY_PARAMS_FOR_SEARCH.include? k
|
531
|
-
end.to_h
|
523
|
+
options.slice(*QUERY_PARAMS_FOR_SEARCH)
|
532
524
|
end
|
533
525
|
end
|
534
526
|
end
|
data/lib/jira/client.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'json'
|
4
4
|
require 'forwardable'
|
5
|
-
require 'ostruct'
|
6
5
|
|
7
6
|
module JIRA
|
8
7
|
# This class is the main access point for all JIRA::Resource instances.
|
@@ -55,7 +54,7 @@ module JIRA
|
|
55
54
|
#
|
56
55
|
# The authenticated client instance returned by the respective client type
|
57
56
|
# (Oauth, Basic)
|
58
|
-
attr_accessor :consumer, :request_client, :http_debug, :
|
57
|
+
attr_accessor :consumer, :request_client, :http_debug, :field_map_cache
|
59
58
|
|
60
59
|
# The configuration options for this client instance
|
61
60
|
attr_reader :options
|
@@ -113,6 +112,23 @@ module JIRA
|
|
113
112
|
default_headers: {}
|
114
113
|
}.freeze
|
115
114
|
|
115
|
+
# Creates a new JIRA::Client instance
|
116
|
+
# @param [Hash] options The configuration options for the client
|
117
|
+
# @option options [Symbol] :auth_type The authentication type to use, :basic, :oauth, :oauth_2legged, or :cookie.
|
118
|
+
# @option options [String] :site The base URL for the JIRA instance
|
119
|
+
# @option options [Boolean] :use_ssl Whether to use HTTPS for requests
|
120
|
+
# @option options [Integer] :ssl_verify_mode The SSL verification mode OpenSSL::SSL::VERIFY_PEER or OpenSSL::SSL::VERIFY_NONE
|
121
|
+
# @option options [Hash] :default_headers Additional headers to send with each request
|
122
|
+
# @option options [String] :cert_path The path to the SSL certificate file to verify the server with
|
123
|
+
# @option options [String] :use_client_cert Whether to use a client certificate for authentication
|
124
|
+
# @option options [String] :ssl_client_cert The client certificate to use
|
125
|
+
# @option options [String] :ssl_client_key The client certificate key to use
|
126
|
+
# @option options [String] :proxy_address The address of the proxy server to use
|
127
|
+
# @option options [Integer] :proxy_port The port of the proxy server to use
|
128
|
+
# @option options [String] :proxy_username The username for the proxy server
|
129
|
+
# @option options [String] :proxy_password The password for the proxy server
|
130
|
+
# @return [JIRA::Client] The client instance
|
131
|
+
# @raise [ArgumentError] If an unknown option is given
|
116
132
|
def initialize(options = {})
|
117
133
|
options = DEFAULT_OPTIONS.merge(options)
|
118
134
|
@options = options
|
@@ -164,8 +180,6 @@ module JIRA
|
|
164
180
|
@http_debug = @options[:http_debug]
|
165
181
|
|
166
182
|
@options.freeze
|
167
|
-
|
168
|
-
@cache = OpenStruct.new
|
169
183
|
end
|
170
184
|
|
171
185
|
def Project # :nodoc:
|
@@ -289,29 +303,63 @@ module JIRA
|
|
289
303
|
end
|
290
304
|
|
291
305
|
# HTTP methods without a body
|
306
|
+
|
307
|
+
# Make an HTTP DELETE request
|
308
|
+
# @param [String] path The path to request
|
309
|
+
# @param [Hash] headers The headers to send with the request
|
310
|
+
# @return [Net::HTTPResponse] The response object
|
311
|
+
# @raise [JIRA::HTTPError] If the response is not an HTTP success code
|
292
312
|
def delete(path, headers = {})
|
293
313
|
request(:delete, path, nil, merge_default_headers(headers))
|
294
314
|
end
|
295
315
|
|
316
|
+
# Make an HTTP GET request
|
317
|
+
# @param [String] path The path to request
|
318
|
+
# @param [Hash] headers The headers to send with the request
|
319
|
+
# @return [Net::HTTPResponse] The response object
|
320
|
+
# @raise [JIRA::HTTPError] If the response is not an HTTP success code
|
296
321
|
def get(path, headers = {})
|
297
322
|
request(:get, path, nil, merge_default_headers(headers))
|
298
323
|
end
|
299
324
|
|
325
|
+
# Make an HTTP HEAD request
|
326
|
+
# @param [String] path The path to request
|
327
|
+
# @param [Hash] headers The headers to send with the request
|
328
|
+
# @return [Net::HTTPResponse] The response object
|
329
|
+
# @raise [JIRA::HTTPError] If the response is not an HTTP success code
|
300
330
|
def head(path, headers = {})
|
301
331
|
request(:head, path, nil, merge_default_headers(headers))
|
302
332
|
end
|
303
333
|
|
304
334
|
# HTTP methods with a body
|
335
|
+
|
336
|
+
# Make an HTTP POST request
|
337
|
+
# @param [String] path The path to request
|
338
|
+
# @param [String] body The body of the request
|
339
|
+
# @param [Hash] headers The headers to send with the request
|
340
|
+
# @return [Net::HTTPResponse] The response object
|
305
341
|
def post(path, body = '', headers = {})
|
306
342
|
headers = { 'Content-Type' => 'application/json' }.merge(headers)
|
307
343
|
request(:post, path, body, merge_default_headers(headers))
|
308
344
|
end
|
309
345
|
|
346
|
+
# Make an HTTP POST request with a file upload
|
347
|
+
# @param [String] path The path to request
|
348
|
+
# @param [String] file The file to upload
|
349
|
+
# @param [Hash] headers The headers to send with the request
|
350
|
+
# @return [Net::HTTPResponse] The response object
|
351
|
+
# @raise [JIRA::HTTPError] If the response is not an HTTP success code
|
310
352
|
def post_multipart(path, file, headers = {})
|
311
353
|
puts "post multipart: #{path} - [#{file}]" if @http_debug
|
312
354
|
@request_client.request_multipart(path, file, merge_default_headers(headers))
|
313
355
|
end
|
314
356
|
|
357
|
+
# Make an HTTP PUT request
|
358
|
+
# @param [String] path The path to request
|
359
|
+
# @param [String] body The body of the request
|
360
|
+
# @param [Hash] headers The headers to send with the request
|
361
|
+
# @return [Net::HTTPResponse] The response object
|
362
|
+
# @raise [JIRA::HTTPError] If the response is not an HTTP success code
|
315
363
|
def put(path, body = '', headers = {})
|
316
364
|
headers = { 'Content-Type' => 'application/json' }.merge(headers)
|
317
365
|
request(:put, path, body, merge_default_headers(headers))
|
@@ -319,11 +367,18 @@ module JIRA
|
|
319
367
|
|
320
368
|
# Sends the specified HTTP request to the REST API through the
|
321
369
|
# appropriate method (oauth, basic).
|
370
|
+
# @param [Symbol] http_method The HTTP method to use
|
371
|
+
# @param [String] path The path to request
|
372
|
+
# @param [String] body The body of the request
|
373
|
+
# @param [Hash] headers The headers to send with the request
|
374
|
+
# @return [Net::HTTPResponse] The response object
|
375
|
+
# @raise [JIRA::HTTPError] If the response is not an HTTP success code
|
322
376
|
def request(http_method, path, body = '', headers = {})
|
323
377
|
puts "#{http_method}: #{path} - [#{body}]" if @http_debug
|
324
378
|
@request_client.request(http_method, path, body, headers)
|
325
379
|
end
|
326
380
|
|
381
|
+
# @private
|
327
382
|
# Stops sensitive client information from being displayed in logs
|
328
383
|
def inspect
|
329
384
|
"#<JIRA::Client:#{object_id}>"
|
data/lib/jira/has_many_proxy.rb
CHANGED
@@ -8,37 +8,39 @@
|
|
8
8
|
#
|
9
9
|
# In practice, instances of this class behave exactly like an Array.
|
10
10
|
#
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
module JIRA
|
12
|
+
class HasManyProxy
|
13
|
+
attr_reader :target_class, :parent
|
14
|
+
attr_accessor :collection
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
def initialize(parent, target_class, collection = [])
|
17
|
+
@parent = parent
|
18
|
+
@target_class = target_class
|
19
|
+
@collection = collection
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
# Builds an instance of this class with the correct parent.
|
23
|
+
# For example, issue.comments.build(attrs) will initialize a
|
24
|
+
# comment as follows:
|
25
|
+
#
|
26
|
+
# JIRA::Resource::Comment.new(issue.client,
|
27
|
+
# :attrs => attrs,
|
28
|
+
# :issue => issue)
|
29
|
+
def build(attrs = {})
|
30
|
+
resource = target_class.new(parent.client, :attrs => attrs, parent.to_sym => parent)
|
31
|
+
collection << resource
|
32
|
+
resource
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
# Forces an HTTP request to fetch all instances of the target class that
|
36
|
+
# are associated with the parent
|
37
|
+
def all
|
38
|
+
target_class.all(parent.client, parent.to_sym => parent)
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
# Delegate any missing methods to the collection that this proxy wraps
|
42
|
+
def method_missing(method_name, ...)
|
43
|
+
collection.send(method_name, ...)
|
44
|
+
end
|
43
45
|
end
|
44
46
|
end
|
data/lib/jira/http_client.rb
CHANGED
@@ -6,14 +6,48 @@ require 'cgi/cookie'
|
|
6
6
|
require 'uri'
|
7
7
|
|
8
8
|
module JIRA
|
9
|
+
# Client using HTTP Basic Authentication
|
10
|
+
# @example Basic authentication
|
11
|
+
# options = {
|
12
|
+
# auth_type: :basic,
|
13
|
+
# site: "https://jira.example.com",
|
14
|
+
# use_ssl: true,
|
15
|
+
# ssl_verify_mode: OpenSSL::SSL::VERIFY_PEER,
|
16
|
+
# cert_path: '/usr/local/etc/trusted-certificates.pem',
|
17
|
+
# username: 'jamie',
|
18
|
+
# password: 'password'
|
19
|
+
# }
|
20
|
+
# client = JIRA::Client.new(options)
|
21
|
+
# @example Bearer token authentication
|
22
|
+
# options = {
|
23
|
+
# auth_type: :basic,
|
24
|
+
# site: "https://jira.example.com",
|
25
|
+
# default_headers: { 'authorization' => "Bearer #{bearer_token_str}" },
|
26
|
+
# use_ssl: true,
|
27
|
+
# ssl_verify_mode: OpenSSL::SSL::VERIFY_PEER
|
28
|
+
# cert_path: '/usr/local/etc/trusted-certificates.pem',
|
29
|
+
# }
|
30
|
+
# client = JIRA::Client.new(options)
|
9
31
|
class HttpClient < RequestClient
|
32
|
+
# @private
|
10
33
|
DEFAULT_OPTIONS = {
|
11
34
|
username: nil,
|
12
35
|
password: nil
|
13
36
|
}.freeze
|
14
37
|
|
38
|
+
# @!attribute [r] options
|
39
|
+
# @return [Hash] The client options
|
15
40
|
attr_reader :options
|
16
41
|
|
42
|
+
# Generally not used directly, but through JIRA::Client.
|
43
|
+
# See JIRA::Client for documentation.
|
44
|
+
# @param [Hash] options Options as passed from JIRA::Client constructor.
|
45
|
+
# @option options [String] :username The username to authenticate with
|
46
|
+
# @option options [String] :password The password to authenticate with
|
47
|
+
# @option options [Hash] :default_headers Additional headers for requests
|
48
|
+
# @option options [String] :proxy_uri Proxy URI
|
49
|
+
# @option options [String] :proxy_user Proxy user
|
50
|
+
# @option options [String] :proxy_password Proxy Password
|
17
51
|
def initialize(options)
|
18
52
|
@options = DEFAULT_OPTIONS.merge(options)
|
19
53
|
@cookies = {}
|
@@ -26,6 +60,18 @@ module JIRA
|
|
26
60
|
make_request(:post, "#{@options[:context_path]}/rest/auth/1/session", body, 'Content-Type' => 'application/json')
|
27
61
|
end
|
28
62
|
|
63
|
+
# Makes a request to the JIRA server.
|
64
|
+
#
|
65
|
+
# Generally you should not call this method directly, but use the helper methods in JIRA::Client.
|
66
|
+
#
|
67
|
+
# File uploads are not supported with this method. Use make_multipart_request instead.
|
68
|
+
#
|
69
|
+
# @param [Symbol] http_method The HTTP method to use
|
70
|
+
# @param [String] url The JIRA REST URL to call
|
71
|
+
# @param [String] body The request body
|
72
|
+
# @param [Hash] headers Additional headers to send with the request
|
73
|
+
# @return [Net::HTTPResponse] The response from the server
|
74
|
+
# @raise [JIRA::HTTPError] If the response is not an HTTP success code
|
29
75
|
def make_request(http_method, url, body = '', headers = {})
|
30
76
|
# When a proxy is enabled, Net::HTTP expects that the request path omits the domain name
|
31
77
|
path = request_path(url)
|
@@ -35,6 +81,17 @@ module JIRA
|
|
35
81
|
execute_request(request)
|
36
82
|
end
|
37
83
|
|
84
|
+
# Makes a multipart request to the JIRA server.
|
85
|
+
#
|
86
|
+
# This is used for file uploads.
|
87
|
+
#
|
88
|
+
# Generally you should not call this method directly, but use the helper methods in JIRA::Client.
|
89
|
+
#
|
90
|
+
# @param [String] url The JIRA REST URL to call
|
91
|
+
# @param [Hash] body The Net::HTTP::Post::Multipart data to send with the request
|
92
|
+
# @param [Hash] headers The headers to send with the request
|
93
|
+
# @return [Net::HTTPResponse] The response object
|
94
|
+
# @raise [JIRA::HTTPError] If the response is not an HTTP success code
|
38
95
|
def make_multipart_request(url, body, headers = {})
|
39
96
|
path = request_path(url)
|
40
97
|
request = Net::HTTP::Post::Multipart.new(path, body, headers)
|
@@ -42,10 +99,12 @@ module JIRA
|
|
42
99
|
execute_request(request)
|
43
100
|
end
|
44
101
|
|
102
|
+
# @private
|
45
103
|
def basic_auth_http_conn
|
46
104
|
http_conn(uri)
|
47
105
|
end
|
48
106
|
|
107
|
+
# @private
|
49
108
|
def http_conn(uri)
|
50
109
|
http_conn =
|
51
110
|
if @options[:proxy_address]
|
@@ -67,10 +126,14 @@ module JIRA
|
|
67
126
|
http_conn
|
68
127
|
end
|
69
128
|
|
129
|
+
# The URI of the JIRA REST API call
|
130
|
+
# @return [URI] The URI of the JIRA REST API call
|
70
131
|
def uri
|
71
132
|
URI.parse(@options[:site])
|
72
133
|
end
|
73
134
|
|
135
|
+
# Returns true if the client is authenticated.
|
136
|
+
# @return [Boolean] True if the client is authenticated
|
74
137
|
def authenticated?
|
75
138
|
@authenticated
|
76
139
|
end
|
@@ -99,12 +162,12 @@ module JIRA
|
|
99
162
|
def store_cookies(response)
|
100
163
|
cookies = response.get_fields('set-cookie')
|
101
164
|
return unless cookies
|
165
|
+
|
102
166
|
cookies.each do |cookie|
|
103
167
|
data = CGI::Cookie.parse(cookie)
|
104
168
|
data.delete('Path')
|
105
169
|
@cookies.merge!(data)
|
106
170
|
end
|
107
|
-
|
108
171
|
end
|
109
172
|
|
110
173
|
def add_cookies(request)
|