112 lines
3.6 KiB
PHP
112 lines
3.6 KiB
PHP
|
<?php
|
||
|
|
||
|
/**
|
||
|
* This Software is the property of Data Development and is protected
|
||
|
* by copyright law - it is NOT Freeware.
|
||
|
* Any unauthorized use of this software without a valid license
|
||
|
* is a violation of the license agreement and will be prosecuted by
|
||
|
* civil and criminal law.
|
||
|
* http://www.shopmodule.com
|
||
|
*
|
||
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||
|
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||
|
* @link http://www.oxidmodule.com
|
||
|
*/
|
||
|
|
||
|
namespace D3\Webauthn\tests\integration;
|
||
|
|
||
|
use D3\Webauthn\Modules\Application\Component\d3_webauthn_UserComponent;
|
||
|
use OxidEsales\Eshop\Application\Controller\AccountController;
|
||
|
|
||
|
class passwordFrontendAuthTest extends integrationTestCase
|
||
|
{
|
||
|
protected $userList = [
|
||
|
1 => 'userId1',
|
||
|
2 => 'userId2',
|
||
|
3 => 'userId3',
|
||
|
];
|
||
|
|
||
|
public function createTestData()
|
||
|
{
|
||
|
$this->createUser(
|
||
|
$this->userList[1],
|
||
|
[
|
||
|
'oxactive' => 1,
|
||
|
'oxrights' => 'user',
|
||
|
'oxshopid' => 1,
|
||
|
'oxusername' => 'noadmin@user.localhost',
|
||
|
'oxpassword' => '$2y$10$b3O5amXZVMGGZbL4X10TIOHiOwEkq3C0ofObuTgHAS4Io0uMLauUS', // 123456
|
||
|
'oxstreet' => __CLASS__
|
||
|
]
|
||
|
);
|
||
|
|
||
|
$this->createUser(
|
||
|
$this->userList[2],
|
||
|
[
|
||
|
'oxactive' => 1,
|
||
|
'oxrights' => 'user',
|
||
|
'oxshopid' => 2,
|
||
|
'oxusername' => 'wrongshop@user.localhost',
|
||
|
'oxpassword' => '$2y$10$b3O5amXZVMGGZbL4X10TIOHiOwEkq3C0ofObuTgHAS4Io0uMLauUS', // 123456
|
||
|
'oxstreet' => __CLASS__
|
||
|
]
|
||
|
);
|
||
|
|
||
|
$this->createUser(
|
||
|
$this->userList[3],
|
||
|
[
|
||
|
'oxactive' => 0,
|
||
|
'oxrights' => 'user',
|
||
|
'oxshopid' => 1,
|
||
|
'oxusername' => 'inactive@user.localhost',
|
||
|
'oxpassword' => '$2y$10$b3O5amXZVMGGZbL4X10TIOHiOwEkq3C0ofObuTgHAS4Io0uMLauUS', // 123456
|
||
|
'oxstreet' => __CLASS__
|
||
|
]
|
||
|
);
|
||
|
}
|
||
|
|
||
|
public function cleanTestData()
|
||
|
{
|
||
|
$this->deleteUser($this->userList[1]);
|
||
|
$this->deleteUser($this->userList[2]);
|
||
|
$this->deleteUser($this->userList[3]);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @test
|
||
|
* @dataProvider loginDataProvider
|
||
|
*/
|
||
|
public function testCheckLoginReturn($username, $password, $expected)
|
||
|
{
|
||
|
$_POST['lgn_usr'] = $username;
|
||
|
$_POST['lgn_pwd'] = $password;
|
||
|
|
||
|
/** @var AccountController $login */
|
||
|
$controller = oxNew(AccountController::class);
|
||
|
$controller->init();
|
||
|
/** @var d3_webauthn_UserComponent $component */
|
||
|
$component = $controller->getComponent('oxcmp_user');
|
||
|
$component->login_noredirect();
|
||
|
|
||
|
$this->assertSame(
|
||
|
$expected,
|
||
|
$component->getLoginStatus()
|
||
|
);
|
||
|
|
||
|
$component->logout();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return array[]
|
||
|
*/
|
||
|
public function loginDataProvider(): array
|
||
|
{
|
||
|
return [
|
||
|
'not existing account' => ['unknown@user.localhost', '123456', USER_LOGIN_FAIL],
|
||
|
'missing password' => ['noadmin@user.localhost', null, USER_LOGIN_FAIL],
|
||
|
'inactive account' => ['inactive@user.localhost', '123456', USER_LOGIN_FAIL],
|
||
|
'wrong shop account' => ['wrongshop@user.localhost', '123456', USER_LOGIN_FAIL],
|
||
|
'account ok' => ['noadmin@user.localhost', '123456', USER_LOGIN_SUCCESS],
|
||
|
];
|
||
|
}
|
||
|
}
|