source: branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfIsMatchHashPassword_authTypeHmacTest.php @ 22193

Revision 22193, 2.5 KB checked in by shift_hiroko.tamagawa, 11 years ago (diff)

#1977 SC_Utilsの単体テストを追加

  • Property svn:keywords set to Id Rev Date
Line 
1<?php
2
3$HOME = realpath(dirname(__FILE__)) . "/../../../..";
4// このテスト専用の定数の設定
5define('AUTH_TYPE', 'HMAC');
6require_once($HOME . "/tests/class/Common_TestCase.php");
7/*
8 * This file is part of EC-CUBE
9 *
10 * Copyright(c) 2000-2012 LOCKON CO.,LTD. All Rights Reserved.
11 *
12 * http://www.lockon.co.jp/
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
27 */
28
29/**
30 * SC_Utils::sfIsMatchHashPassword()のテストクラス.
31 * 暗号化の詳細については特にテストしていない.
32 *
33 * @author Hiroko Tamagawa
34 * @version $Id$
35 */
36class SC_Utils_sfIsMatchHashPassword_authTypeHmacTest extends Common_TestCase {
37
38
39  protected function setUp() {
40    // parent::setUp();
41  }
42
43  protected function tearDown() {
44    // parent::tearDown();
45  }
46
47  /////////////////////////////////////////
48  public function testSfIsMatchHashPassword_ハッシュ化後の文字列が一致する場合_trueが返る() {
49    $pass = 'ec-cube';
50    $salt = 'salt';
51    $hashpass = SC_Utils_Ex::sfGetHashString($pass, $salt);
52
53    $this->expected = TRUE;
54    $this->actual = SC_Utils::sfIsMatchHashPassword($pass, $hashpass, $salt);
55
56    $this->verify('パスワード文字列比較結果');
57  }
58
59  public function testSfIsMatchHashPassword_ハッシュ化後の文字列が一致しない場合_falseが返る() {
60    $pass = 'ec-cube';
61    $salt = 'salt';
62    $hashpass = 'ec-cube';
63
64    $this->expected = FALSE;
65    $this->actual = SC_Utils::sfIsMatchHashPassword($pass, $hashpass, $salt);
66
67    $this->verify('パスワード文字列比較結果');
68  }
69
70  public function testSfIsMatchHashPassword_saltが未指定の場合_旧バージョンの暗号化で比較される() {
71    $pass = 'ec-cube';
72    $hashpass = sha1($pass . ':' . AUTH_MAGIC);
73
74    $this->expected = TRUE;
75    $this->actual = SC_Utils::sfIsMatchHashPassword($pass, $hashpass);
76
77    $this->verify('パスワード文字列比較結果');
78  }
79
80}
81
Note: See TracBrowser for help on using the repository browser.