forked from pquerna/otp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with invalid URLs when secret size is not divisible by 5. p…
- Loading branch information
Showing
4 changed files
with
20 additions
and
2 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 |
---|---|---|
|
@@ -151,4 +151,12 @@ func TestGenerate(t *testing.T) { | |
}) | ||
require.Equal(t, otp.ErrGenerateMissingAccountName, err, "generate missing account name.") | ||
require.Nil(t, k, "key should be nil on error.") | ||
|
||
k, err = Generate(GenerateOpts{ | ||
Issuer: "SnakeOil", | ||
AccountName: "[email protected]", | ||
SecretSize: 17, // anything that is not divisable by 5, really | ||
}) | ||
require.NoError(t, err, "Secret size is valid when length not divisable by 5.") | ||
require.NotContains(t, k.Secret(), "=", "Secret has no escaped 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
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 |
---|---|---|
|
@@ -135,4 +135,12 @@ func TestGenerate(t *testing.T) { | |
}) | ||
require.NoError(t, err, "generate larger TOTP") | ||
require.Equal(t, 32, len(k.Secret()), "Secret is 32 bytes long as base32.") | ||
|
||
k, err = Generate(GenerateOpts{ | ||
Issuer: "SnakeOil", | ||
AccountName: "[email protected]", | ||
SecretSize: 13, // anything that is not divisable by 5, really | ||
}) | ||
require.NoError(t, err, "Secret size is valid when length not divisable by 5.") | ||
require.NotContains(t, k.Secret(), "=", "Secret has no escaped characters.") | ||
} |