Skip to content

Commit

Permalink
omit -pass option in decrypt command if --password-file not given
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian D. Burns committed Jun 7, 2012
1 parent f3fc6dc commit 4c66ebc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/backup/cli/utility.rb
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions spec/cli/utility_spec.rb
Expand Up @@ -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',
Expand Down

0 comments on commit 4c66ebc

Please sign in to comment.