-
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.
Test for old way and new issuer to prevent breaking changes
- Loading branch information
Showing
2 changed files
with
39 additions
and
7 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 |
---|---|---|
|
@@ -110,21 +110,22 @@ | |
end | ||
|
||
describe '#provisioning_uri' do | ||
let(:hotp) { ROTP::HOTP.new('a' * 32, name: "[email protected]", issuer: "Example.com") } | ||
|
||
let(:hotp) { ROTP::HOTP.new('a' * 32, name: "[email protected]") } | ||
|
||
it 'created from the otp instance data' do | ||
expect(hotp.provisioning_uri()) | ||
.to eq 'otpauth://hotp/Example.com:m%40mdp.im?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&issuer=Example.com&counter=0' | ||
.to eq 'otpauth://hotp/m%40mdp.im?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=0' | ||
end | ||
|
||
it 'allow passing a name to override the OTP name' do | ||
expect(hotp.provisioning_uri('mark@percival')) | ||
.to eq 'otpauth://hotp/Example.com:mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&issuer=Example.com&counter=0' | ||
.to eq 'otpauth://hotp/mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=0' | ||
end | ||
|
||
it 'also accepts a custom counter value' do | ||
expect(hotp.provisioning_uri('mark@percival', 17)) | ||
.to eq 'otpauth://hotp/Example.com:mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&issuer=Example.com&counter=17' | ||
.to eq 'otpauth://hotp/mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=17' | ||
end | ||
|
||
context 'with non-standard provisioning_params' do | ||
|
@@ -134,5 +135,20 @@ | |
expect(params['image'].first).to eq 'https://example.com/icon.png' | ||
end | ||
end | ||
|
||
context "with an issuer" do | ||
let(:hotp) { ROTP::HOTP.new('a' * 32, name: "[email protected]", issuer: "Example.com") } | ||
|
||
it 'created from the otp instance data' do | ||
expect(hotp.provisioning_uri()) | ||
.to eq 'otpauth://hotp/Example.com:m%40mdp.im?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&issuer=Example.com&counter=0' | ||
end | ||
|
||
it 'allow passing a name to override the OTP name' do | ||
expect(hotp.provisioning_uri('mark@percival')) | ||
.to eq 'otpauth://hotp/Example.com:mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&issuer=Example.com&counter=0' | ||
end | ||
end | ||
|
||
end | ||
end |
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 |
---|---|---|
|
@@ -225,16 +225,16 @@ def get_timecodes(at, b, a) | |
|
||
|
||
describe '#provisioning_uri' do | ||
let(:totp) { ROTP::TOTP.new(TEST_SECRET, name: "[email protected]", issuer: "Example.com") } | ||
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/Example.com:m%40mdp.im?secret=JBSWY3DPEHPK3PXP&issuer=Example.com' | ||
.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/Example.com:mark%40percival?secret=JBSWY3DPEHPK3PXP&issuer=Example.com' | ||
.to eq 'otpauth://totp/mark%40percival?secret=JBSWY3DPEHPK3PXP' | ||
end | ||
|
||
context 'with non-standard provisioning_params' do | ||
|
@@ -249,6 +249,22 @@ def get_timecodes(at, b, a) | |
end | ||
|
||
end | ||
|
||
context "with an issuer" do | ||
let(:totp) { ROTP::TOTP.new(TEST_SECRET, name: "[email protected]", issuer: "Example.com") } | ||
|
||
it 'creates a provisioning uri from the OTP instance' do | ||
expect(totp.provisioning_uri()) | ||
.to eq 'otpauth://totp/Example.com:m%40mdp.im?secret=JBSWY3DPEHPK3PXP&issuer=Example.com' | ||
end | ||
|
||
it 'allow passing a name to override the OTP name' do | ||
expect(totp.provisioning_uri('mark@percival')) | ||
.to eq 'otpauth://totp/Example.com:mark%40percival?secret=JBSWY3DPEHPK3PXP&issuer=Example.com' | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
describe '#now' do | ||
|