diff options
| author | mo khan <mokhan@users.noreply.github.com> | 2016-11-18 10:29:33 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-18 10:29:33 -0700 |
| commit | 172e3dfb7ff0ebec111a8349daddd50ad86648aa (patch) | |
| tree | 216abfe1666126bda23cc2b27e5222c4e8f0ec9e /spec/lib/totp_command_spec.rb | |
| parent | 6301ea64a649212838a449e7f11af91f72bd5263 (diff) | |
| parent | 32938166ecb1d446101f0b312a3ba4635a010bdc (diff) | |
Merge pull request #6 from mokhan/GH-3v0.0.12
Add a command to remove a secret.
Diffstat (limited to 'spec/lib/totp_command_spec.rb')
| -rw-r--r-- | spec/lib/totp_command_spec.rb | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/spec/lib/totp_command_spec.rb b/spec/lib/totp_command_spec.rb index 5049adc..58405e4 100644 --- a/spec/lib/totp_command_spec.rb +++ b/spec/lib/totp_command_spec.rb @@ -12,7 +12,7 @@ module TFA let(:secret) { ::ROTP::Base32.random_base32 } it "returns a time based one time password for the authentication secret given" do - storage.save('development', secret) + storage.save("development", secret) expect(subject.run("development")).to eql(code_for(secret)) end end @@ -22,20 +22,34 @@ module TFA let(:staging_secret) { ::ROTP::Base32.random_base32 } it "returns the one time password for all keys" do - storage.save('development', development_secret) - storage.save('staging', staging_secret) - expect(subject.run(nil)).to eql([ - { 'development' => code_for(development_secret) }, - { 'staging' => code_for(staging_secret) } + storage.save("development", development_secret) + storage.save("staging", staging_secret) + + expect(subject.run(nil)).to match_array([ + { "development" => code_for(development_secret) }, + { "staging" => code_for(staging_secret) } ]) end end - context 'when the key is not known' do + context "when the key is not known" do it "returns with nothing" do expect(subject.run(["blah"])).to be_empty end end + + context "when the secret is invalid" do + let(:invalid_secret) { "hello world" } + + before :each do + storage.save("development", invalid_secret) + end + + it "returns an error message" do + expected = { "development" => "INVALID SECRET" } + expect(subject.run(["development"])).to match_array([expected]) + end + end end end end |
