-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #391 from josh-/fix-otp-space-escaping
Ensure that an OTP's issuer and label values are escaped correctly
- Loading branch information
Showing
2 changed files
with
44 additions
and
8 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
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 |
---|---|---|
|
@@ -2656,7 +2656,22 @@ public void one_time_password_generator_time_based_generates_with_standard_optio | |
Label = "[email protected]", | ||
}; | ||
|
||
pg.ToString().ShouldBe("otpauth://totp/Google:[email protected]?secret=pwq65q55&issuer=Google"); | ||
pg.ToString().ShouldBe("otpauth://totp/Google:test%40google.com?secret=pwq65q55&issuer=Google"); | ||
} | ||
|
||
|
||
[Fact] | ||
[Category("PayloadGenerator/OneTimePassword")] | ||
public void one_time_password_generator_time_based_generates_with_standard_options_escapes_issuer_and_label() | ||
{ | ||
var pg = new PayloadGenerator.OneTimePassword | ||
{ | ||
Secret = "pwq6 5q55", | ||
Issuer = "Google Google", | ||
Label = "test/[email protected]", | ||
}; | ||
|
||
pg.ToString().ShouldBe("otpauth://totp/Google%20Google:test%2Ftest%40google.com?secret=pwq65q55&issuer=Google%20Google"); | ||
} | ||
|
||
|
||
|
@@ -2673,7 +2688,23 @@ public void one_time_password_generator_hmac_based_generates_with_standard_optio | |
Counter = 500, | ||
}; | ||
|
||
pg.ToString().ShouldBe("otpauth://hotp/Google:[email protected]?secret=pwq65q55&issuer=Google&counter=500"); | ||
pg.ToString().ShouldBe("otpauth://hotp/Google:test%40google.com?secret=pwq65q55&issuer=Google&counter=500"); | ||
} | ||
|
||
[Fact] | ||
[Category("PayloadGenerator/OneTimePassword")] | ||
public void one_time_password_generator_hmac_based_generates_with_standard_options_escapes_issuer_and_label() | ||
{ | ||
var pg = new PayloadGenerator.OneTimePassword | ||
{ | ||
Secret = "pwq6 5q55", | ||
Issuer = "Google Google", | ||
Label = "test/[email protected]", | ||
Type = PayloadGenerator.OneTimePassword.OneTimePasswordAuthType.HOTP, | ||
Counter = 500, | ||
}; | ||
|
||
pg.ToString().ShouldBe("otpauth://hotp/Google%20Google:test%2Ftest%40google.com?secret=pwq65q55&issuer=Google%20Google&counter=500"); | ||
} | ||
|
||
|
||
|