cmd/syncthing: Use lower strength factor in auth tests (fixes #5206) (#5211)

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:
Jakob Borg 2018-09-18 21:56:52 +02:00 committed by GitHub
parent 4f4781d254
commit d7bc0659e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -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")
}