Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3A43611DF7 for ; Mon, 16 Jun 2014 22:52:49 +0000 (UTC) Received: (qmail 97940 invoked by uid 500); 16 Jun 2014 22:52:43 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 97791 invoked by uid 500); 16 Jun 2014 22:52:43 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 96696 invoked by uid 99); 16 Jun 2014 22:52:43 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jun 2014 22:52:43 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1E95E941779; Mon, 16 Jun 2014 22:52:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kxepal@apache.org To: commits@couchdb.apache.org Date: Mon, 16 Jun 2014 22:53:11 -0000 Message-Id: In-Reply-To: <86731430c5194546a2188404fdce3eb5@git.apache.org> References: <86731430c5194546a2188404fdce3eb5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [30/50] couchdb commit: updated refs/heads/1963-eunit to bfb7eb9 Port 230-pbkfd2.t etap test suite to eunit Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/38ccb3a4 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/38ccb3a4 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/38ccb3a4 Branch: refs/heads/1963-eunit Commit: 38ccb3a4f98624d1b152d57e6f63ff1aa3c2c54f Parents: 4b01190 Author: Alexander Shorin Authored: Tue Jun 10 00:19:52 2014 +0400 Committer: Alexander Shorin Committed: Tue Jun 17 01:41:45 2014 +0400 ---------------------------------------------------------------------- test/couchdb/Makefile.am | 1 + test/couchdb/couch_passwords_tests.erl | 54 +++++++++++++++++++++++++++++ test/etap/230-pbkfd2.t | 38 -------------------- test/etap/Makefile.am | 1 - 4 files changed, 55 insertions(+), 39 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/38ccb3a4/test/couchdb/Makefile.am ---------------------------------------------------------------------- diff --git a/test/couchdb/Makefile.am b/test/couchdb/Makefile.am index 0403559..46249b8 100644 --- a/test/couchdb/Makefile.am +++ b/test/couchdb/Makefile.am @@ -31,6 +31,7 @@ eunit_files = \ couch_doc_json_tests.erl \ couch_file_tests.erl \ couch_key_tree_tests.erl \ + couch_passwords_tests.erl \ couch_ref_counter_tests.erl \ couch_stream_tests.erl \ couch_stats_tests.erl \ http://git-wip-us.apache.org/repos/asf/couchdb/blob/38ccb3a4/test/couchdb/couch_passwords_tests.erl ---------------------------------------------------------------------- diff --git a/test/couchdb/couch_passwords_tests.erl b/test/couchdb/couch_passwords_tests.erl new file mode 100644 index 0000000..116265c --- /dev/null +++ b/test/couchdb/couch_passwords_tests.erl @@ -0,0 +1,54 @@ +% Licensed under the Apache License, Version 2.0 (the "License"); you may not +% use this file except in compliance with the License. You may obtain a copy of +% the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +% License for the specific language governing permissions and limitations under +% the License. + +-module(couch_passwords_tests). + +-include("couch_eunit.hrl"). + + +pbkdf2_test_()-> + {"PBKDF2", + [ + {"Iterations: 1, length: 20", + ?_assertEqual( + {ok, <<"0c60c80f961f0e71f3a9b524af6012062fe037a6">>}, + couch_passwords:pbkdf2(<<"password">>, <<"salt">>, 1, 20))}, + + {"Iterations: 2, length: 20", + ?_assertEqual( + {ok, <<"ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957">>}, + couch_passwords:pbkdf2(<<"password">>, <<"salt">>, 2, 20))}, + + {"Iterations: 4096, length: 20", + ?_assertEqual( + {ok, <<"4b007901b765489abead49d926f721d065a429c1">>}, + couch_passwords:pbkdf2(<<"password">>, <<"salt">>, 4096, 20))}, + + {"Iterations: 4096, length: 25", + ?_assertEqual( + {ok, <<"3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038">>}, + couch_passwords:pbkdf2(<<"passwordPASSWORDpassword">>, + <<"saltSALTsaltSALTsaltSALTsaltSALTsalt">>, + 4096, 25))}, + {"Null byte", + ?_assertEqual( + {ok, <<"56fa6aa75548099dcc37d7f03425e0c3">>}, + couch_passwords:pbkdf2(<<"pass\0word">>, + <<"sa\0lt">>, + 4096, 16))}, + + {timeout, 180, %% this may runs too long on slow hosts + {"Iterations: 16777216 - this may take some time", + ?_assertEqual( + {ok, <<"eefe3d61cd4da4e4e9945b3d6ba2158c2634e984">>}, + couch_passwords:pbkdf2(<<"password">>, <<"salt">>, 16777216, 20) + )}}]}. http://git-wip-us.apache.org/repos/asf/couchdb/blob/38ccb3a4/test/etap/230-pbkfd2.t ---------------------------------------------------------------------- diff --git a/test/etap/230-pbkfd2.t b/test/etap/230-pbkfd2.t deleted file mode 100644 index d980ef6..0000000 --- a/test/etap/230-pbkfd2.t +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env escript -%% -*- erlang -*- - -% Licensed under the Apache License, Version 2.0 (the "License"); you may not -% use this file except in compliance with the License. You may obtain a copy of -% the License at -% -% http://www.apache.org/licenses/LICENSE-2.0 -% -% Unless required by applicable law or agreed to in writing, software -% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -% License for the specific language governing permissions and limitations under -% the License. - -main(_) -> - test_util:init_code_path(), - etap:plan(6), - etap:is(couch_passwords:pbkdf2(<<"password">>, <<"salt">>, 1, 20), - {ok, <<"0c60c80f961f0e71f3a9b524af6012062fe037a6">>}, - "test vector #1"), - etap:is(couch_passwords:pbkdf2(<<"password">>, <<"salt">>, 2, 20), - {ok, <<"ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957">>}, - "test vector #2"), - etap:is(couch_passwords:pbkdf2(<<"password">>, <<"salt">>, 4096, 20), - {ok, <<"4b007901b765489abead49d926f721d065a429c1">>}, - "test vector #3"), - etap:is(couch_passwords:pbkdf2(<<"passwordPASSWORDpassword">>, - <<"saltSALTsaltSALTsaltSALTsaltSALTsalt">>, 4096, 25), - {ok, <<"3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038">>}, - "test vector #4"), - etap:is(couch_passwords:pbkdf2(<<"pass\0word">>, <<"sa\0lt">>, 4096, 16), - {ok, <<"56fa6aa75548099dcc37d7f03425e0c3">>}, - "test vector #5"), - etap:is(couch_passwords:pbkdf2(<<"password">>, <<"salt">>, 16777216, 20), - {ok, <<"eefe3d61cd4da4e4e9945b3d6ba2158c2634e984">>}, - "test vector #6"), - etap:end_tests(). http://git-wip-us.apache.org/repos/asf/couchdb/blob/38ccb3a4/test/etap/Makefile.am ---------------------------------------------------------------------- diff --git a/test/etap/Makefile.am b/test/etap/Makefile.am index e05a0ad..a6ff368 100644 --- a/test/etap/Makefile.am +++ b/test/etap/Makefile.am @@ -32,7 +32,6 @@ fixture_files = \ fixtures/test.couch tap_files = \ - 230-pbkfd2.t \ 231-cors.t \ 250-upgrade-legacy-view-files.t