Permalink
Browse files

omit -pass option in decrypt command if --password-file not given

  • Loading branch information...
1 parent f3fc6dc commit 4c66ebcfed395472fb0be57edbff280ed15da387 Brian D. Burns committed Jun 7, 2012
Showing with 15 additions and 2 deletions.
  1. +2 −2 lib/backup/cli/utility.rb
  2. +13 −0 spec/cli/utility_spec.rb
@@ -173,7 +173,7 @@ def decrypt
case options[:encryptor].downcase
when 'openssl'
base64 = options[:base64] ? '-base64' : ''
- password = options[:password_file] ? "-pass file:#{options[:password_file]}" : ''
+ password = options[:password_file].empty? ? '' : "-pass file:#{options[:password_file]}"
salt = options[:salt] ? '-salt' : ''
%x[openssl aes-256-cbc -d #{base64} #{password} #{salt} -in '#{options[:in]}' -out '#{options[:out]}']
when 'gpg'
@@ -224,7 +224,7 @@ def dependencies
puts "Please wait..\n\n"
puts %x[gem install #{options[:install]} -v '#{Backup::Dependency.all[options[:install]][:version]}']
end
-
+
if options[:installed]
puts %x[gem list -i -v '#{Backup::Dependency.all[options[:installed]][:version]}' #{options[:installed]}]
end
View
@@ -305,6 +305,19 @@
# cli.start
# end
#
+# it 'should omit -pass option if no --password-file given' do
+# ARGV.replace(['decrypt', '--encryptor', 'openssl',
+# '--in', 'in_file',
+# '--out', 'out_file',
+# '--base64', '--salt'])
+#
+# cli.any_instance.expects(:`).with(
+# "openssl aes-256-cbc -d -base64 -salt " +
+# "-in 'in_file' -out 'out_file'"
+# )
+# cli.start
+# end
+#
# it 'should perform GnuPG decryption' do
# ARGV.replace(['decrypt', '--encryptor', 'gpg',
# '--in', 'in_file',

0 comments on commit 4c66ebc

Please sign in to comment.