summaryrefslogtreecommitdiffstats
path: root/modules/util/util_test.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2022-01-26 12:10:10 +0800
committerGitHub <noreply@github.com>2022-01-26 12:10:10 +0800
commit49dd9067535538771ef13623ed1dd9698a4a2151 (patch)
tree7a06ff053683e50d93ad50ce25585a13d54c41e5 /modules/util/util_test.go
parent4889ab52de0b390bb6e96ad6a64ee082585b3d79 (diff)
downloadgitea-49dd9067535538771ef13623ed1dd9698a4a2151.tar.gz
gitea-49dd9067535538771ef13623ed1dd9698a4a2151.zip
Use base32 for 2FA scratch token (#18384)
* Use base32 for 2FA scratch token * rename Secure* to Crypto*, add comments
Diffstat (limited to 'modules/util/util_test.go')
-rw-r--r--modules/util/util_test.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/modules/util/util_test.go b/modules/util/util_test.go
index e2e26b2627..b32cec23d9 100644
--- a/modules/util/util_test.go
+++ b/modules/util/util_test.go
@@ -120,20 +120,20 @@ func Test_NormalizeEOL(t *testing.T) {
}
func Test_RandomInt(t *testing.T) {
- int, err := RandomInt(255)
+ int, err := CryptoRandomInt(255)
assert.True(t, int >= 0)
assert.True(t, int <= 255)
assert.NoError(t, err)
}
func Test_RandomString(t *testing.T) {
- str1, err := RandomString(32)
+ str1, err := CryptoRandomString(32)
assert.NoError(t, err)
matches, err := regexp.MatchString(`^[a-zA-Z0-9]{32}$`, str1)
assert.NoError(t, err)
assert.True(t, matches)
- str2, err := RandomString(32)
+ str2, err := CryptoRandomString(32)
assert.NoError(t, err)
matches, err = regexp.MatchString(`^[a-zA-Z0-9]{32}$`, str1)
assert.NoError(t, err)
@@ -141,13 +141,13 @@ func Test_RandomString(t *testing.T) {
assert.NotEqual(t, str1, str2)
- str3, err := RandomString(256)
+ str3, err := CryptoRandomString(256)
assert.NoError(t, err)
matches, err = regexp.MatchString(`^[a-zA-Z0-9]{256}$`, str3)
assert.NoError(t, err)
assert.True(t, matches)
- str4, err := RandomString(256)
+ str4, err := CryptoRandomString(256)
assert.NoError(t, err)
matches, err = regexp.MatchString(`^[a-zA-Z0-9]{256}$`, str4)
assert.NoError(t, err)
@@ -157,18 +157,18 @@ func Test_RandomString(t *testing.T) {
}
func Test_RandomBytes(t *testing.T) {
- bytes1, err := RandomBytes(32)
+ bytes1, err := CryptoRandomBytes(32)
assert.NoError(t, err)
- bytes2, err := RandomBytes(32)
+ bytes2, err := CryptoRandomBytes(32)
assert.NoError(t, err)
assert.NotEqual(t, bytes1, bytes2)
- bytes3, err := RandomBytes(256)
+ bytes3, err := CryptoRandomBytes(256)
assert.NoError(t, err)
- bytes4, err := RandomBytes(256)
+ bytes4, err := CryptoRandomBytes(256)
assert.NoError(t, err)
assert.NotEqual(t, bytes3, bytes4)