From d7bc0659e4fd842319bcf0b5b80e53579702d665 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Tue, 18 Sep 2018 21:56:52 +0200 Subject: [PATCH] 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. --- cmd/syncthing/gui_auth_test.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/syncthing/gui_auth_test.go b/cmd/syncthing/gui_auth_test.go index b1b0e5a30..eba6ced77 100644 --- a/cmd/syncthing/gui_auth_test.go +++ b/cmd/syncthing/gui_auth_test.go @@ -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") }