Skip to content

Commit

Permalink
rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
jshawl committed Feb 12, 2024
1 parent 9fed081 commit 0eec1a9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 0 additions & 2 deletions bin/minisign
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ begin
raise OptionParser::InvalidOption if options.keys.empty?
rescue OptionParser::InvalidOption
Minisign::CLI.usage
puts ''
Minisign::CLI.help
exit 1
end

Expand Down
22 changes: 11 additions & 11 deletions lib/minisign/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@
module Minisign
# The command line interface
module CLI
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
def self.help
def self.usage
puts 'Usage:'
puts 'minisign -G [-f] [-p pubkey_file] [-s seckey_file] [-W]'
puts 'minisign -R [-s seckey_file] [-p pubkey_file]'
puts 'minisign -C [-s seckey_file] [-W]'
puts 'minisign -S [-l] [-x sig_file] [-s seckey_file] [-c untrusted_comment]'
puts ' [-t trusted_comment] -m file [file ...]'
puts 'minisign -V [-H] [-x sig_file] [-p pubkey_file | -P pubkey] [-o] [-q] -m file'
puts ''
puts '-G generate a new key pair'
puts '-R recreate a public key file from a secret key file'
puts '-C change/remove the password of the secret key'
Expand All @@ -29,16 +38,7 @@ def self.help
puts ''
end
# rubocop:enable Metrics/MethodLength

def self.usage
puts 'Usage:'
puts 'minisign -G [-f] [-p pubkey_file] [-s seckey_file] [-W]'
puts 'minisign -R [-s seckey_file] [-p pubkey_file]'
puts 'minisign -C [-s seckey_file] [-W]'
puts 'minisign -S [-l] [-x sig_file] [-s seckey_file] [-c untrusted_comment]'
puts ' [-t trusted_comment] -m file [file ...]'
puts 'minisign -V [-H] [-x sig_file] [-p pubkey_file | -P pubkey] [-o] [-q] -m file'
end
# rubocop:enable Metrics/AbcSize

def self.prompt
$stdin.noecho(&:gets).chomp
Expand Down
13 changes: 7 additions & 6 deletions spec/minisign/e2e_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
expect(`minisign`).to eq(jedisct1)
end
it 'generates a key pair' do
path = "test/generated/cli"
keyname = "jedisct1-encrypted"
path = 'test/generated/cli'
keyname = 'jedisct1-encrypted'
exe = 'test/generated/minisign'
password = SecureRandom.uuid
command = "echo '#{password}\n#{password}' | test/generated/minisign -G -p #{path}/#{keyname}.pub -s #{path}/#{keyname}.key"
command = "echo '#{password}\n#{password}' | #{exe} -G -p #{path}/#{keyname}.pub -s #{path}/#{keyname}.key"
`#{command}`
# prompt -f
expect(`#{command} 2>&1`).to match("Key generation aborted:")
expect(`#{command} 2>&1`).to match('Key generation aborted:')
output = `#{command} -f`
expect(output).not_to match("Key generation aborted:")
expect(output).not_to match('Key generation aborted:')
expect(output).to match("The secret key was saved as #{path}/#{keyname}.key - Keep it secret!")
expect(output).to match("The public key was saved as #{path}/#{keyname}.pub - That one can be public.")
public_key = File.read("#{path}/#{keyname}.pub").split("\n").pop
expect(output.gsub("+","")).to match("minisign -Vm <file> -P #{public_key}".gsub("+",""))
expect(output.gsub('+', '')).to match("minisign -Vm <file> -P #{public_key}".gsub('+', ''))
end
end

0 comments on commit 0eec1a9

Please sign in to comment.