File tree Expand file tree Collapse file tree 4 files changed +10
-16
lines changed
modules/auth/password/pwn Expand file tree Collapse file tree 4 files changed +10
-16
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ package user_test
55
66import (
77 "context"
8+ "crypto/rand"
89 "fmt"
9- "math/rand"
1010 "strings"
1111 "testing"
1212 "time"
Original file line number Diff line number Diff line change 44package pwn
55
66import (
7- "math/rand"
7+ "math/rand/v2 "
88 "net/http"
9- "os"
109 "strings"
1110 "testing"
1211 "time"
@@ -18,11 +17,6 @@ var client = New(WithHTTP(&http.Client{
1817 Timeout : time .Second * 2 ,
1918}))
2019
21- func TestMain (m * testing.M ) {
22- rand .Seed (time .Now ().Unix ())
23- os .Exit (m .Run ())
24- }
25-
2620func TestPassword (t * testing.T ) {
2721 // Check input error
2822 _ , err := client .CheckPassword ("" , false )
@@ -81,24 +75,24 @@ func testPassword() string {
8175
8276 // Set special character
8377 for i := 0 ; i < 5 ; i ++ {
84- random := rand .Intn (len (specialCharSet ))
78+ random := rand .IntN (len (specialCharSet ))
8579 password .WriteString (string (specialCharSet [random ]))
8680 }
8781
8882 // Set numeric
8983 for i := 0 ; i < 5 ; i ++ {
90- random := rand .Intn (len (numberSet ))
84+ random := rand .IntN (len (numberSet ))
9185 password .WriteString (string (numberSet [random ]))
9286 }
9387
9488 // Set uppercase
9589 for i := 0 ; i < 5 ; i ++ {
96- random := rand .Intn (len (upperCharSet ))
90+ random := rand .IntN (len (upperCharSet ))
9791 password .WriteString (string (upperCharSet [random ]))
9892 }
9993
10094 for i := 0 ; i < 5 ; i ++ {
101- random := rand .Intn (len (allCharSet ))
95+ random := rand .IntN (len (allCharSet ))
10296 password .WriteString (string (allCharSet [random ]))
10397 }
10498 inRune := []rune (password .String ())
Original file line number Diff line number Diff line change 44package integration
55
66import (
7- "math/rand"
7+ "math/rand/v2 "
88 "net/http"
99 "net/url"
1010 "testing"
@@ -18,7 +18,7 @@ import (
1818func StringWithCharset (length int , charset string ) string {
1919 b := make ([]byte , length )
2020 for i := range b {
21- b [i ] = charset [rand .Intn (len (charset ))]
21+ b [i ] = charset [rand .IntN (len (charset ))]
2222 }
2323 return string (b )
2424}
@@ -37,7 +37,7 @@ func BenchmarkRepoBranchCommit(b *testing.B) {
3737 b .ResetTimer ()
3838 b .Run ("CreateBranch" , func (b * testing.B ) {
3939 b .StopTimer ()
40- branchName := StringWithCharset (5 + rand .Intn (10 ), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" )
40+ branchName := StringWithCharset (5 + rand .IntN (10 ), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" )
4141 b .StartTimer ()
4242 for i := 0 ; i < b .N ; i ++ {
4343 b .Run ("new_" + branchName , func (b * testing.B ) {
Original file line number Diff line number Diff line change @@ -5,9 +5,9 @@ package integration
55
66import (
77 "bytes"
8+ "crypto/rand"
89 "encoding/hex"
910 "fmt"
10- "math/rand"
1111 "net/http"
1212 "net/url"
1313 "os"
You can’t perform that action at this time.
0 commit comments