spec/lib/rotp/hotp_spec.rb in rotp-6.0.0 vs spec/lib/rotp/hotp_spec.rb in rotp-6.1.0

- old
+ new

@@ -106,31 +106,16 @@ end end end describe '#provisioning_uri' do - let(:uri) { hotp.provisioning_uri('mark@percival') } - let(:params) { CGI.parse URI.parse(uri).query } - - it 'has the correct format' do - expect(uri).to match %r{\Aotpauth:\/\/hotp.+} + it 'accepts the account name' do + expect(hotp.provisioning_uri('mark@percival')) + .to eq 'otpauth://hotp/mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=0' end - it 'includes the secret as parameter' do - expect(params['secret'].first).to eq 'a' * 32 - end - - context 'with default digits' do - it 'does not include digits parameter with default digits' do - expect(params['digits'].first).to be_nil - end - end - - context 'with non-default digits' do - let(:hotp) { ROTP::HOTP.new('a' * 32, digits: 8) } - - it 'includes digits parameter' do - expect(params['digits'].first).to eq '8' - end + it 'also accepts a custom counter value' do + expect(hotp.provisioning_uri('mark@percival', 17)) + .to eq 'otpauth://hotp/mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=17' end end end