mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 07:12:27 +00:00
Newly added auth tests uses a high strength factor for bcrypt, which takes ages under -race. No reason for that.
This commit is contained in:
parent
4f4781d254
commit
d7bc0659e4
@ -7,12 +7,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
var passwordHashBytes []byte
|
||||
|
||||
func init() {
|
||||
passwordHashBytes, _ = bcrypt.GenerateFromPassword([]byte("pass"), 0)
|
||||
}
|
||||
|
||||
func TestStaticAuthOK(t *testing.T) {
|
||||
passwordHashBytes, _ := bcrypt.GenerateFromPassword([]byte("pass"), 14)
|
||||
ok := authStatic("user", "pass", "user", string(passwordHashBytes))
|
||||
if !ok {
|
||||
t.Fatalf("should pass auth")
|
||||
@ -20,7 +26,6 @@ func TestStaticAuthOK(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSimpleAuthUsernameFail(t *testing.T) {
|
||||
passwordHashBytes, _ := bcrypt.GenerateFromPassword([]byte("pass"), 14)
|
||||
ok := authStatic("userWRONG", "pass", "user", string(passwordHashBytes))
|
||||
if ok {
|
||||
t.Fatalf("should fail auth")
|
||||
@ -28,8 +33,7 @@ func TestSimpleAuthUsernameFail(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStaticAuthPasswordFail(t *testing.T) {
|
||||
passwordHashBytes, _ := bcrypt.GenerateFromPassword([]byte("passWRONG"), 14)
|
||||
ok := authStatic("user", "pass", "user", string(passwordHashBytes))
|
||||
ok := authStatic("user", "passWRONG", "user", string(passwordHashBytes))
|
||||
if ok {
|
||||
t.Fatalf("should fail auth")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user