Skip to content

Commit

Permalink
More testing to ensure no breaking regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
mdp committed Aug 30, 2023
1 parent 42ef301 commit 5c03995
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
5 changes: 2 additions & 3 deletions spec/lib/rotp/hotp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
let(:counter) { 1234 }
let(:token) { '161024' }
let(:hotp) { ROTP::HOTP.new('a' * 32) }
let(:uri) { hotp.provisioning_uri("mark@percival") }
let(:params) { CGI.parse URI.parse(uri).query }

describe '#at' do
let(:token) { hotp.at counter }
Expand Down Expand Up @@ -110,8 +108,8 @@
end

describe '#provisioning_uri' do

let(:hotp) { ROTP::HOTP.new('a' * 32, name: "[email protected]") }
let(:params) { CGI.parse URI.parse(uri).query }

it 'created from the otp instance data' do
expect(hotp.provisioning_uri())
Expand All @@ -130,6 +128,7 @@

context 'with non-standard provisioning_params' do
let(:hotp) { ROTP::HOTP.new('a' * 32, digits: 8, provisioning_params: {image: 'https://example.com/icon.png'}) }
let(:uri) { hotp.provisioning_uri("mark@percival") }

it 'includes the issuer as parameter' do
expect(params['image'].first).to eq 'https://example.com/icon.png'
Expand Down
24 changes: 13 additions & 11 deletions spec/lib/rotp/totp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
let(:now) { TEST_TIME }
let(:token) { TEST_TOKEN }
let(:totp) { ROTP::TOTP.new TEST_SECRET }
let(:uri) { totp.provisioning_uri("mark@percival") }
let(:params) { CGI.parse URI.parse(uri).query }

describe '#at' do
let(:token) { totp.at now }
Expand Down Expand Up @@ -225,24 +223,28 @@ def get_timecodes(at, b, a)


describe '#provisioning_uri' do
let(:totp) { ROTP::TOTP.new(TEST_SECRET, name: "[email protected]") }
let(:params) { CGI.parse URI.parse(uri).query }

it 'creates a provisioning uri from the OTP instance' do
expect(totp.provisioning_uri())
.to eq 'otpauth://totp/m%40mdp.im?secret=JBSWY3DPEHPK3PXP'
end
context "with a provided name on the TOTP instance" do
let(:totp) { ROTP::TOTP.new(TEST_SECRET, name: "[email protected]") }
it 'creates a provisioning uri from the OTP instance' do
expect(totp.provisioning_uri())
.to eq 'otpauth://totp/m%40mdp.im?secret=JBSWY3DPEHPK3PXP'
end

it 'allow passing a name to override the OTP name' do
expect(totp.provisioning_uri('mark@percival'))
.to eq 'otpauth://totp/mark%40percival?secret=JBSWY3DPEHPK3PXP'
it 'allow passing a name to override the OTP name' do
expect(totp.provisioning_uri('mark@percival'))
.to eq 'otpauth://totp/mark%40percival?secret=JBSWY3DPEHPK3PXP'
end
end

context 'with non-standard provisioning_params' do
let(:totp) {
ROTP::TOTP.new(TEST_SECRET, name: "[email protected]", issuer: "Example.com",
ROTP::TOTP.new(TEST_SECRET,
provisioning_params: { image: 'https://example.com/icon.png' }
)
}
let(:uri) { totp.provisioning_uri("mark@percival") }

it 'includes the issuer as parameter' do
expect(params['image'].first).to eq 'https://example.com/icon.png'
Expand Down

0 comments on commit 5c03995

Please sign in to comment.