New Upstream Release - ruby-jira
Ready changes
Summary
Merged new upstream version: 2.3.0 (was: 2.1.5).
Resulting package
Built on 2023-03-30T21:40 (took 4m24s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-releases ruby-jira
Lintian Result
Diff
diff --git a/README.md b/README.md
index 66231eb..eb55f72 100644
--- a/README.md
+++ b/README.md
@@ -99,7 +99,7 @@ defaults to HTTP Basic Auth.
Jira supports cookie based authentication whereby user credentials are passed
to JIRA via a JIRA REST API call. This call returns a session cookie which must
-then be sent to all following JIRA REST API calls.
+then be sent to all following JIRA REST API calls.
To enable cookie based authentication, set `:auth_type` to `:cookie`,
set `:use_cookies` to `true` and set `:username` and `:password` accordingly.
@@ -114,7 +114,7 @@ options = {
:context_path => '',
:auth_type => :cookie, # Set cookie based authentication
:use_cookies => true, # Send cookies with each request
- :additional_cookies => ['AUTH=vV7uzixt0SScJKg7'] # Optional cookies to send
+ :additional_cookies => ['AUTH=vV7uzixt0SScJKg7'] # Optional cookies to send
# with each request
}
@@ -134,15 +134,40 @@ cookie to add to the request.
Some authentication schemes that require additional cookies ignore the username
and password sent in the JIRA REST API call. For those use cases, `:username`
-and `:password` may be omitted from `options`.
+and `:password` may be omitted from `options`.
+## Configuring JIRA to use Personal Access Tokens Auth
+If your JIRA system is configured to support Personal Access Token authorization, minor modifications are needed in how credentials are communicated to the server. Specifically, the paremeters `:username` and `:password` are not needed. Also, the parameter `:default_headers` is needed to contain the api_token, which can be obtained following the official documentation from [Atlassian](https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html). Please note that the Personal Access Token can only be used as it is. If it is encoded (with base64 or any other encoding method) then the token will not work correctly and authentication will fail.
+
+```ruby
+require 'jira-ruby'
+
+# NOTE: the token should not be encoded
+api_token = API_TOKEN_OBTAINED_FROM_JIRA_UI
+
+options = {
+ :site => 'http://mydomain.atlassian.net:443/',
+ :context_path => '',
+ :username => '<the email you sign-in to Jira>',
+ :password => api_token,
+ :auth_type => :basic
+}
+
+client = JIRA::Client.new(options)
+
+project = client.Project.find('SAMPLEPROJECT')
+
+project.issues.each do |issue|
+ puts "#{issue.id} - #{issue.summary}"
+end
+```
## Using the API Gem in a command line application
Using HTTP Basic Authentication, configure and connect a client to your instance
of JIRA.
Note: If your Jira install is hosted on [atlassian.net](atlassian.net), it will have no context
-path by default. If you're having issues connecting, try setting context_path
+path by default. If you're having issues connecting, try setting context_path
to an empty string in the options hash.
```ruby
diff --git a/Rakefile b/Rakefile
index 983806e..cdb06d6 100644
--- a/Rakefile
+++ b/Rakefile
@@ -14,13 +14,13 @@ desc 'Prepare and run rspec tests'
task :prepare do
rsa_key = File.expand_path('rsakey.pem')
unless File.exist?(rsa_key)
- raise 'rsakey.pem does not exist, tests will fail. Run `rake jira:generate_public_cert` first'
+ Rake::Task['jira:generate_public_cert'].invoke
end
end
desc 'Run RSpec tests'
# RSpec::Core::RakeTask.new(:spec)
-RSpec::Core::RakeTask.new(:spec) do |task|
+RSpec::Core::RakeTask.new(:spec, [] => [:prepare]) do |task|
task.rspec_opts = ['--color', '--format', 'doc']
end
diff --git a/debian/changelog b/debian/changelog
index a4f717b..25034bf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+ruby-jira (2.3.0-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+ * Drop patch fix-FTBFS-with-ruby-rspec-3.12.patch, present upstream.
+
+ -- Debian Janitor <janitor@jelmer.uk> Thu, 30 Mar 2023 21:36:40 -0000
+
ruby-jira (2.1.5-4) unstable; urgency=medium
* Team upload.
diff --git a/debian/patches/fix-FTBFS-with-ruby-rspec-3.12.patch b/debian/patches/fix-FTBFS-with-ruby-rspec-3.12.patch
deleted file mode 100644
index 5d95f84..0000000
--- a/debian/patches/fix-FTBFS-with-ruby-rspec-3.12.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-Author: Luke Duncalfe <lduncalfe@eml.cc>
-Description: fix FTBFS with ruby-rspec-3.12
-Origin: upstream, https://github.com/sumoheavy/jira-ruby/pull/394
-Bug-Debian: https://bugs.debian.org/1027078
-Last-Update: 2023-01-02
-
-Index: ruby-jira/spec/jira/resource/issue_spec.rb
-===================================================================
---- ruby-jira.orig/spec/jira/resource/issue_spec.rb
-+++ ruby-jira/spec/jira/resource/issue_spec.rb
-@@ -47,7 +47,7 @@ describe JIRA::Resource::Issue do
- .and_return(empty_response)
-
- expect(client).to receive(:Issue).and_return(issue)
-- expect(issue).to receive(:build).with('id' => '1', 'summary' => 'Bugs Everywhere')
-+ expect(issue).to receive(:build).with({ 'id' => '1', 'summary' => 'Bugs Everywhere' })
-
- issues = JIRA::Resource::Issue.all(client)
- end
-Index: ruby-jira/spec/jira/oauth_client_spec.rb
-===================================================================
---- ruby-jira.orig/spec/jira/oauth_client_spec.rb
-+++ ruby-jira/spec/jira/oauth_client_spec.rb
-@@ -58,7 +58,7 @@ describe JIRA::OauthClient do
- request_token = OAuth::RequestToken.new(oauth_client.consumer)
- allow(oauth_client).to receive(:get_request_token).and_return(request_token)
- mock_access_token = double
-- expect(request_token).to receive(:get_access_token).with(oauth_verifier: 'abc123').and_return(mock_access_token)
-+ expect(request_token).to receive(:get_access_token).with({ oauth_verifier: 'abc123' }).and_return(mock_access_token)
- oauth_client.init_access_token(oauth_verifier: 'abc123')
- expect(oauth_client.access_token).to eq(mock_access_token)
- end
diff --git a/debian/patches/fix-securerandom-nameerror.patch b/debian/patches/fix-securerandom-nameerror.patch
index 1dd64f5..f0abe8b 100644
--- a/debian/patches/fix-securerandom-nameerror.patch
+++ b/debian/patches/fix-securerandom-nameerror.patch
@@ -10,10 +10,10 @@ Forwarded: not-needed
spec/jira/resource/project_spec.rb | 1 +
1 file changed, 1 insertion(+)
-diff --git a/spec/jira/resource/project_spec.rb b/spec/jira/resource/project_spec.rb
-index df8e102..9d90bc2 100644
---- a/spec/jira/resource/project_spec.rb
-+++ b/spec/jira/resource/project_spec.rb
+Index: ruby-jira.git/spec/jira/resource/project_spec.rb
+===================================================================
+--- ruby-jira.git.orig/spec/jira/resource/project_spec.rb
++++ ruby-jira.git/spec/jira/resource/project_spec.rb
@@ -1,4 +1,5 @@
require 'spec_helper'
+require 'securerandom'
diff --git a/debian/patches/remove-bundler-rubygems.patch b/debian/patches/remove-bundler-rubygems.patch
index 5e884ed..bed37ec 100644
--- a/debian/patches/remove-bundler-rubygems.patch
+++ b/debian/patches/remove-bundler-rubygems.patch
@@ -5,8 +5,10 @@ Forwarded: not-needed
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/spec/spec_helper.rb
-+++ b/spec/spec_helper.rb
+Index: ruby-jira.git/spec/spec_helper.rb
+===================================================================
+--- ruby-jira.git.orig/spec/spec_helper.rb
++++ ruby-jira.git/spec/spec_helper.rb
@@ -1,6 +1,4 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
-require 'rubygems'
@@ -14,8 +16,10 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
require 'webmock/rspec'
require 'pry'
---- a/Rakefile
-+++ b/Rakefile
+Index: ruby-jira.git/Rakefile
+===================================================================
+--- ruby-jira.git.orig/Rakefile
++++ ruby-jira.git/Rakefile
@@ -1,6 +1,3 @@
-require 'bundler/gem_tasks'
-
diff --git a/debian/patches/series b/debian/patches/series
index d51916e..6d198d9 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,2 @@
remove-bundler-rubygems.patch
fix-securerandom-nameerror.patch
-fix-FTBFS-with-ruby-rspec-3.12.patch
diff --git a/example.rb b/example.rb
index 5e92b80..f332c74 100644
--- a/example.rb
+++ b/example.rb
@@ -166,6 +166,14 @@ client.Issue.jql(a_normal_jql_search, max_results: 500)
# # --------------------------
# issue.comments.first.save({"body" => "an updated comment frome example.rb"})
+
+# # Add attachment to Issue
+# # ------------------------
+# issue = client.Issue.find('PROJ-1')
+# attachment = issue.attachments.build
+# attachment.save('file': '/path/to/file')
+#
+
# List all available link types
# ------------------------------
pp client.Issuelinktype.all
diff --git a/lib/jira-ruby.rb b/lib/jira-ruby.rb
index b4250cf..5036e9e 100644
--- a/lib/jira-ruby.rb
+++ b/lib/jira-ruby.rb
@@ -1,5 +1,6 @@
$LOAD_PATH << __dir__
+require 'active_support'
require 'active_support/inflector'
ActiveSupport::Inflector.inflections do |inflector|
inflector.singular /status$/, 'status'
@@ -25,6 +26,9 @@ require 'jira/resource/worklog'
require 'jira/resource/applinks'
require 'jira/resource/issuelinktype'
require 'jira/resource/issuelink'
+require 'jira/resource/suggested_issue'
+require 'jira/resource/issue_picker_suggestions_issue'
+require 'jira/resource/issue_picker_suggestions'
require 'jira/resource/remotelink'
require 'jira/resource/sprint'
require 'jira/resource/sprint_report'
diff --git a/lib/jira/client.rb b/lib/jira/client.rb
index 522e8d8..b777766 100644
--- a/lib/jira/client.rb
+++ b/lib/jira/client.rb
@@ -40,6 +40,7 @@ module JIRA
# :key_path => nil,
# :ssl_client_cert => nil,
# :ssl_client_key => nil
+ # :ca_file => nil
#
# See the JIRA::Base class methods for all of the available methods on these accessor
# objects.
@@ -257,6 +258,10 @@ module JIRA
JIRA::Resource::IssuelinktypeFactory.new(self)
end
+ def IssuePickerSuggestions
+ JIRA::Resource::IssuePickerSuggestionsFactory.new(self)
+ end
+
def Remotelink
JIRA::Resource::RemotelinkFactory.new(self)
end
diff --git a/lib/jira/http_client.rb b/lib/jira/http_client.rb
index e68a537..bdd89ea 100644
--- a/lib/jira/http_client.rb
+++ b/lib/jira/http_client.rb
@@ -59,6 +59,7 @@ module JIRA
http_conn.verify_mode = @options[:ssl_verify_mode]
http_conn.ssl_version = @options[:ssl_version] if @options[:ssl_version]
http_conn.read_timeout = @options[:read_timeout]
+ http_conn.ca_file = @options[:ca_file] if @options[:ca_file]
http_conn
end
diff --git a/lib/jira/oauth_client.rb b/lib/jira/oauth_client.rb
index fcfface..bcbed35 100644
--- a/lib/jira/oauth_client.rb
+++ b/lib/jira/oauth_client.rb
@@ -46,7 +46,7 @@ module JIRA
# Returns the current request token if it is set, else it creates
# and sets a new token.
def request_token(options = {}, *arguments, &block)
- @request_token ||= get_request_token(options, *arguments, block)
+ @request_token ||= get_request_token(options, *arguments, &block)
end
# Sets the request token from a given token and secret.
diff --git a/lib/jira/resource/issue_picker_suggestions.rb b/lib/jira/resource/issue_picker_suggestions.rb
new file mode 100644
index 0000000..2834c16
--- /dev/null
+++ b/lib/jira/resource/issue_picker_suggestions.rb
@@ -0,0 +1,24 @@
+module JIRA
+ module Resource
+ class IssuePickerSuggestionsFactory < JIRA::BaseFactory # :nodoc:
+ end
+
+ class IssuePickerSuggestions < JIRA::Base
+ has_many :sections, class: JIRA::Resource::IssuePickerSuggestionsIssue
+
+ def self.all(client, query = '', options = { current_jql: nil, current_issue_key: nil, current_project_id: nil, show_sub_tasks: nil, show_sub_tasks_parent: nil })
+ url = client.options[:rest_base_path] + "/issue/picker?query=#{CGI.escape(query)}"
+
+ url << "¤tJQL=#{CGI.escape(options[:current_jql])}" if options[:current_jql]
+ url << "¤tIssueKey=#{CGI.escape(options[:current_issue_key])}" if options[:current_issue_key]
+ url << "¤tProjectId=#{CGI.escape(options[:current_project_id])}" if options[:current_project_id]
+ url << "&showSubTasks=#{options[:show_sub_tasks]}" if options[:show_sub_tasks]
+ url << "&showSubTaskParent=#{options[:show_sub_task_parent]}" if options[:show_sub_task_parent]
+
+ response = client.get(url)
+ json = parse_json(response.body)
+ client.IssuePickerSuggestions.build(json)
+ end
+ end
+ end
+end
diff --git a/lib/jira/resource/issue_picker_suggestions_issue.rb b/lib/jira/resource/issue_picker_suggestions_issue.rb
new file mode 100644
index 0000000..4d54c90
--- /dev/null
+++ b/lib/jira/resource/issue_picker_suggestions_issue.rb
@@ -0,0 +1,10 @@
+module JIRA
+ module Resource
+ class IssuePickerSuggestionsIssueFactory < JIRA::BaseFactory # :nodoc:
+ end
+
+ class IssuePickerSuggestionsIssue < JIRA::Base
+ has_many :issues, class: JIRA::Resource::SuggestedIssue
+ end
+ end
+end
diff --git a/lib/jira/resource/suggested_issue.rb b/lib/jira/resource/suggested_issue.rb
new file mode 100644
index 0000000..7fe7d00
--- /dev/null
+++ b/lib/jira/resource/suggested_issue.rb
@@ -0,0 +1,9 @@
+module JIRA
+ module Resource
+ class SuggestedIssueFactory < JIRA::BaseFactory # :nodoc:
+ end
+
+ class SuggestedIssue < JIRA::Base
+ end
+ end
+end
diff --git a/lib/jira/version.rb b/lib/jira/version.rb
index bd3da13..0923140 100644
--- a/lib/jira/version.rb
+++ b/lib/jira/version.rb
@@ -1,3 +1,3 @@
module JIRA
- VERSION = '2.1.5'.freeze
+ VERSION = '2.3.0'.freeze
end
diff --git a/spec/jira/http_client_spec.rb b/spec/jira/http_client_spec.rb
index 11b2294..e184ea6 100644
--- a/spec/jira/http_client_spec.rb
+++ b/spec/jira/http_client_spec.rb
@@ -285,6 +285,11 @@ describe JIRA::HttpClient do
expect(basic_client_cert_client.http_conn(uri)).to eq(http_conn)
end
+ it 'can use a certificate authority file' do
+ client = JIRA::HttpClient.new(JIRA::Client::DEFAULT_OPTIONS.merge(ca_file: '/opt/custom.ca.pem'))
+ expect(client.http_conn(client.uri).ca_file).to eql('/opt/custom.ca.pem')
+ end
+
it 'returns a http connection' do
http_conn = double
uri = double
diff --git a/spec/jira/oauth_client_spec.rb b/spec/jira/oauth_client_spec.rb
index 048b1d6..165443e 100644
--- a/spec/jira/oauth_client_spec.rb
+++ b/spec/jira/oauth_client_spec.rb
@@ -35,6 +35,26 @@ describe JIRA::OauthClient do
expect(oauth_client.get_request_token).to eq(request_token)
end
+ it 'could pre-process the response body in a block' do
+ response = Net::HTTPSuccess.new(1.0, '200', 'OK')
+ allow_any_instance_of(OAuth::Consumer).to receive(:request).and_return(response)
+ allow(response).to receive(:body).and_return('&oauth_token=token&oauth_token_secret=secret&password=top_secret')
+
+ result = oauth_client.request_token do |response_body|
+ CGI.parse(response_body).each_with_object({}) do |(k, v), h|
+ next if k == 'password'
+
+ h[k.strip.to_sym] = v.first
+ end
+ end
+
+ expect(result).to be_an_instance_of(OAuth::RequestToken)
+ expect(result.consumer).to eql(oauth_client.consumer)
+ expect(result.params[:oauth_token]).to eql('token')
+ expect(result.params[:oauth_token_secret]).to eql('secret')
+ expect(result.params[:password]).to be_falsey
+ end
+
it 'allows setting the request token' do
token = double
expect(OAuth::RequestToken).to receive(:new).with(oauth_client.consumer, 'foo', 'bar').and_return(token)
@@ -58,7 +78,7 @@ describe JIRA::OauthClient do
request_token = OAuth::RequestToken.new(oauth_client.consumer)
allow(oauth_client).to receive(:get_request_token).and_return(request_token)
mock_access_token = double
- expect(request_token).to receive(:get_access_token).with(oauth_verifier: 'abc123').and_return(mock_access_token)
+ expect(request_token).to receive(:get_access_token).with({ oauth_verifier: 'abc123' }).and_return(mock_access_token)
oauth_client.init_access_token(oauth_verifier: 'abc123')
expect(oauth_client.access_token).to eq(mock_access_token)
end
@@ -159,4 +179,4 @@ describe JIRA::OauthClient do
end
end
end
-end
\ No newline at end of file
+end
diff --git a/spec/jira/resource/issue_picker_suggestions_spec.rb b/spec/jira/resource/issue_picker_suggestions_spec.rb
new file mode 100644
index 0000000..6cbc351
--- /dev/null
+++ b/spec/jira/resource/issue_picker_suggestions_spec.rb
@@ -0,0 +1,79 @@
+require 'spec_helper'
+
+describe JIRA::Resource::IssuePickerSuggestions do
+ let(:client) do
+ double('client', options: {
+ rest_base_path: '/jira/rest/api/2'
+ })
+ end
+
+ describe 'relationships' do
+ subject do
+ JIRA::Resource::IssuePickerSuggestions.new(client, attrs: {
+ 'sections' => [{ 'id' => 'hs'}, { 'id' => 'cs' }]
+ })
+ end
+
+ it 'has the correct relationships' do
+ expect(subject).to have_many(:sections, JIRA::Resource::IssuePickerSuggestionsIssue)
+ expect(subject.sections.length).to eq(2)
+ end
+ end
+
+ describe '#all' do
+ let(:response) { double }
+ let(:issue_picker_suggestions) { double }
+
+ before do
+ allow(response).to receive(:body).and_return('{"sections":[{"id": "cs"}]}')
+ allow(client).to receive(:IssuePickerSuggestions).and_return(issue_picker_suggestions)
+ allow(issue_picker_suggestions).to receive(:build)
+ end
+
+ it 'should autocomplete issues' do
+ allow(response).to receive(:body).and_return('{"sections":[{"id": "cs"}]}')
+ expect(client).to receive(:get).with('/jira/rest/api/2/issue/picker?query=query')
+ .and_return(response)
+
+ expect(client).to receive(:IssuePickerSuggestions).and_return(issue_picker_suggestions)
+ expect(issue_picker_suggestions).to receive(:build).with({ 'sections' => [{ 'id' => 'cs' }] })
+
+ JIRA::Resource::IssuePickerSuggestions.all(client, 'query')
+ end
+
+ it 'should autocomplete issues with current jql' do
+ expect(client).to receive(:get).with('/jira/rest/api/2/issue/picker?query=query¤tJQL=project+%3D+PR')
+ .and_return(response)
+
+ JIRA::Resource::IssuePickerSuggestions.all(client, 'query', current_jql: 'project = PR')
+ end
+
+ it 'should autocomplete issues with current issue jey' do
+ expect(client).to receive(:get).with('/jira/rest/api/2/issue/picker?query=query¤tIssueKey=PR-42')
+ .and_return(response)
+
+ JIRA::Resource::IssuePickerSuggestions.all(client, 'query', current_issue_key: 'PR-42')
+ end
+
+ it 'should autocomplete issues with current project id' do
+ expect(client).to receive(:get).with('/jira/rest/api/2/issue/picker?query=query¤tProjectId=PR')
+ .and_return(response)
+
+ JIRA::Resource::IssuePickerSuggestions.all(client, 'query', current_project_id: 'PR')
+ end
+
+ it 'should autocomplete issues with show sub tasks' do
+ expect(client).to receive(:get).with('/jira/rest/api/2/issue/picker?query=query&showSubTasks=true')
+ .and_return(response)
+
+ JIRA::Resource::IssuePickerSuggestions.all(client, 'query', show_sub_tasks: true)
+ end
+
+ it 'should autocomplete issues with show sub tasks parent' do
+ expect(client).to receive(:get).with('/jira/rest/api/2/issue/picker?query=query&showSubTaskParent=true')
+ .and_return(response)
+
+ JIRA::Resource::IssuePickerSuggestions.all(client, 'query', show_sub_task_parent: true)
+ end
+ end
+end
diff --git a/spec/jira/resource/issue_spec.rb b/spec/jira/resource/issue_spec.rb
index 585200c..7c9c915 100644
--- a/spec/jira/resource/issue_spec.rb
+++ b/spec/jira/resource/issue_spec.rb
@@ -47,7 +47,7 @@ describe JIRA::Resource::Issue do
.and_return(empty_response)
expect(client).to receive(:Issue).and_return(issue)
- expect(issue).to receive(:build).with('id' => '1', 'summary' => 'Bugs Everywhere')
+ expect(issue).to receive(:build).with({ 'id' => '1', 'summary' => 'Bugs Everywhere' })
issues = JIRA::Resource::Issue.all(client)
end
diff --git a/spec/jira/resource/jira_picker_suggestions_issue_spec.rb b/spec/jira/resource/jira_picker_suggestions_issue_spec.rb
new file mode 100644
index 0000000..c584b87
--- /dev/null
+++ b/spec/jira/resource/jira_picker_suggestions_issue_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe JIRA::Resource::IssuePickerSuggestionsIssue do
+ let(:client) { double('client') }
+
+ describe 'relationships' do
+ subject do
+ JIRA::Resource::IssuePickerSuggestionsIssue.new(client, attrs: {
+ 'issues' => [{ 'id' => '1'}, { 'id' => '2' }]
+ })
+ end
+
+ it 'has the correct relationships' do
+ expect(subject).to have_many(:issues, JIRA::Resource::SuggestedIssue)
+ expect(subject.issues.length).to eq(2)
+ end
+ end
+end
Debdiff
[The following lists of changes regard files as different if they have different names, permissions or owners.]
Files in second set of .debs but not in first
-rw-r--r-- root/root /usr/lib/ruby/vendor_ruby/jira/resource/issue_picker_suggestions.rb -rw-r--r-- root/root /usr/lib/ruby/vendor_ruby/jira/resource/issue_picker_suggestions_issue.rb -rw-r--r-- root/root /usr/lib/ruby/vendor_ruby/jira/resource/suggested_issue.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/specifications/jira-ruby-2.3.0.gemspec
Files in first set of .debs but not in second
-rw-r--r-- root/root /usr/share/rubygems-integration/all/specifications/jira-ruby-2.1.5.gemspec
No differences were encountered in the control files