diff options
| -rw-r--r-- | Gemfile.lock | 26 | ||||
| -rw-r--r-- | hcl.gemspec | 3 | ||||
| -rw-r--r-- | lib/hcl/app.rb | 7 | ||||
| -rw-r--r-- | test/app_test.rb | 13 |
4 files changed, 35 insertions, 14 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index 4131a42..4bc6aee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,7 +9,7 @@ PATH highline (= 1.7.2) pry (= 0.10.1) trollop (= 2.1.2) - yajl-ruby (= 1.2.1) + yajl-ruby (= 1.3.0) GEM remote: https://rubygems.org/ @@ -17,18 +17,19 @@ GEM byebug (5.0.0) columnize (= 0.9.0) chronic (0.10.2) - coderay (1.1.0) + coderay (1.1.1) columnize (0.9.0) docile (1.1.5) escape_utils (1.1.0) faraday (0.9.1) multipart-post (>= 1.2, < 3) + ffi (1.9.18-java) gem-man (0.3.0) highline (1.7.2) hpricot (0.8.6) hpricot (0.8.6-java) - json (1.8.3) - json (1.8.3-java) + json (2.1.0) + json (2.1.0-java) metaclass (0.0.4) method_source (0.8.2) minitest (5.7.0) @@ -40,6 +41,11 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) + pry (0.10.1-java) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + spoon (~> 0.0) rake (10.4.2) rdiscount (2.1.8) ronn (0.7.3) @@ -47,14 +53,16 @@ GEM mustache (>= 0.7.0) rdiscount (>= 1.5.8) rubygems-tasks (0.2.4) - simplecov (0.10.0) + simplecov (0.14.1) docile (~> 1.1.0) - json (~> 1.8) + json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) + simplecov-html (0.10.1) slop (3.6.0) + spoon (0.0.6) + ffi trollop (2.1.2) - yajl-ruby (1.2.1) + yajl-ruby (1.3.0) yard (0.8.7.6) PLATFORMS @@ -73,4 +81,4 @@ DEPENDENCIES yard BUNDLED WITH - 1.14.3 + 1.15.1 diff --git a/hcl.gemspec b/hcl.gemspec index 076f0ca..6bceead 100644 --- a/hcl.gemspec +++ b/hcl.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'chronic', '0.10.2' s.add_runtime_dependency 'highline', '1.7.2' s.add_runtime_dependency 'faraday', '0.9.1' - s.add_runtime_dependency 'yajl-ruby', '1.2.1' + s.add_runtime_dependency 'yajl-ruby', '1.3.0' s.add_runtime_dependency 'escape_utils', '1.1.0' s.add_runtime_dependency 'pry', '0.10.1' s.add_development_dependency 'rake' @@ -30,4 +30,3 @@ Gem::Specification.new do |s| s.add_development_dependency 'simplecov' s.add_development_dependency 'minitest' end - diff --git a/lib/hcl/app.rb b/lib/hcl/app.rb index 321b3d5..4065c46 100644 --- a/lib/hcl/app.rb +++ b/lib/hcl/app.rb @@ -1,5 +1,6 @@ require 'yaml' require 'fileutils' +require 'shellwords' require 'trollop' require 'highline/import' @@ -168,7 +169,7 @@ EOM puts "Please specify your Harvest credentials.\n" config['login'] = ask("Email Address: ").to_s config['password'] = ask("Password: ") { |q| q.echo = false }.to_s - config['subdomain'] = ask("Subdomain: ").to_s + config['subdomain'] = ask("Subdomain (acme in acme.harvestapp.com): ").to_s @http = HCl::Net.new config write_config config end @@ -226,10 +227,10 @@ EOM end def save_password config - if system("security add-internet-password -U -l hcl -a '%s' -s '%s.harvestapp.com' -w '%s'" % [ + if system("security add-internet-password -U -l hcl -a '%s' -s '%s.harvestapp.com' -w %s" % [ config['login'], config['subdomain'], - config['password'], + Shellwords.escape(config['password']), ]) then config.delete('password') end end end diff --git a/test/app_test.rb b/test/app_test.rb index 4c997d7..499909d 100644 --- a/test/app_test.rb +++ b/test/app_test.rb @@ -65,4 +65,17 @@ class AppTest < HCl::TestCase assert_match /API failure/i, error_output end + def test_save_password_allows_passwords_with_quotes + app = HCl::App.new + app.expects(:system).with("security add-internet-password -U -l hcl -a 'taco@example.com' -s 'acme.harvestapp.com' -w pass\\ with\\ \\'\\ quote") + + config = { + 'login' => 'taco@example.com', + 'subdomain' => 'acme', + 'password' => "pass with ' quote", + } + + app.send :save_password, config + end + end |
