|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Spryker Commerce OS. |
|
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types = 1); |
|
9
|
|
|
|
|
10
|
|
|
namespace PyzTest\Glue\MultiFactorAuth; |
|
11
|
|
|
|
|
12
|
|
|
use Generated\Shared\Transfer\CustomerTransfer; |
|
|
|
|
|
|
13
|
|
|
use Orm\Zed\MultiFactorAuth\Persistence\Map\SpyCustomerMultiFactorAuthCodesTableMap; |
|
|
|
|
|
|
14
|
|
|
use Orm\Zed\MultiFactorAuth\Persistence\SpyCustomerMultiFactorAuthCodesQuery; |
|
15
|
|
|
use SprykerTest\Glue\Testify\Tester\StorefrontApiEndToEndTester; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Inherited Methods |
|
19
|
|
|
* |
|
20
|
|
|
* @method void wantTo($text) |
|
21
|
|
|
* @method void wantToTest($text) |
|
22
|
|
|
* @method void execute($callable) |
|
23
|
|
|
* @method void expectTo($prediction) |
|
24
|
|
|
* @method void expect($prediction) |
|
25
|
|
|
* @method void amGoingTo($argumentation) |
|
26
|
|
|
* @method void am($role) |
|
27
|
|
|
* @method void lookForwardTo($achieveValue) |
|
28
|
|
|
* @method void comment($description) |
|
29
|
|
|
* @method void pause($vars = []) |
|
30
|
|
|
* |
|
31
|
|
|
* @SuppressWarnings(PHPMD) |
|
32
|
|
|
*/ |
|
33
|
|
|
class MultiFactorAuthStorefrontApiTester extends StorefrontApiEndToEndTester |
|
34
|
|
|
{ |
|
35
|
|
|
use _generated\MultiFactorAuthStorefrontApiTesterActions; |
|
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
protected const TEST_PASSWORD = 'Change!23456'; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer |
|
44
|
|
|
* |
|
45
|
|
|
* @return void |
|
46
|
|
|
*/ |
|
47
|
|
|
public function authorizeCustomerToStorefrontApi(CustomerTransfer $customerTransfer): void |
|
48
|
|
|
{ |
|
49
|
|
|
$oauthResponseTransfer = $this->havePasswordAuthorizationToStorefrontApi($customerTransfer); |
|
50
|
|
|
$this->amBearerAuthenticated($oauthResponseTransfer->getAccessToken()); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param string $customerName |
|
55
|
|
|
* |
|
56
|
|
|
* @return \Generated\Shared\Transfer\CustomerTransfer |
|
57
|
|
|
*/ |
|
58
|
|
|
public function createCustomer(string $customerName): CustomerTransfer |
|
59
|
|
|
{ |
|
60
|
|
|
$customerTransfer = $this->haveCustomer([ |
|
61
|
|
|
CustomerTransfer::USERNAME => $customerName, |
|
62
|
|
|
CustomerTransfer::PASSWORD => static::TEST_PASSWORD, |
|
63
|
|
|
CustomerTransfer::NEW_PASSWORD => static::TEST_PASSWORD, |
|
64
|
|
|
CustomerTransfer::EMAIL => $customerName, |
|
65
|
|
|
]); |
|
66
|
|
|
|
|
67
|
|
|
$this->confirmCustomer($customerTransfer); |
|
68
|
|
|
|
|
69
|
|
|
return $customerTransfer->setPassword(static::TEST_PASSWORD); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer |
|
74
|
|
|
* @param string $mfaType |
|
75
|
|
|
* |
|
76
|
|
|
* @return string|null |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getCustomerMultiFactorAuthCodeFromDatabase(CustomerTransfer $customerTransfer, string $mfaType): ?string |
|
79
|
|
|
{ |
|
80
|
|
|
$customerMultiFactorAuthCodeEntity = (new SpyCustomerMultiFactorAuthCodesQuery()) |
|
81
|
|
|
->innerJoinSpyCustomerMultiFactorAuth() |
|
82
|
|
|
->useSpyCustomerMultiFactorAuthQuery() |
|
83
|
|
|
->filterByType($mfaType); |
|
84
|
|
|
|
|
85
|
|
|
/** @var \Orm\Zed\MultiFactorAuth\Persistence\SpyCustomerMultiFactorAuthCodes|null $customerMultiFactorAuthCodeEntity */ |
|
86
|
|
|
$customerMultiFactorAuthCodeEntity = $customerMultiFactorAuthCodeEntity->filterByFkCustomer($customerTransfer->getIdCustomer()) |
|
87
|
|
|
->addDescendingOrderByColumn(SpyCustomerMultiFactorAuthCodesTableMap::COL_ID_CUSTOMER_MULTI_FACTOR_AUTH_CODE) |
|
88
|
|
|
->endUse() |
|
89
|
|
|
->findOne(); |
|
90
|
|
|
|
|
91
|
|
|
return $customerMultiFactorAuthCodeEntity?->getCode(); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths