ruby_bugzilla 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +0 -1
- data/README.md +25 -9
- data/lib/ruby_bugzilla/version.rb +1 -1
- data/lib/ruby_bugzilla.rb +93 -139
- data/spec/ruby_bugzilla_spec.rb +71 -281
- data/spec/spec_helper.rb +2 -2
- metadata +4 -5
- data/samples/bugzilla_credentials.yaml +0 -14
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# RubyBugzilla
|
2
2
|
|
3
|
-
|
4
3
|
[![Gem Version](https://badge.fury.io/rb/ruby_bugzilla.png)](http://badge.fury.io/rb/ruby_bugzilla)
|
5
4
|
[![Build Status](https://travis-ci.org/ManageIQ/ruby_bugzilla.png)](https://travis-ci.org/ManageIQ/ruby_bugzilla)
|
6
5
|
[![Code Climate](https://codeclimate.com/github/ManageIQ/ruby_bugzilla.png)](https://codeclimate.com/github/ManageIQ/ruby_bugzilla)
|
@@ -9,6 +8,24 @@
|
|
9
8
|
|
10
9
|
A Ruby wrapper around the python-bugzilla CLI for easy access to the Bugzilla API
|
11
10
|
|
11
|
+
## Prerequisites
|
12
|
+
|
13
|
+
python-bugzilla must be installed.
|
14
|
+
|
15
|
+
* For Fedora/RHEL
|
16
|
+
* sudo yum install python-bugzilla
|
17
|
+
* For Mac
|
18
|
+
* Download python-bugzilla from https://fedorahosted.org/python-bugzilla/
|
19
|
+
* Untar the file
|
20
|
+
* Run setup.py install
|
21
|
+
|
22
|
+
python-bugzilla uses pycurl and expects it to be installed.
|
23
|
+
|
24
|
+
* For Mac
|
25
|
+
* Download pycurl from http://pycurl.sourceforge.net/download/
|
26
|
+
* Untar the file
|
27
|
+
* Run setup.py install
|
28
|
+
|
12
29
|
## Installation
|
13
30
|
|
14
31
|
Add this line to your application's Gemfile:
|
@@ -23,15 +40,14 @@ Or install it yourself as:
|
|
23
40
|
|
24
41
|
$ gem install ruby_bugzilla
|
25
42
|
|
26
|
-
## Usage
|
27
|
-
|
28
|
-
If not already logged in to bugzilla, RubyBugzilla can login using
|
29
|
-
the crendentials in bugzilla_credentials.yaml
|
30
|
-
Copy sample/bugzilla_credentials.yaml to $HOME and edit the file
|
31
|
-
to contain your bugzilla credentials.
|
32
|
-
|
33
|
-
TODO: Write more usage instructions here
|
43
|
+
## Example Usage
|
34
44
|
|
45
|
+
```ruby
|
46
|
+
bz = RubyBugzilla.new("http://uri.to/bugzilla, "username", "password")
|
47
|
+
bz.login
|
48
|
+
output = bz.query(:bug_status => "NEW")
|
49
|
+
bz.modify([928134, 932439], :status => "RELEASE_PENDING", :comment => "Looks good")
|
50
|
+
```
|
35
51
|
|
36
52
|
## Contributing
|
37
53
|
|
data/lib/ruby_bugzilla.rb
CHANGED
@@ -1,192 +1,147 @@
|
|
1
|
-
require 'yaml'
|
2
1
|
require 'linux_admin'
|
3
2
|
|
4
3
|
class RubyBugzilla
|
4
|
+
CMD = `which bugzilla`.chomp
|
5
|
+
COOKIES_FILE = File.expand_path('~/.bugzillacookies')
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
CREDS_FILE = File.expand_path('~') + '/.bugzilla_credentials.yaml'
|
9
|
-
|
10
|
-
def self.username=(un)
|
11
|
-
@username = un
|
7
|
+
def self.installed?
|
8
|
+
File.exists?(CMD)
|
12
9
|
end
|
13
10
|
|
14
|
-
def self.
|
15
|
-
|
11
|
+
def self.logged_in?
|
12
|
+
File.exists?(COOKIES_FILE)
|
16
13
|
end
|
17
14
|
|
18
|
-
def self.
|
19
|
-
|
15
|
+
def self.clear_login!
|
16
|
+
File.delete(COOKIES_FILE) if File.exists?(COOKIES_FILE)
|
20
17
|
end
|
21
18
|
|
22
|
-
|
23
|
-
|
24
|
-
end
|
19
|
+
attr_accessor :bugzilla_uri, :username, :password, :last_command
|
20
|
+
attr_reader :bugzilla_request_uri
|
25
21
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
22
|
+
def bugzilla_uri=(value)
|
23
|
+
@bugzilla_request_uri = URI.join(value, "xmlrpc.cgi").to_s
|
24
|
+
@bugzilla_uri = value
|
25
|
+
end
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
self.password ||= pw_from_file
|
34
|
-
end
|
27
|
+
def initialize(bugzilla_uri, username, password)
|
28
|
+
raise "python-bugzilla not installed" unless installed?
|
29
|
+
raise ArgumentError, "username and password must be set" if username.nil? || password.nil?
|
35
30
|
|
36
|
-
|
31
|
+
self.bugzilla_uri = bugzilla_uri
|
32
|
+
self.username = username
|
33
|
+
self.password = password
|
37
34
|
end
|
38
35
|
|
39
|
-
|
40
|
-
|
41
|
-
def self.credentials_from_file
|
42
|
-
begin
|
43
|
-
creds = YAML.load_file(CREDS_FILE)
|
44
|
-
rescue Errno::ENOENT => error
|
45
|
-
return [nil, nil]
|
46
|
-
end
|
47
|
-
|
48
|
-
[creds[:bugzilla_credentials][:username],
|
49
|
-
creds[:bugzilla_credentials][:password]]
|
36
|
+
def inspect
|
37
|
+
super.gsub(/@password=\".+?\", /, "")
|
50
38
|
end
|
51
39
|
|
52
|
-
def
|
53
|
-
|
54
|
-
options = YAML.load_file(CREDS_FILE)
|
55
|
-
rescue Errno::ENOENT => error
|
56
|
-
return ["https://bugzilla.redhat.com/", false]
|
57
|
-
end
|
58
|
-
[options[:bugzilla_options][:bugzilla_uri],
|
59
|
-
options[:bugzilla_options][:debug]]
|
40
|
+
def installed?
|
41
|
+
self.class.installed?
|
60
42
|
end
|
61
43
|
|
62
|
-
|
63
|
-
|
64
|
-
def self.logged_in?
|
65
|
-
File.exists?(COOKIES_FILE)
|
44
|
+
def logged_in?
|
45
|
+
self.class.logged_in?
|
66
46
|
end
|
67
47
|
|
68
|
-
def
|
69
|
-
|
70
|
-
File.delete(COOKIES_FILE)
|
71
|
-
end
|
48
|
+
def clear_login!
|
49
|
+
self.class.clear_login!
|
72
50
|
end
|
73
51
|
|
74
|
-
def
|
52
|
+
def login
|
53
|
+
if logged_in?
|
54
|
+
self.last_command = nil
|
55
|
+
return "Already Logged In"
|
56
|
+
end
|
75
57
|
|
76
|
-
login_cmd = "#{CMD} "
|
77
|
-
output = "Already Logged In"
|
78
58
|
params = {}
|
59
|
+
params["--debug"] = nil
|
60
|
+
params["login"] = [username, password]
|
79
61
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
params["--bugzilla="] = "#{uri_opt}/xmlrpc.cgi" unless uri_opt.nil?
|
87
|
-
params["--debug"] = nil if debug_opt
|
88
|
-
params["login"] = [username, password]
|
89
|
-
|
90
|
-
begin
|
91
|
-
login_cmd_result = LinuxAdmin.run!(CMD, :params => params)
|
92
|
-
rescue => error
|
93
|
-
# A failed login attempt could result in a corrupt COOKIES_FILE
|
94
|
-
clear_login!
|
95
|
-
raise "#{self.string_command(CMD, params, password)} Failed.\n#{error}"
|
96
|
-
end
|
97
|
-
output = login_cmd_result.output
|
62
|
+
begin
|
63
|
+
execute(params)
|
64
|
+
rescue
|
65
|
+
clear_login! # A failed login attempt could result in a corrupt COOKIES_FILE
|
66
|
+
raise
|
98
67
|
end
|
99
|
-
[self.string_command(CMD, params, password), output]
|
100
68
|
end
|
101
69
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
70
|
+
# Query for existing bugs
|
71
|
+
#
|
72
|
+
# Example:
|
73
|
+
# # Query for all NEW bugs, and return the output in a specific format.
|
74
|
+
# puts bz.query(
|
75
|
+
# :bug_status => "NEW",
|
76
|
+
# :outputformat => "BZ_ID: %{id} STATUS: %{bug_status} SUMMARY: %{summary}"
|
77
|
+
# )
|
78
|
+
# # BZ_ID: 1234 STATUS: NEW SUMMARY: Something went wrong.
|
79
|
+
# # BZ_ID: 1235 STATUS: NEW SUMMARY: Another thing went wrong.
|
80
|
+
#
|
81
|
+
# @param options [Hash] Query options. Some possible values are:
|
82
|
+
# * <tt>:product</tt> - A specific product to limit the query against
|
83
|
+
# * <tt>:flag</tt> - Comma separated list of flags
|
84
|
+
# * <tt>:bug_status</tt> - Comma separated list of bug statuses, such as NEW,
|
85
|
+
# ASSIGNED, etc.
|
86
|
+
# * <tt>:outputformat</tt> - A string that will be used to format each line
|
87
|
+
# of output, with <tt>%{}</tt> as the interpolater.
|
88
|
+
# @return [String] The command output
|
89
|
+
def query(options)
|
90
|
+
raise ArgumentError, "options must be specified" if options.empty?
|
110
91
|
|
111
92
|
params = {}
|
93
|
+
params["query"] = nil
|
94
|
+
set_params_options(params, options)
|
112
95
|
|
113
|
-
params
|
114
|
-
params["query"] = nil
|
115
|
-
params["--product="] = product
|
116
|
-
params["--flag="] = flag unless flag.nil?
|
117
|
-
params["--bug_status="] = bug_status unless bug_status.nil?
|
118
|
-
params["--outputformat="] = output_format unless output_format.nil?
|
119
|
-
|
120
|
-
begin
|
121
|
-
query_cmd_result = LinuxAdmin.run!(CMD, :params => params)
|
122
|
-
rescue => error
|
123
|
-
raise "#{self.string_command(CMD, params)} Failed.\n#{error}"
|
124
|
-
end
|
125
|
-
|
126
|
-
[self.string_command(CMD, params), query_cmd_result.output]
|
96
|
+
execute(params)
|
127
97
|
end
|
128
98
|
|
129
|
-
|
130
|
-
#
|
131
|
-
# Example Usage:
|
132
|
-
#
|
133
|
-
# bugids can be an Array of bug ids, a String or Fixnum
|
134
|
-
# containing a single bug id
|
99
|
+
# Modify an existing bug or set of bugs
|
135
100
|
#
|
136
|
-
#
|
101
|
+
# Examples:
|
102
|
+
# # Set the status of multiple bugs to RELEASE_PENDING
|
103
|
+
# bz.modify([948970, 948971], :status => "RELEASE_PENDING")
|
137
104
|
#
|
138
|
-
#
|
139
|
-
#
|
105
|
+
# # Add a comment
|
106
|
+
# bz.modify("948972", :comment => "whatevs")
|
140
107
|
#
|
141
|
-
#
|
142
|
-
#
|
108
|
+
# # Set the status to POST and add a comment
|
109
|
+
# bz.modify(948970, :status => "POST", :comment => "Fixed in shabla")
|
143
110
|
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
#
|
147
|
-
|
148
|
-
|
149
|
-
|
111
|
+
# @param bug_ids [String, Integer, Array<String>, Array<Integer>] The bug id
|
112
|
+
# or ids to process.
|
113
|
+
# @param options [Hash] The properties to change. Some properties include
|
114
|
+
# * <tt>:status</tt> - The bug status, such as NEW, ASSIGNED, etc.
|
115
|
+
# * <tt>:comment</tt> - Add a comment
|
116
|
+
# @return [String] The command output
|
117
|
+
def modify(bug_ids, options)
|
118
|
+
bug_ids = Array(bug_ids)
|
119
|
+
raise ArgumentError, "bug_ids and options must be specified" if bug_ids.empty? || options.empty?
|
120
|
+
raise ArgumentError, "bug_ids must be numeric" unless bug_ids.all? {|id| id.to_s =~ /^\d+$/ }
|
150
121
|
|
151
|
-
bugids = Array(bugids_arg)
|
152
|
-
if bugids.empty? || options.empty? || bugids_arg.to_s.empty?
|
153
|
-
raise ArgumentError, "bugids and options must be specified"
|
154
|
-
end
|
155
|
-
|
156
|
-
uri_opt, debug_opt = self.options
|
157
122
|
params = {}
|
123
|
+
params["modify"] = bug_ids
|
124
|
+
set_params_options(params, options)
|
158
125
|
|
159
|
-
params
|
160
|
-
|
126
|
+
execute(params)
|
127
|
+
end
|
161
128
|
|
162
|
-
|
163
|
-
self.set_params_options(params, options)
|
129
|
+
private
|
164
130
|
|
165
|
-
|
166
|
-
|
167
|
-
rescue => error
|
168
|
-
raise "#{self.string_command(CMD, params)} Failed.\n#{error}"
|
169
|
-
end
|
131
|
+
def execute(params)
|
132
|
+
params = {"--bugzilla=" => bugzilla_request_uri}.merge(params)
|
170
133
|
|
171
|
-
self.string_command(CMD, params)
|
134
|
+
self.last_command = string_command(CMD, params, password)
|
135
|
+
LinuxAdmin.run!(CMD, :params => params).output
|
172
136
|
end
|
173
137
|
|
174
|
-
|
175
|
-
def self.set_params_options(params, options)
|
138
|
+
def set_params_options(params, options)
|
176
139
|
options.each do |key,value|
|
177
140
|
params["--#{key}="] = value
|
178
141
|
end
|
179
142
|
end
|
180
143
|
|
181
|
-
|
182
|
-
def self.set_params_bugids(params, bugids)
|
183
|
-
bugids.each do |bugid|
|
184
|
-
params[bugid] = nil
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
private
|
189
|
-
def self.string_command(cmd, params = {}, password=nil)
|
144
|
+
def string_command(cmd, params = {}, password=nil)
|
190
145
|
scrubbed_str = str = ""
|
191
146
|
str << cmd
|
192
147
|
params.each do |param, value|
|
@@ -203,5 +158,4 @@ class RubyBugzilla
|
|
203
158
|
scrubbed_str = str.sub(password, "********") unless password.nil?
|
204
159
|
scrubbed_str
|
205
160
|
end
|
206
|
-
|
207
161
|
end
|
data/spec/ruby_bugzilla_spec.rb
CHANGED
@@ -1,337 +1,127 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'tempfile'
|
3
2
|
|
4
|
-
class TempCredFile < Tempfile
|
5
|
-
def initialize(file)
|
6
|
-
f = super
|
7
|
-
f.puts("---")
|
8
|
-
f.puts(":bugzilla_credentials:")
|
9
|
-
f.puts(" :username: My Username")
|
10
|
-
f.puts(" :password: My Password")
|
11
|
-
f.puts(":bugzilla_options:")
|
12
|
-
f.puts(" :bugzilla_uri: MyURI")
|
13
|
-
f.puts(" :debug: MyDebug")
|
14
|
-
f.flush
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
3
|
describe RubyBugzilla do
|
19
|
-
|
20
|
-
saved_cookies_file = RubyBugzilla::COOKIES_FILE
|
21
|
-
saved_creds_file = RubyBugzilla::CREDS_FILE
|
4
|
+
let(:bz) { RubyBugzilla.new("http://uri.to/bugzilla", "calvin", "hobbes") }
|
22
5
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
$VERBOSE = v
|
29
|
-
end
|
6
|
+
before do
|
7
|
+
# Assume most tests have bugzilla installed and logged in by faking with
|
8
|
+
# valid files
|
9
|
+
stub_const("RubyBugzilla::CMD", "/bin/echo")
|
10
|
+
stub_const("RubyBugzilla::COOKIES_FILE", "/bin/echo")
|
30
11
|
end
|
31
12
|
|
32
|
-
|
33
|
-
after :each do
|
34
|
-
ignore_warnings do
|
35
|
-
RubyBugzilla::CMD = saved_cmd
|
36
|
-
RubyBugzilla::COOKIES_FILE = saved_cookies_file
|
37
|
-
RubyBugzilla::CREDS_FILE = saved_creds_file
|
38
|
-
RubyBugzilla.username = nil
|
39
|
-
RubyBugzilla.password = nil
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context "#logged_in?" do
|
13
|
+
context ".logged_in?" do
|
44
14
|
it "with an existing bugzilla cookie" do
|
45
|
-
|
46
|
-
ignore_warnings do
|
47
|
-
RubyBugzilla::COOKIES_FILE = file.path
|
48
|
-
end
|
49
|
-
RubyBugzilla.logged_in?.should be true
|
50
|
-
end
|
15
|
+
RubyBugzilla.logged_in?.should be_true
|
51
16
|
end
|
52
17
|
|
53
18
|
it "with no bugzilla cookie" do
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
RubyBugzilla.logged_in?.should be false
|
19
|
+
stub_const("RubyBugzilla::COOKIES_FILE", "/This/file/does/not/exist")
|
20
|
+
RubyBugzilla.logged_in?.should be_false
|
58
21
|
end
|
59
22
|
end
|
60
23
|
|
61
|
-
context "#
|
62
|
-
it
|
63
|
-
|
64
|
-
RubyBugzilla::CMD = '/This/cmd/does/not/exist'
|
65
|
-
end
|
66
|
-
expect { RubyBugzilla.login! }.to raise_exception
|
24
|
+
context "#new" do
|
25
|
+
it 'normal case' do
|
26
|
+
expect { bz }.to_not raise_error
|
67
27
|
end
|
68
28
|
|
69
|
-
it "when the bugzilla
|
70
|
-
|
71
|
-
|
72
|
-
RubyBugzilla::CMD = '/bin/echo'
|
73
|
-
RubyBugzilla::COOKIES_FILE = '/This/file/does/not/exist'
|
74
|
-
end
|
75
|
-
cmd, output = RubyBugzilla.login!("My Username", "My Password")
|
76
|
-
output.should include("login My Username My Password")
|
29
|
+
it "when the bugzilla command is not found" do
|
30
|
+
stub_const("RubyBugzilla::CMD", "/This/cmd/does/not/exist")
|
31
|
+
expect { bz }.to raise_error
|
77
32
|
end
|
78
33
|
|
79
|
-
it "when
|
80
|
-
|
81
|
-
ignore_warnings do
|
82
|
-
RubyBugzilla::CMD = '/bin/echo'
|
83
|
-
RubyBugzilla::COOKIES_FILE = '/This/file/does/not/exist'
|
84
|
-
end
|
85
|
-
cmd, output = RubyBugzilla.login!("calvin", "hobbes")
|
86
|
-
output.should include("login calvin hobbes")
|
34
|
+
it "when bugzilla_uri is invalid" do
|
35
|
+
expect { RubyBugzilla.new("lalala", "", "") }.to raise_error(URI::BadURIError)
|
87
36
|
end
|
88
37
|
|
38
|
+
it "when username and password are not set" do
|
39
|
+
expect { RubyBugzilla.new("http://uri.to/bugzilla", nil, nil) }.to raise_error(ArgumentError)
|
40
|
+
end
|
89
41
|
end
|
90
42
|
|
91
|
-
context "#
|
92
|
-
it "when
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
43
|
+
context "#login" do
|
44
|
+
it "when already logged in" do
|
45
|
+
output = bz.login
|
46
|
+
|
47
|
+
bz.last_command.should be_nil
|
48
|
+
output.should include("Already Logged In")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "when not already logged in" do
|
52
|
+
stub_const("RubyBugzilla::COOKIES_FILE", "/This/file/does/not/exist")
|
53
|
+
bz.login
|
54
|
+
|
55
|
+
bz.last_command.should include("login")
|
97
56
|
end
|
57
|
+
end
|
98
58
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
103
|
-
expect { RubyBugzilla.query }.to raise_error(ArgumentError)
|
59
|
+
context "#query" do
|
60
|
+
it "when no arguments are specified" do
|
61
|
+
expect { bz.query }.to raise_error(ArgumentError)
|
104
62
|
end
|
105
63
|
|
106
64
|
it "when the bugzilla query command produces output" do
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
cmd, output = RubyBugzilla.login!("calvin", "hobbes")
|
114
|
-
cmd, output = RubyBugzilla.query('CloudForms Management Engine',
|
115
|
-
flag = '',
|
116
|
-
bug_status = 'NEW, ASSIGNED, POST, MODIFIED, ON_DEV, ON_QA, VERIFIED, RELEASE_PENDING',
|
117
|
-
output_format = 'BZ_ID: %{id} STATUS: %{bug_status} SUMMARY: %{summary}')
|
65
|
+
output = bz.query(
|
66
|
+
:product => 'CloudForms Management Engine',
|
67
|
+
:bug_status => 'NEW, ASSIGNED, POST, MODIFIED, ON_DEV, ON_QA, VERIFIED, RELEASE_PENDING',
|
68
|
+
:outputformat => 'BZ_ID: %{id} STATUS: %{bug_status} SUMMARY: %{summary}'
|
69
|
+
)
|
118
70
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
71
|
+
bz.last_command.should include("query")
|
72
|
+
output.should include("BZ_ID:")
|
73
|
+
output.should include("STATUS:")
|
74
|
+
output.should include("SUMMARY:")
|
123
75
|
end
|
124
76
|
end
|
125
77
|
|
126
78
|
context "#modify" do
|
127
|
-
it "when the bugzilla command is not found" do
|
128
|
-
ignore_warnings do
|
129
|
-
RubyBugzilla::CMD = '/This/cmd/does/not/exist'
|
130
|
-
end
|
131
|
-
expect { RubyBugzilla.modify }.to raise_exception
|
132
|
-
end
|
133
|
-
|
134
79
|
it "when no arguments are specified" do
|
135
|
-
|
136
|
-
RubyBugzilla::CMD = '/bin/echo'
|
137
|
-
end
|
138
|
-
expect { RubyBugzilla.modify }.to raise_error(ArgumentError)
|
80
|
+
expect { bz.modify }.to raise_error(ArgumentError)
|
139
81
|
end
|
140
82
|
|
141
|
-
it "when
|
142
|
-
|
143
|
-
RubyBugzilla::CMD = '/bin/echo'
|
144
|
-
end
|
145
|
-
expect { RubyBugzilla.modify("", :status => "POST") }.to raise_error(ArgumentError)
|
83
|
+
it "when invalid bugids are are specified" do
|
84
|
+
expect { bz.modify("", :status => "POST") }.to raise_error(ArgumentError)
|
146
85
|
end
|
147
86
|
|
148
87
|
it "when no options are specified" do
|
149
|
-
|
150
|
-
RubyBugzilla::CMD = '/bin/echo'
|
151
|
-
end
|
152
|
-
expect { RubyBugzilla.modify(9, {}) }.to raise_error(ArgumentError)
|
88
|
+
expect { bz.modify(9, {}) }.to raise_error(ArgumentError)
|
153
89
|
end
|
154
90
|
|
155
91
|
it "when the bugzilla modify command succeeds for one option and multiple BZs" do
|
156
|
-
|
157
|
-
ignore_warnings do
|
158
|
-
RubyBugzilla::CMD = '/bin/echo'
|
159
|
-
RubyBugzilla::COOKIES_FILE = '/This/file/does/not/exist'
|
160
|
-
end
|
161
|
-
|
162
|
-
cmd, output = RubyBugzilla.login!("calvin", "hobbes")
|
163
|
-
cmd = RubyBugzilla.modify(["948970", "948971", "948972", "948973"],
|
164
|
-
:status => "RELEASE_PENDING")
|
92
|
+
bz.modify(["948970", "948971", "948972", "948973"], :status => "RELEASE_PENDING")
|
165
93
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
94
|
+
bz.last_command.should include("modify")
|
95
|
+
bz.last_command.should include("--status=\"RELEASE_PENDING\"")
|
96
|
+
bz.last_command.should include("948970")
|
97
|
+
bz.last_command.should include("948971")
|
98
|
+
bz.last_command.should include("948972")
|
99
|
+
bz.last_command.should include("948973")
|
172
100
|
end
|
173
101
|
|
174
102
|
it "when the bugzilla modify command succeeds for multiple options and a Array BZ" do
|
175
|
-
|
176
|
-
ignore_warnings do
|
177
|
-
RubyBugzilla::CMD = '/bin/echo'
|
178
|
-
RubyBugzilla::COOKIES_FILE = '/This/file/does/not/exist'
|
179
|
-
end
|
103
|
+
bz.modify(["948972"], :status => "POST", :comment => "Fixed in shabla")
|
180
104
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
cmd.should include("modify")
|
186
|
-
cmd.should include("--status=\"POST\"")
|
187
|
-
cmd.should include("948972")
|
188
|
-
cmd.should include("Fixed in shabla")
|
105
|
+
bz.last_command.should include("modify")
|
106
|
+
bz.last_command.should include("--status=\"POST\"")
|
107
|
+
bz.last_command.should include("948972")
|
108
|
+
bz.last_command.should include("Fixed in shabla")
|
189
109
|
end
|
190
110
|
|
191
111
|
it "when the bugzilla modify command succeeds for a Fixnum BZ" do
|
192
|
-
|
193
|
-
ignore_warnings do
|
194
|
-
RubyBugzilla::CMD = '/bin/echo'
|
195
|
-
RubyBugzilla::COOKIES_FILE = '/This/file/does/not/exist'
|
196
|
-
end
|
197
|
-
|
198
|
-
cmd, output = RubyBugzilla.login!("calvin", "hobbes")
|
199
|
-
cmd = RubyBugzilla.modify(948972, :status => "POST")
|
112
|
+
bz.modify(948972, :status => "POST")
|
200
113
|
|
201
|
-
|
202
|
-
|
203
|
-
|
114
|
+
bz.last_command.should include("modify")
|
115
|
+
bz.last_command.should include("--status=\"POST\"")
|
116
|
+
bz.last_command.should include("948972")
|
204
117
|
end
|
205
118
|
|
206
119
|
it "when the bugzilla modify command succeeds for a String BZ" do
|
207
|
-
|
208
|
-
ignore_warnings do
|
209
|
-
RubyBugzilla::CMD = '/bin/echo'
|
210
|
-
RubyBugzilla::COOKIES_FILE = '/This/file/does/not/exist'
|
211
|
-
end
|
212
|
-
|
213
|
-
cmd, output = RubyBugzilla.login!("calvin", "hobbes")
|
214
|
-
cmd = RubyBugzilla.modify("948972", :status => "POST")
|
120
|
+
bz.modify("948972", :status => "POST")
|
215
121
|
|
216
|
-
|
217
|
-
|
218
|
-
|
122
|
+
bz.last_command.should include("modify")
|
123
|
+
bz.last_command.should include("--status=\"POST\"")
|
124
|
+
bz.last_command.should include("948972")
|
219
125
|
end
|
220
126
|
end
|
221
|
-
|
222
|
-
context "#credentials_from_file" do
|
223
|
-
it "when the YAML input file is not found" do
|
224
|
-
ignore_warnings do
|
225
|
-
RubyBugzilla::CREDS_FILE = '/This/cmd/does/not/exist'
|
226
|
-
end
|
227
|
-
un, pw = RubyBugzilla.credentials_from_file
|
228
|
-
un.should == nil
|
229
|
-
pw.should == nil
|
230
|
-
end
|
231
|
-
|
232
|
-
it "when the YAML input is valid" do
|
233
|
-
# Fake the credentials YAML file.
|
234
|
-
TempCredFile.open('ruby_bugzilla_spec') do |file|
|
235
|
-
ignore_warnings do
|
236
|
-
RubyBugzilla::CREDS_FILE = file.path
|
237
|
-
end
|
238
|
-
un, pw = RubyBugzilla.credentials_from_file
|
239
|
-
un.should == "My Username"
|
240
|
-
pw.should == "My Password"
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
context "#credentials" do
|
246
|
-
it "with no arguments and when the YAML input file is not found" do
|
247
|
-
ignore_warnings do
|
248
|
-
RubyBugzilla::CREDS_FILE = '/This/cmd/does/not/exist'
|
249
|
-
end
|
250
|
-
un, pw = RubyBugzilla.credentials
|
251
|
-
un.should == nil
|
252
|
-
pw.should == nil
|
253
|
-
end
|
254
|
-
|
255
|
-
it "with no arguments and when the YAML input is valid" do
|
256
|
-
# Fake the credentials YAML file.
|
257
|
-
TempCredFile.open('ruby_bugzilla_spec') do |file|
|
258
|
-
ignore_warnings do
|
259
|
-
RubyBugzilla::CREDS_FILE = file.path
|
260
|
-
end
|
261
|
-
un, pw = RubyBugzilla.credentials
|
262
|
-
un.should == "My Username"
|
263
|
-
pw.should == "My Password"
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
it "with arguments and when the YAML input file is not found" do
|
268
|
-
ignore_warnings do
|
269
|
-
RubyBugzilla::CREDS_FILE = '/This/cmd/does/not/exist'
|
270
|
-
end
|
271
|
-
un, pw = RubyBugzilla.credentials("test_un", "test_pw")
|
272
|
-
un.should == "test_un"
|
273
|
-
pw.should == "test_pw"
|
274
|
-
end
|
275
|
-
|
276
|
-
it "with arguments and valid YAML input, favor arguments" do
|
277
|
-
# Fake the credentials YAML file.
|
278
|
-
TempCredFile.open('ruby_bugzilla_spec') do |file|
|
279
|
-
ignore_warnings do
|
280
|
-
RubyBugzilla::CREDS_FILE = file.path
|
281
|
-
end
|
282
|
-
un, pw = RubyBugzilla.credentials("test_un", "test_pw")
|
283
|
-
un.should == "test_un"
|
284
|
-
pw.should == "test_pw"
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
it "with password argument and valid YAML input, favor argument" do
|
289
|
-
# Fake the credentials YAML file.
|
290
|
-
TempCredFile.open('ruby_bugzilla_spec') do |file|
|
291
|
-
ignore_warnings do
|
292
|
-
RubyBugzilla::CREDS_FILE = file.path
|
293
|
-
end
|
294
|
-
un, pw = RubyBugzilla.credentials(nil, "test_pw")
|
295
|
-
un.should == "My Username"
|
296
|
-
pw.should == "test_pw"
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
it "with username argument and valid YAML input, favor argument" do
|
301
|
-
# Fake the credentials YAML file.
|
302
|
-
TempCredFile.open('ruby_bugzilla_spec') do |file|
|
303
|
-
ignore_warnings do
|
304
|
-
RubyBugzilla::CREDS_FILE = file.path
|
305
|
-
end
|
306
|
-
un, pw = RubyBugzilla.credentials("test_un")
|
307
|
-
un.should == "test_un"
|
308
|
-
pw.should == "My Password"
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
end
|
313
|
-
|
314
|
-
context "#options" do
|
315
|
-
it "when the YAML input is valid" do
|
316
|
-
# Fake the credentials YAML file.
|
317
|
-
TempCredFile.open('ruby_bugzilla_spec') do |file|
|
318
|
-
ignore_warnings do
|
319
|
-
RubyBugzilla::CREDS_FILE = file.path
|
320
|
-
end
|
321
|
-
uri, debug = RubyBugzilla.options
|
322
|
-
uri.should == "MyURI"
|
323
|
-
debug.should == "MyDebug"
|
324
|
-
end
|
325
|
-
end
|
326
|
-
it "when the YAML input is is not found" do
|
327
|
-
ignore_warnings do
|
328
|
-
RubyBugzilla::CREDS_FILE = '/This/cmd/does/not/exist'
|
329
|
-
end
|
330
|
-
uri, debug = RubyBugzilla.options
|
331
|
-
uri.should == "https://bugzilla.redhat.com/"
|
332
|
-
debug.should == false
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
127
|
end
|
337
|
-
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'ruby_bugzilla'
|
2
|
-
|
3
1
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
4
2
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
5
3
|
# Require this file using `require "spec_helper"` to ensure that it is only
|
@@ -19,3 +17,5 @@ end
|
|
19
17
|
|
20
18
|
require 'coveralls'
|
21
19
|
Coveralls.wear!
|
20
|
+
|
21
|
+
require 'ruby_bugzilla'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_bugzilla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -113,7 +113,6 @@ files:
|
|
113
113
|
- lib/ruby_bugzilla.rb
|
114
114
|
- lib/ruby_bugzilla/version.rb
|
115
115
|
- ruby_bugzilla.gemspec
|
116
|
-
- samples/bugzilla_credentials.yaml
|
117
116
|
- spec/ruby_bugzilla_spec.rb
|
118
117
|
- spec/spec_helper.rb
|
119
118
|
homepage: http://github.com/ManageIQ/ruby-bugzilla
|
@@ -131,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
130
|
version: '0'
|
132
131
|
segments:
|
133
132
|
- 0
|
134
|
-
hash: -
|
133
|
+
hash: -77384532165350342
|
135
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
135
|
none: false
|
137
136
|
requirements:
|
@@ -140,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
139
|
version: '0'
|
141
140
|
segments:
|
142
141
|
- 0
|
143
|
-
hash: -
|
142
|
+
hash: -77384532165350342
|
144
143
|
requirements: []
|
145
144
|
rubyforge_project:
|
146
145
|
rubygems_version: 1.8.25
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# Copy this file to .bugzilla_credentials.yaml
|
2
|
-
# in your home directory to use it for automated
|
3
|
-
# login to bugzilla
|
4
|
-
#
|
5
|
-
# Note: The dot to make it a hiden file:
|
6
|
-
# <dot>bugzilla_credentials.yaml
|
7
|
-
#
|
8
|
-
---
|
9
|
-
:bugzilla_options:
|
10
|
-
:bugzilla_uri: https://bugzilla.redhat.com/
|
11
|
-
:debug: true
|
12
|
-
:bugzilla_credentials:
|
13
|
-
:username: Your bugzilla login name
|
14
|
-
:password: Your bugzilla password
|