Commit 1954d7b

mokha <mokha@cisco.com>
2018-12-03 04:34:31
list keys instead of all secrets.
1 parent 9428722
Changed files (2)
lib
spec
lib/tfa/cli.rb
@@ -20,7 +20,7 @@ module TFA
 
     desc "show NAME", "shows the secret for the given key"
     def show(name = nil)
-      name ? storage.secret_for(name) : storage.all
+      name ? storage.secret_for(name) : storage.all.map { |x| x.keys }.flatten.sort
     end
 
     desc "totp NAME", "generate a Time based One Time Password using the secret associated with the given NAME."
spec/lib/cli_spec.rb
@@ -41,14 +41,14 @@ module TFA
       end
 
       context "when no key is given" do
-        it "returns the secret for all keys" do
+        it "returns the name of each item" do
           key = SecureRandom.uuid
           subject.add(key, dev_secret)
           subject.add("production", prod_secret)
 
           result = subject.show.to_s
-          expect(result).to include(dev_secret)
-          expect(result).to include(prod_secret)
+          expect(result).to include(key)
+          expect(result).to include("production")
         end
       end
     end