Commit 5a175f5
Changed files (2)
lib
tfa
spec
lib/tfa/totp_command.rb
@@ -5,7 +5,7 @@ module TFA
end
def run(arguments)
- return password_for(secret_for(arguments.first)) if arguments.any?
+ return password_for(secret_for(arguments.first)) if valid?(arguments)
all_passwords
end
@@ -24,7 +24,11 @@ module TFA
end
def secret_for(key)
- @storage.secret_for(key)
+ @storage.secret_for(key)
+ end
+
+ def valid?(arguments)
+ arguments.any? && secret_for(arguments.first)
end
end
end
spec/lib/totp_command_spec.rb
@@ -31,6 +31,12 @@ module TFA
])
end
end
+
+ context 'when the key is not known' do
+ it "returns with nothing" do
+ expect(subject.run(["blah"])).to be_empty
+ end
+ end
end
end
end