-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More testing to ensure no breaking regressions
- Loading branch information
Showing
2 changed files
with
15 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 } | ||
|
@@ -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()) | ||
|
@@ -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' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 } | ||
|
@@ -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' | ||
|