jira-ruby 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/jira-ruby.gemspec +2 -2
- data/lib/jira/client.rb +6 -1
- data/lib/jira/http_client.rb +5 -0
- data/lib/jira/railtie.rb +1 -1
- data/lib/jira/resource/issue.rb +3 -0
- data/lib/jira/version.rb +1 -1
- data/spec/jira/client_spec.rb +36 -1
- data/spec/jira/resource/field_spec.rb +1 -42
- data/spec/jira/resource/issue_spec.rb +12 -0
- metadata +7 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d616cf8d52b0dff3a17a4381b03160eef8e15755
|
4
|
+
data.tar.gz: 7823abec7764565a45a94d061d6f19d1e164b227
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c35b0d388f24a4e17afb24f4d7a96e21374f4548a672d007c262e3856f8f442d1d56f48fd3eee96eb1b84580022b014cff7f280143a6dd442ea58b9e3e102b5
|
7
|
+
data.tar.gz: 72dce2f225e83b9adc8f1e9fe3951ab464439ec90e0cd899df9f353515089c4b6600318e477006504528cbacf755d0ca556065d324ab266fc62d70c1f3242f8a
|
data/jira-ruby.gemspec
CHANGED
@@ -20,10 +20,10 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
# Rubtime Dependencies
|
22
22
|
s.add_runtime_dependency 'oauth', '~> 0.5', '>= 0.5.0'
|
23
|
-
s.add_runtime_dependency 'activesupport'
|
23
|
+
s.add_runtime_dependency 'activesupport'
|
24
24
|
|
25
25
|
# Development Dependencies
|
26
|
-
s.add_development_dependency 'railties'
|
26
|
+
s.add_development_dependency 'railties'
|
27
27
|
s.add_development_dependency 'webmock', '~> 1.18', '>= 1.18.0'
|
28
28
|
s.add_development_dependency 'rspec', '~> 3.0', '>= 3.0.0'
|
29
29
|
s.add_development_dependency 'rake', '~> 10.3', '>= 10.3.2'
|
data/lib/jira/client.rb
CHANGED
@@ -66,8 +66,13 @@ module JIRA
|
|
66
66
|
@consumer = @request_client.consumer
|
67
67
|
when :basic
|
68
68
|
@request_client = HttpClient.new(@options)
|
69
|
+
when :cookie
|
70
|
+
raise ArgumentError, 'Options: :use_cookies must be true for :cookie authorization type' if @options.key?(:use_cookies) && !@options[:use_cookies]
|
71
|
+
@options[:use_cookies] = true
|
72
|
+
@request_client = HttpClient.new(@options)
|
73
|
+
@request_client.make_cookie_auth_request
|
69
74
|
else
|
70
|
-
raise ArgumentError, 'Options: ":auth_type" must be ":oauth" or ":basic"'
|
75
|
+
raise ArgumentError, 'Options: ":auth_type" must be ":oauth", ":cookie" or ":basic"'
|
71
76
|
end
|
72
77
|
|
73
78
|
@http_debug = @options[:http_debug]
|
data/lib/jira/http_client.rb
CHANGED
@@ -17,6 +17,11 @@ module JIRA
|
|
17
17
|
@cookies = {}
|
18
18
|
end
|
19
19
|
|
20
|
+
def make_cookie_auth_request
|
21
|
+
body = { :username => @options[:username], :password => @options[:password] }.to_json
|
22
|
+
make_request(:post, '/rest/auth/1/session', body, {'Content-Type' => 'application/json'})
|
23
|
+
end
|
24
|
+
|
20
25
|
def make_request(http_method, path, body='', headers={})
|
21
26
|
request = Net::HTTP.const_get(http_method.to_s.capitalize).new(path, headers)
|
22
27
|
request.body = body unless body.nil?
|
data/lib/jira/railtie.rb
CHANGED
data/lib/jira/resource/issue.rb
CHANGED
data/lib/jira/version.rb
CHANGED
data/spec/jira/client_spec.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::Client do
|
4
|
+
before(:each) do
|
5
|
+
stub_request(:post, "https://foo:bar@localhost:2990/rest/auth/1/session").
|
6
|
+
to_return(:status => 200, :body => "", :headers => {})
|
7
|
+
end
|
4
8
|
|
5
9
|
let(:oauth_client) do
|
6
10
|
JIRA::Client.new({ :consumer_key => 'foo', :consumer_secret => 'bar' })
|
@@ -10,7 +14,11 @@ describe JIRA::Client do
|
|
10
14
|
JIRA::Client.new({ :username => 'foo', :password => 'bar', :auth_type => :basic })
|
11
15
|
end
|
12
16
|
|
13
|
-
let(:
|
17
|
+
let(:cookie_client) do
|
18
|
+
JIRA::Client.new({ :username => 'foo', :password => 'bar', :auth_type => :cookie })
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:clients) { [oauth_client, basic_client, cookie_client] }
|
14
22
|
|
15
23
|
let(:response) do
|
16
24
|
response = double("response")
|
@@ -54,11 +62,13 @@ describe JIRA::Client do
|
|
54
62
|
specify "that are of the correct class" do
|
55
63
|
expect(oauth_client.request_client.class).to eq(JIRA::OauthClient)
|
56
64
|
expect(basic_client.request_client.class).to eq(JIRA::HttpClient)
|
65
|
+
expect(cookie_client.request_client.class).to eq(JIRA::HttpClient)
|
57
66
|
end
|
58
67
|
|
59
68
|
specify "which have a corresponding auth type option" do
|
60
69
|
expect(oauth_client.options[:auth_type]).to eq(:oauth)
|
61
70
|
expect(basic_client.options[:auth_type]).to eq(:basic)
|
71
|
+
expect(cookie_client.options[:auth_type]).to eq(:cookie)
|
62
72
|
end
|
63
73
|
|
64
74
|
describe "like oauth" do
|
@@ -93,8 +103,12 @@ describe JIRA::Client do
|
|
93
103
|
it "sets the username and password" do
|
94
104
|
expect(basic_client.options[:username]).to eq('foo')
|
95
105
|
expect(basic_client.options[:password]).to eq('bar')
|
106
|
+
|
107
|
+
expect(cookie_client.options[:username]).to eq('foo')
|
108
|
+
expect(cookie_client.options[:password]).to eq('bar')
|
96
109
|
end
|
97
110
|
end
|
111
|
+
|
98
112
|
end
|
99
113
|
|
100
114
|
describe "has http methods" do
|
@@ -106,23 +120,28 @@ describe JIRA::Client do
|
|
106
120
|
# stubbed response for generic client request method
|
107
121
|
expect(oauth_client).to receive(:request).exactly(5).times.and_return(response)
|
108
122
|
expect(basic_client).to receive(:request).exactly(5).times.and_return(response)
|
123
|
+
expect(cookie_client).to receive(:request).exactly(5).times.and_return(response)
|
109
124
|
|
110
125
|
# response for merging headers for http methods with no body
|
111
126
|
expect(oauth_client).to receive(:merge_default_headers).exactly(3).times.with({})
|
112
127
|
expect(basic_client).to receive(:merge_default_headers).exactly(3).times.with({})
|
128
|
+
expect(cookie_client).to receive(:merge_default_headers).exactly(3).times.with({})
|
113
129
|
|
114
130
|
# response for merging headers for http methods with body
|
115
131
|
expect(oauth_client).to receive(:merge_default_headers).exactly(2).times.with(content_type_header)
|
116
132
|
expect(basic_client).to receive(:merge_default_headers).exactly(2).times.with(content_type_header)
|
133
|
+
expect(cookie_client).to receive(:merge_default_headers).exactly(2).times.with(content_type_header)
|
117
134
|
|
118
135
|
[:delete, :get, :head].each do |method|
|
119
136
|
oauth_client.send(method, '/path', {})
|
120
137
|
basic_client.send(method, '/path', {})
|
138
|
+
cookie_client.send(method, '/path', {})
|
121
139
|
end
|
122
140
|
|
123
141
|
[:post, :put].each do |method|
|
124
142
|
oauth_client.send(method, '/path', '', content_type_header)
|
125
143
|
basic_client.send(method, '/path', '', content_type_header)
|
144
|
+
cookie_client.send(method, '/path', '', content_type_header)
|
126
145
|
end
|
127
146
|
end
|
128
147
|
|
@@ -130,15 +149,19 @@ describe JIRA::Client do
|
|
130
149
|
[:delete, :get, :head].each do |method|
|
131
150
|
expect(oauth_client).to receive(:request).with(method, '/path', nil, headers).and_return(response)
|
132
151
|
expect(basic_client).to receive(:request).with(method, '/path', nil, headers).and_return(response)
|
152
|
+
expect(cookie_client).to receive(:request).with(method, '/path', nil, headers).and_return(response)
|
133
153
|
oauth_client.send(method, '/path', {})
|
134
154
|
basic_client.send(method, '/path', {})
|
155
|
+
cookie_client.send(method, '/path', {})
|
135
156
|
end
|
136
157
|
|
137
158
|
[:post, :put].each do |method|
|
138
159
|
expect(oauth_client).to receive(:request).with(method, '/path', '', merged_headers)
|
139
160
|
expect(basic_client).to receive(:request).with(method, '/path', '', merged_headers)
|
161
|
+
expect(cookie_client).to receive(:request).with(method, '/path', '', merged_headers)
|
140
162
|
oauth_client.send(method, '/path', '', {})
|
141
163
|
basic_client.send(method, '/path', '', {})
|
164
|
+
cookie_client.send(method, '/path', '', {})
|
142
165
|
end
|
143
166
|
end
|
144
167
|
|
@@ -160,10 +183,16 @@ describe JIRA::Client do
|
|
160
183
|
[:delete, :get, :head].each do |method|
|
161
184
|
expect(basic_client.request_client).to receive(:make_request).with(method, '/path', nil, headers).and_return(response)
|
162
185
|
basic_client.send(method, '/path', headers)
|
186
|
+
|
187
|
+
expect(cookie_client.request_client).to receive(:make_request).with(method, '/path', nil, headers).and_return(response)
|
188
|
+
cookie_client.send(method, '/path', headers)
|
163
189
|
end
|
164
190
|
[:post, :put].each do |method|
|
165
191
|
expect(basic_client.request_client).to receive(:make_request).with(method, '/path', '', merged_headers).and_return(response)
|
166
192
|
basic_client.send(method, '/path', '', headers)
|
193
|
+
|
194
|
+
expect(cookie_client.request_client).to receive(:make_request).with(method, '/path', '', merged_headers).and_return(response)
|
195
|
+
cookie_client.send(method, '/path', '', headers)
|
167
196
|
end
|
168
197
|
end
|
169
198
|
end
|
@@ -173,16 +202,22 @@ describe JIRA::Client do
|
|
173
202
|
it "gets all projects" do
|
174
203
|
expect(JIRA::Resource::Project).to receive(:all).with(oauth_client).and_return([])
|
175
204
|
expect(JIRA::Resource::Project).to receive(:all).with(basic_client).and_return([])
|
205
|
+
expect(JIRA::Resource::Project).to receive(:all).with(cookie_client).and_return([])
|
206
|
+
|
176
207
|
expect(oauth_client.Project.all).to eq([])
|
177
208
|
expect(basic_client.Project.all).to eq([])
|
209
|
+
expect(cookie_client.Project.all).to eq([])
|
178
210
|
end
|
179
211
|
|
180
212
|
it "finds a single project" do
|
181
213
|
find_result = double()
|
182
214
|
expect(JIRA::Resource::Project).to receive(:find).with(oauth_client, '123').and_return(find_result)
|
183
215
|
expect(JIRA::Resource::Project).to receive(:find).with(basic_client, '123').and_return(find_result)
|
216
|
+
expect(JIRA::Resource::Project).to receive(:find).with(cookie_client, '123').and_return(find_result)
|
217
|
+
|
184
218
|
expect(oauth_client.Project.find('123')).to eq(find_result)
|
185
219
|
expect(basic_client.Project.find('123')).to eq(find_result)
|
220
|
+
expect(cookie_client.Project.find('123')).to eq(find_result)
|
186
221
|
end
|
187
222
|
end
|
188
223
|
end
|
@@ -13,7 +13,7 @@ describe JIRA::Resource::Field do
|
|
13
13
|
allow(client.Field).to receive(:all).and_return([
|
14
14
|
JIRA::Resource::Field.new(client, :attrs => {'id' =>"customfield_10666", "name" => "Priority", "custom" => true, "orderable" => true, "navigable" => true, "searchable" => true, "clauseNames" => ["cf[10666]","Priority"], "schema" =>{"type" => "string", "custom" => "com.atlassian.jira.plugin.system.customfieldtypes:select","customId" => 10666}}),
|
15
15
|
JIRA::Resource::Field.new(client, :attrs => {'id' =>"issuekey", "name" => "Key", "custom" => false, "orderable" => false, "navigable" => true, "searchable" => false, "clauseNames" => ["id","issue","issuekey","key"]}),
|
16
|
-
JIRA::Resource::Field.new(client, :attrs => {
|
16
|
+
JIRA::Resource::Field.new(client, :attrs => {'id' =>"priority", "name" => "Priority", "custom" => false, "orderable" => true, "navigable" => true, "searchable" => true, "clauseNames" => ["priority"], "schema" =>{"type" => "priority", "system" => "priority"}}),
|
17
17
|
JIRA::Resource::Field.new(client, :attrs => {'id' =>"summary", "name" => "Summary", "custom" => false, "orderable" => true, "navigable" => true, "searchable" => true, "clauseNames" => ["summary"], "schema" =>{"type" => "string", "system" => "summary"}}),
|
18
18
|
JIRA::Resource::Field.new(client, :attrs => {'id' =>"issuetype", "name" => "Issue Type", "custom" => false, "orderable" => true, "navigable" => true, "searchable" => true, "clauseNames" => ["issuetype","type"], "schema" =>{"type" => "issuetype", "system" => "issuetype"}}),
|
19
19
|
JIRA::Resource::Field.new(client, :attrs => {'id' =>"customfield_10111", "name" => "SingleWord", "custom" => true, "orderable" => true, "navigable" => true, "searchable" => true, "clauseNames" => ["cf[10111]","SingleWord"], "schema" =>{"type" => "string", "custom" => "com.atlassian.jira.plugin.system.customfieldtypes:select","customId" => 10111}}),
|
@@ -70,10 +70,6 @@ describe JIRA::Resource::Field do
|
|
70
70
|
expect(subject.customfield_10111).to eq('data_in_custom_field')
|
71
71
|
end
|
72
72
|
|
73
|
-
it "cannot find a mapped field before mapping and raises error" do
|
74
|
-
expect{subject.SingleWork}.to raise_error(NoMethodError)
|
75
|
-
end
|
76
|
-
|
77
73
|
it "is not confused by common attribute keys and raises error" do
|
78
74
|
expect{subject.name}.to raise_error(NoMethodError)
|
79
75
|
expect{subject.custom}.to raise_error(NoMethodError)
|
@@ -83,12 +79,6 @@ describe JIRA::Resource::Field do
|
|
83
79
|
|
84
80
|
context "after fields are mapped" do
|
85
81
|
|
86
|
-
before do
|
87
|
-
silence_stream(STDERR) do
|
88
|
-
expect(client.Field.map_fields.class).to eq(Hash)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
82
|
include_context "mapped or not"
|
93
83
|
|
94
84
|
it "warns of duplicate fields" do
|
@@ -96,37 +86,6 @@ describe JIRA::Resource::Field do
|
|
96
86
|
expect{client.Field.map_fields}.to output(/renaming as SingleWord_10444/).to_stderr
|
97
87
|
end
|
98
88
|
|
99
|
-
it "can find a mapped field after mapping and returns results" do
|
100
|
-
expect{subject.SingleWord}.to_not raise_error
|
101
|
-
expect(subject.SingleWord).to eq subject.customfield_10111
|
102
|
-
end
|
103
|
-
|
104
|
-
it "handles duplicate names in a safe fashion" do
|
105
|
-
expect{subject.Multi_Word}.to_not raise_error
|
106
|
-
expect(subject.Multi_Word).to eq subject.customfield_10222
|
107
|
-
end
|
108
|
-
|
109
|
-
it "handles special characters in a safe fashion" do
|
110
|
-
expect{subject.Why_N_t}.to_not raise_error
|
111
|
-
expect(subject.Why_N_t).to eq subject.customfield_10333
|
112
|
-
end
|
113
|
-
|
114
|
-
it "handles duplicates in custom names" do
|
115
|
-
expect{subject.SingleWord_10444}.to_not raise_error
|
116
|
-
expect(subject.SingleWord_10444).to eq subject.customfield_10444
|
117
|
-
end
|
118
|
-
|
119
|
-
it "keeps custom names from overwriting system names" do
|
120
|
-
#expect(client.Field.map_fields.class).to eq(Hash)
|
121
|
-
expect{subject.Priority_10666}.to_not raise_error
|
122
|
-
expect(subject.Priority_10666).to eq subject.customfield_10666
|
123
|
-
end
|
124
|
-
|
125
|
-
it "can find a standard field by an expanded name" do
|
126
|
-
#expect(client.Field.map_fields.class).to eq(Hash)
|
127
|
-
expect(subject.priority).to eq(1)
|
128
|
-
expect(subject.Priority).to eq(1)
|
129
|
-
end
|
130
89
|
end
|
131
90
|
end
|
132
91
|
end
|
@@ -105,6 +105,18 @@ describe JIRA::Resource::Issue do
|
|
105
105
|
expect(JIRA::Resource::Issue.jql(client,'foo bar', start_at: 1, max_results: 3)).to eq([''])
|
106
106
|
end
|
107
107
|
|
108
|
+
it "should search an issue with a jql query string and maxResults equals zero and should return the count of tickets" do
|
109
|
+
response = double()
|
110
|
+
issue = double()
|
111
|
+
|
112
|
+
allow(response).to receive(:body).and_return('{"total": 1, "issues": []}')
|
113
|
+
expect(client).to receive(:get)
|
114
|
+
.with('/jira/rest/api/2/search?jql=foo+bar&maxResults=0')
|
115
|
+
.and_return(response)
|
116
|
+
|
117
|
+
expect(JIRA::Resource::Issue.jql(client,'foo bar', max_results: 0)).to eq(1)
|
118
|
+
end
|
119
|
+
|
108
120
|
it "should search an issue with a jql query string and string expand" do
|
109
121
|
response = double()
|
110
122
|
issue = double()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jira-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SUMO Heavy Industries
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06
|
11
|
+
date: 2016-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth
|
@@ -34,42 +34,30 @@ dependencies:
|
|
34
34
|
name: activesupport
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '4.2'
|
40
37
|
- - ">="
|
41
38
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
39
|
+
version: '0'
|
43
40
|
type: :runtime
|
44
41
|
prerelease: false
|
45
42
|
version_requirements: !ruby/object:Gem::Requirement
|
46
43
|
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '4.2'
|
50
44
|
- - ">="
|
51
45
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
46
|
+
version: '0'
|
53
47
|
- !ruby/object:Gem::Dependency
|
54
48
|
name: railties
|
55
49
|
requirement: !ruby/object:Gem::Requirement
|
56
50
|
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '4.2'
|
60
51
|
- - ">="
|
61
52
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
53
|
+
version: '0'
|
63
54
|
type: :development
|
64
55
|
prerelease: false
|
65
56
|
version_requirements: !ruby/object:Gem::Requirement
|
66
57
|
requirements:
|
67
|
-
- - "~>"
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '4.2'
|
70
58
|
- - ">="
|
71
59
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
60
|
+
version: '0'
|
73
61
|
- !ruby/object:Gem::Dependency
|
74
62
|
name: webmock
|
75
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -353,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
353
341
|
version: '0'
|
354
342
|
requirements: []
|
355
343
|
rubyforge_project: jira-ruby
|
356
|
-
rubygems_version: 2.
|
344
|
+
rubygems_version: 2.6.4
|
357
345
|
signing_key:
|
358
346
|
specification_version: 4
|
359
347
|
summary: Ruby Gem for use with the Atlassian JIRA REST API
|