File tree 4 files changed +10
-16
lines changed
modules/auth/password/pwn
4 files changed +10
-16
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ package user_test
5
5
6
6
import (
7
7
"context"
8
+ "crypto/rand"
8
9
"fmt"
9
- "math/rand"
10
10
"strings"
11
11
"testing"
12
12
"time"
Original file line number Diff line number Diff line change 4
4
package pwn
5
5
6
6
import (
7
- "math/rand"
7
+ "math/rand/v2 "
8
8
"net/http"
9
- "os"
10
9
"strings"
11
10
"testing"
12
11
"time"
@@ -18,11 +17,6 @@ var client = New(WithHTTP(&http.Client{
18
17
Timeout : time .Second * 2 ,
19
18
}))
20
19
21
- func TestMain (m * testing.M ) {
22
- rand .Seed (time .Now ().Unix ())
23
- os .Exit (m .Run ())
24
- }
25
-
26
20
func TestPassword (t * testing.T ) {
27
21
// Check input error
28
22
_ , err := client .CheckPassword ("" , false )
@@ -81,24 +75,24 @@ func testPassword() string {
81
75
82
76
// Set special character
83
77
for i := 0 ; i < 5 ; i ++ {
84
- random := rand .Intn (len (specialCharSet ))
78
+ random := rand .IntN (len (specialCharSet ))
85
79
password .WriteString (string (specialCharSet [random ]))
86
80
}
87
81
88
82
// Set numeric
89
83
for i := 0 ; i < 5 ; i ++ {
90
- random := rand .Intn (len (numberSet ))
84
+ random := rand .IntN (len (numberSet ))
91
85
password .WriteString (string (numberSet [random ]))
92
86
}
93
87
94
88
// Set uppercase
95
89
for i := 0 ; i < 5 ; i ++ {
96
- random := rand .Intn (len (upperCharSet ))
90
+ random := rand .IntN (len (upperCharSet ))
97
91
password .WriteString (string (upperCharSet [random ]))
98
92
}
99
93
100
94
for i := 0 ; i < 5 ; i ++ {
101
- random := rand .Intn (len (allCharSet ))
95
+ random := rand .IntN (len (allCharSet ))
102
96
password .WriteString (string (allCharSet [random ]))
103
97
}
104
98
inRune := []rune (password .String ())
Original file line number Diff line number Diff line change 4
4
package integration
5
5
6
6
import (
7
- "math/rand"
7
+ "math/rand/v2 "
8
8
"net/http"
9
9
"net/url"
10
10
"testing"
@@ -18,7 +18,7 @@ import (
18
18
func StringWithCharset (length int , charset string ) string {
19
19
b := make ([]byte , length )
20
20
for i := range b {
21
- b [i ] = charset [rand .Intn (len (charset ))]
21
+ b [i ] = charset [rand .IntN (len (charset ))]
22
22
}
23
23
return string (b )
24
24
}
@@ -37,7 +37,7 @@ func BenchmarkRepoBranchCommit(b *testing.B) {
37
37
b .ResetTimer ()
38
38
b .Run ("CreateBranch" , func (b * testing.B ) {
39
39
b .StopTimer ()
40
- branchName := StringWithCharset (5 + rand .Intn (10 ), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" )
40
+ branchName := StringWithCharset (5 + rand .IntN (10 ), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" )
41
41
b .StartTimer ()
42
42
for i := 0 ; i < b .N ; i ++ {
43
43
b .Run ("new_" + branchName , func (b * testing.B ) {
Original file line number Diff line number Diff line change @@ -5,9 +5,9 @@ package integration
5
5
6
6
import (
7
7
"bytes"
8
+ "crypto/rand"
8
9
"encoding/hex"
9
10
"fmt"
10
- "math/rand"
11
11
"net/http"
12
12
"net/url"
13
13
"os"
You can’t perform that action at this time.
0 commit comments