File: cli_spec.rb

package info (click to toggle)
ruby-rotp 2.1.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 340 kB
  • ctags: 79
  • sloc: ruby: 726; makefile: 16
file content (29 lines) | stat: -rw-r--r-- 614 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'spec_helper'
require 'rotp/cli'

RSpec.describe ROTP::CLI do
  let(:cli)    { described_class.new('executable', argv) }
  let(:output) { cli.output }
  let(:now)    { Time.utc 2012,1,1 }

  before do
    Timecop.freeze now
  end

  context 'generating a TOTP' do
    let(:argv) { %w(--secret JBSWY3DPEHPK3PXP) }

    it 'prints the corresponding token' do
      expect(output).to eq '068212'
    end
  end

  context 'generating a HOTP' do
    let(:argv) { %W(--hmac --secret #{'a' * 32} --counter 1234) }

    it 'prints the corresponding token' do
      expect(output).to eq '161024'
    end
  end

end