|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Nextcloud - user_sql |
| 4 | + * |
| 5 | + * @copyright 2018 Marcin Łojewski <dev@mlojewski.me> |
| 6 | + * @author Marcin Łojewski <dev@mlojewski.me> |
| 7 | + * |
| 8 | + * This program is free software: you can redistribute it and/or modify |
| 9 | + * it under the terms of the GNU Affero General Public License as |
| 10 | + * published by the Free Software Foundation, either version 3 of the |
| 11 | + * License, or (at your option) any later version. |
| 12 | + * |
| 13 | + * This program is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU Affero General Public License for more details. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU Affero General Public License |
| 19 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 20 | + */ |
| 21 | + |
| 22 | +namespace Tests\UserSQL\Crypto; |
| 23 | + |
| 24 | +use OCA\UserSQL\Crypto\Drupal7; |
| 25 | +use OCA\UserSQL\Crypto\IPasswordAlgorithm; |
| 26 | +use OCP\IL10N; |
| 27 | +use Test\TestCase; |
| 28 | + |
| 29 | +/** |
| 30 | + * Unit tests for class <code>Drupal7</code>. |
| 31 | + * |
| 32 | + * @author Marcin Łojewski <dev@mlojewski.me> |
| 33 | + */ |
| 34 | +class Drupal7Test extends TestCase |
| 35 | +{ |
| 36 | + /** |
| 37 | + * @var IPasswordAlgorithm |
| 38 | + */ |
| 39 | + private $crypto; |
| 40 | + |
| 41 | + public function testCheckPassword() |
| 42 | + { |
| 43 | + $this->assertTrue( |
| 44 | + $this->crypto->checkPassword( |
| 45 | + "password", "\$S\$DC7eCpJQ3SUQtW4Bp.vKb2rpeaffi4iqk9OpYwJyEoSMsezn67Sl" |
| 46 | + ) |
| 47 | + ); |
| 48 | + } |
| 49 | + |
| 50 | + public function testPasswordHash() |
| 51 | + { |
| 52 | + $hash = $this->crypto->getPasswordHash("password"); |
| 53 | + $this->assertTrue($this->crypto->checkPassword("password", $hash)); |
| 54 | + } |
| 55 | + |
| 56 | + protected function setUp() |
| 57 | + { |
| 58 | + parent::setUp(); |
| 59 | + $this->crypto = new Drupal7($this->createMock(IL10N::class)); |
| 60 | + } |
| 61 | +} |
0 commit comments