diff options
| author | Gavin Miller <gavmille@cisco.com> | 2015-08-06 13:36:59 -0600 |
|---|---|---|
| committer | Gavin Miller <gavmille@cisco.com> | 2015-08-06 13:36:59 -0600 |
| commit | 1c1770a956b85b8545a3f9c1bb2ae7bc047510ea (patch) | |
| tree | 18825089aa794fe2c355a0752fbe326f6e4e18ed | |
| parent | 5f859a714e715ae6a8f71cefd96c1f3487438a84 (diff) | |
Added failing spec & fix for array passing of [name] to TotpCommand.new.run()
| -rw-r--r-- | lib/tfa/cli.rb | 2 | ||||
| -rw-r--r-- | spec/lib/cli_spec.rb | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/tfa/cli.rb b/lib/tfa/cli.rb index a73de1e..07dbdac 100644 --- a/lib/tfa/cli.rb +++ b/lib/tfa/cli.rb @@ -18,7 +18,7 @@ module TFA desc "totp NAME", "generate a Time based One Time Password" def totp(name = nil) - TotpCommand.new(storage).run([name]) + TotpCommand.new(storage).run(name) end private diff --git a/spec/lib/cli_spec.rb b/spec/lib/cli_spec.rb new file mode 100644 index 0000000..2081817 --- /dev/null +++ b/spec/lib/cli_spec.rb @@ -0,0 +1,20 @@ +module TFA + describe CLI do + subject { CLI.new } + + def code_for(secret) + ::ROTP::TOTP.new(secret).now + end + + describe "#totp" do + context "when a single key is given" do + let(:secret) { ::ROTP::Base32.random_base32 } + + it "returns a time based one time password for the authentication secret given" do + subject.add('development', secret) + expect(subject.totp("development")).to eql(code_for(secret)) + end + end + end + end +end |
