Skip to content

Commit e545b77

Browse files
committedJan 14, 2017
Add ssl & proxy config
1 parent bd1cbf5 commit e545b77

File tree

6 files changed

+42
-16
lines changed

6 files changed

+42
-16
lines changed
 

‎Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
terjira (0.2.10)
4+
terjira (0.3.0)
55
activesupport (= 4.0.13)
66
jira-ruby (~> 1.1.3)
77
thor (~> 0.19.0)

‎README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ or check OSX 10.11 issue [#12](https://github.com/keepcosmos/terjira/issues/12)
3535
```
3636
Authentication:
3737
jira login # Login your Jira
38+
# [--ssl-config] with ssl configuration
39+
# [--proxy-config] with proxy configuration
3840
jira logout # Logout your Jira
3941
4042
Project:
@@ -53,13 +55,15 @@ Sprint:
5355
jira sprint ( ls | list ) # List of all sprint from the board
5456
jira sprint [SPRINT_ID] # Show the sprint
5557
jira sprint active # Show active sprints and issues
58+
# To show issues on the sprint(include no assignee)
59+
                                    # pass `--assignee ALL` or `-a ALL`.
5660
5761
Issue:
5862
jira issue help [COMMAND] # Describe one specific subcommand
5963
jira issue ( ls | list ) # List of issues
6064
# default assignee option is current loggined user
6165
# To show issues of all users(include no assignee)
62-
                                    # pass `--assignee ALL` option.
66+
                                    # pass `--assignee ALL` or `-a ALL`.
6367
jira issue jql "[QUERY]" # Search issues with JQL
6468
# ex)
6569
# jira issue jql "project = 'TEST' AND summary ~ 'authentication'"
@@ -76,15 +80,15 @@ Issue:
7680
7781
```
7882

79-
## Todo
83+
84+
## Feature Todo
8085
**Contributions are welcome!**
8186
- [x] Add JQL command for find issues
8287
- [x] Search issues by keyword
8388
- [ ] Manage worklog and estimate of issues
8489
- [ ] Manage component and version of issues
8590
- [ ] Track history of transitions
8691
- [ ] More friendly help
87-
- [ ] Improve test coverage
8892

8993
## Development
9094

‎lib/terjira.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ module Terjira
1111
# Main CLI
1212
class CLI < Thor
1313
desc 'login', 'login your Jira'
14+
option "ssl-config", type: :boolean
15+
option "proxy-config", type: :boolean
1416
def login
1517
pastel = Pastel.new
1618
Client::Base.expire_auth_options
17-
Client::Base.build_auth_options
19+
Client::Base.build_auth_options(options)
1820

1921
# for touch base resource
2022
Client::Field.all

‎lib/terjira/client/auth_option_builder.rb

+25-5
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,23 @@ module Client
66
module AuthOptionBuilder
77
AUTH_CACHE_KEY = 'auth'.freeze
88

9-
def build_auth_options(cache_key = AUTH_CACHE_KEY)
9+
def build_auth_options(options = {})
10+
cache_key = options[:cache_key] || AUTH_CACHE_KEY
1011
auth_file_cache.fetch cache_key do
11-
build_auth_options_by_tty
12+
build_auth_options_by_tty(options)
1213
end
1314
end
1415

15-
def build_auth_options_by_cached(cache_key = AUTH_CACHE_KEY)
16+
def build_auth_options_by_cached(options = {})
17+
cache_key = options[:cache_key] || AUTH_CACHE_KEY
1618
auth_file_cache.get(cache_key)
1719
end
1820

19-
def expire_auth_options(cache_key = AUTH_CACHE_KEY)
21+
def expire_auth_options
2022
Terjira::FileCache.clear_all
2123
end
2224

23-
def build_auth_options_by_tty
25+
def build_auth_options_by_tty(options = {})
2426
puts 'Login will be required...'
2527
prompt = TTY::Prompt.new
2628

@@ -29,8 +31,26 @@ def build_auth_options_by_tty
2931
key(:context_path).ask('Context path:', default: '')
3032
key(:username).ask('Username:', required: true)
3133
key(:password).mask('Password:', required: true)
34+
35+
if options['ssl-config']
36+
key(:use_ssl).yes?('Use SSL?')
37+
key(:ssl_verify_mode).select('Verify mode:') do |menu|
38+
menu.choice 'Verify peer', OpenSSL::SSL::VERIFY_PEER
39+
menu.choice 'Verify client once', OpenSSL::SSL::VERIFY_CLIENT_ONCE
40+
menu.choice 'Verify fail if no peer cert', OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
41+
menu.choice 'Verify none', OpenSSL::SSL::VERIFY_NONE
42+
end
43+
end
44+
45+
if options['proxy-config']
46+
key(:proxy_address).ask("Proxy address: ", default: nil)
47+
key(:proxy_port).ask("Proxy port: ", default: nil)
48+
end
3249
end
50+
3351
result[:auth_type] = :basic
52+
result[:use_ssl] ||= false if result[:site] =~ /http\:\/\//
53+
3454
result
3555
end
3656

‎lib/terjira/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'terjira/utils/file_cache'
22

33
module Terjira
4-
VERSION = '0.2.10'.freeze
4+
VERSION = '0.3.0'.freeze
55

66
class VersionChecker
77
VERSION_CHECK_DURATION = (60 * 60 * 24 * 5).freeze

‎spec/auth_option_builder_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class TestClass
2626
prompt.input.rewind
2727

2828
capture(:stdout) do
29-
TestClass.build_auth_options('testauthpath')
30-
result = TestClass.build_auth_options_by_cached('testauthpath')
29+
TestClass.build_auth_options(cache_key: 'testauthpath')
30+
result = TestClass.build_auth_options_by_cached(cache_key: 'testauthpath')
3131
expect(result).to eq(auth_options)
3232
end
3333
end
@@ -36,9 +36,9 @@ class TestClass
3636
prompt.input << inputs
3737
prompt.input.rewind
3838
capture(:stdout) do
39-
TestClass.build_auth_options('testauthpath')
40-
TestClass.expire_auth_options('testauthpath')
41-
result = TestClass.build_auth_options_by_cached('testauthpath')
39+
TestClass.build_auth_options(cache_key: 'testauthpath')
40+
TestClass.expire_auth_options
41+
result = TestClass.build_auth_options_by_cached(cache_key: 'testauthpath')
4242
expect(result).to eq(nil)
4343
end
4444
end

0 commit comments

Comments
 (0)
Please sign in to comment.