diff options
| author | mo khan <mo@mokhan.ca> | 2014-07-25 15:50:35 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-07-25 15:50:35 -0600 |
| commit | eef9f2a9669a2c2b95fbf9cafd2d63f98c84dd0a (patch) | |
| tree | 3f9e0136328a45817bb8fb5fb1f647e63263bca4 | |
| parent | 21c34f940fd530e412908e0d79c8d61d1278a4fb (diff) | |
dump all secrets.
| -rw-r--r-- | lib/tfa/show_command.rb | 14 | ||||
| -rw-r--r-- | spec/lib/show_command_spec.rb | 28 |
2 files changed, 33 insertions, 9 deletions
diff --git a/lib/tfa/show_command.rb b/lib/tfa/show_command.rb index 0bfcd67..fe9c908 100644 --- a/lib/tfa/show_command.rb +++ b/lib/tfa/show_command.rb @@ -5,9 +5,17 @@ module TFA end def run(arguments) - name = arguments.last - @storage.transaction(true) do - @storage[name] + if arguments.any? + name = arguments.last + @storage.transaction(true) do + @storage[name] + end + else + @storage.transaction(true) do + @storage.roots.map do |key| + @storage[key] + end + end end end end diff --git a/spec/lib/show_command_spec.rb b/spec/lib/show_command_spec.rb index 7cfcb31..a647451 100644 --- a/spec/lib/show_command_spec.rb +++ b/spec/lib/show_command_spec.rb @@ -3,14 +3,30 @@ module TFA subject { ShowCommand.new(storage) } let(:storage) { PStore.new(Tempfile.new('blah').path) } - it "retrieves the secret associated with the key given" do - secret = SecureRandom.uuid - storage.transaction do - storage['production'] = secret + describe "#run" do + context "when looking up the secret for a specific key" do + it "retrieves the secret associated with the key given" do + secret = SecureRandom.uuid + storage.transaction do + storage['production'] = secret + end + + result = subject.run(['production']) + expect(result).to eql(secret) + end end - result = subject.run(['production']) - expect(result).to eql(secret) + context "when a specific name is not given" do + it "returns all the secrets" do + storage.transaction do + storage['development'] = "1" + storage['staging'] = "2" + storage['production'] = "3" + end + + expect(subject.run([])).to eql(["1", "2", "3"]) + end + end end end end |
