Commit 39f9e76
Changed files (2)
lib
tfa
spec
lib
lib/tfa/cli.rb
@@ -29,7 +29,7 @@ module TFA
end
def clean(secret)
- if secret.include?('=')
+ if secret.include?("=")
/secret=([^&]*)/.match(secret).captures.first
else
secret
spec/lib/cli_spec.rb
@@ -11,23 +11,25 @@ module TFA
describe "#add" do
context "when a secret is added" do
it "adds the secret" do
- subject.add('development', secret)
- expect(subject.show('development')).to eql(secret)
+ subject.add("development", secret)
+ expect(subject.show("development")).to eql(secret)
end
end
context "when a full otpauth string is added" do
it "strips out the url for just the secret" do
- subject.add('development', "otpauth://totp/email@email.com?secret=#{secret}&issuer=")
- expect(subject.show('development')).to eql(secret)
+ url = "otpauth://totp/email@email.com?secret=#{secret}&issuer="
+
+ subject.add("development", url)
+ expect(subject.show("development")).to eql(secret)
end
end
end
describe "#totp" do
context "when a single key is given" do
- it "returns a time based one time password for the authentication secret given" do
- subject.add('development', secret)
+ it "returns a time based one time password" do
+ subject.add("development", secret)
expect(subject.totp("development")).to eql(code_for(secret))
end
end