couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woh...@apache.org
Subject [couchdb] 01/03: Replace resource expensive bcrypt test with shorter version (#1231)
Date Wed, 18 Jul 2018 16:19:43 GMT
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch bcrypt
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit e41996b63c8d4261d18730aab2dd91a7793e89ba
Author: Eric Avdey <eiri@eiri.ca>
AuthorDate: Fri Mar 23 15:43:03 2018 -0300

    Replace resource expensive bcrypt test with shorter version (#1231)
    
    * Fix the tests
    
    * Replace resource expensive bcrypt test with shorter version
    
    * Add tests descriptions
---
 src/couch/test/couch_passwords_tests.erl | 34 ++++++++++++++++----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/couch/test/couch_passwords_tests.erl b/src/couch/test/couch_passwords_tests.erl
index c624dba..a566273 100644
--- a/src/couch/test/couch_passwords_tests.erl
+++ b/src/couch/test/couch_passwords_tests.erl
@@ -53,24 +53,24 @@ pbkdf2_test_()->
            )}}]}.
 
 
-
-setup() ->
-    test_util:start(?MODULE, [bcrypt]).
-
-teardown(Ctx)->
-    test_util:stop(Ctx).
-
 bcrypt_test_() ->
     {
         "Bcrypt",
         {
-            foreach,
-            fun setup/0, fun teardown/1,
+            setup,
+            fun() ->
+                test_util:start_applications([bcrypt])
+            end,
+            fun test_util:stop_applications/1,
             [
-                {timeout, 1, fun bcrypt_logRounds_4/0},
-                {timeout, 5, fun bcrypt_logRounds_12/0},
-                {timeout, 180, fun bcrypt_logRounds_18/0},
-                {timeout, 5, fun bcrypt_null_byte/0}
+                {"Log rounds: 4",
+                {timeout, 1, fun bcrypt_logRounds_4/0}},
+                {"Log rounds: 5",
+                {timeout, 1, fun bcrypt_logRounds_5/0}},
+                {"Log rounds: 12",
+                {timeout, 5, fun bcrypt_logRounds_12/0}},
+                {"Null byte",
+                {timeout, 5, fun bcrypt_null_byte/0}}
 
             ]
         }
@@ -79,16 +79,16 @@ bcrypt_test_() ->
 bcrypt_logRounds_4() ->
     bcrypt_assert_equal(<<"password">>, 4).
 
+bcrypt_logRounds_5() ->
+    bcrypt_assert_equal(<<"password">>, 5).
+
 bcrypt_logRounds_12() ->
     bcrypt_assert_equal(<<"password">>, 12).
 
-bcrypt_logRounds_18() ->
-    bcrypt_assert_equal(<<"password">>, 18).
-
 bcrypt_null_byte() ->
     bcrypt_assert_equal(<<"passw\0rd">>, 12).
 
 bcrypt_assert_equal(Password, Rounds) when is_integer(Rounds) ->
     HashPass = couch_passwords:bcrypt(Password, Rounds),
     ReHashPass = couch_passwords:bcrypt(Password, HashPass),
-    ?_assertEqual(HashPass, ReHashPass).
+    ?assertEqual(HashPass, ReHashPass).


Mime
View raw message