forked from spryker-shop/b2b-demo-shop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request spryker-shop#303 from spryker-shop/bugfix/cc-31028…
…-add-missing-glue-tests CC-31028 Integrated API E2E tests.
- Loading branch information
Showing
104 changed files
with
13,796 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
tests/PyzTest/Glue/AgentAuth/RestApi/AgentAccessTokensRestApiCest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Spryker Commerce OS. | ||
* For full license information, please view the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PyzTest\Glue\AgentAuth\RestApi; | ||
|
||
use Codeception\Util\HttpCode; | ||
use PyzTest\Glue\AgentAuth\AgentAuthRestApiTester; | ||
use PyzTest\Glue\AgentAuth\RestApi\Fixtures\AgentAccessTokensRestApiFixtures; | ||
use Spryker\Glue\AgentAuthRestApi\AgentAuthRestApiConfig; | ||
|
||
/** | ||
* Auto-generated group annotations | ||
* | ||
* @group PyzTest | ||
* @group Glue | ||
* @group AgentAuth | ||
* @group RestApi | ||
* @group AgentAccessTokensRestApiCest | ||
* Add your own group annotations below this line | ||
* @group EndToEnd | ||
*/ | ||
class AgentAccessTokensRestApiCest | ||
{ | ||
/** | ||
* @var \PyzTest\Glue\AgentAuth\RestApi\Fixtures\AgentAccessTokensRestApiFixtures | ||
*/ | ||
protected AgentAccessTokensRestApiFixtures $fixtures; | ||
|
||
/** | ||
* @param \PyzTest\Glue\AgentAuth\AgentAuthRestApiTester $I | ||
* | ||
* @return void | ||
*/ | ||
public function loadFixtures(AgentAuthRestApiTester $I): void | ||
{ | ||
/** @var \PyzTest\Glue\AgentAuth\RestApi\Fixtures\AgentAccessTokensRestApiFixtures $fixtures */ | ||
$fixtures = $I->loadFixtures(AgentAccessTokensRestApiFixtures::class); | ||
|
||
$this->fixtures = $fixtures; | ||
} | ||
|
||
/** | ||
* @depends loadFixtures | ||
* | ||
* @param \PyzTest\Glue\AgentAuth\AgentAuthRestApiTester $I | ||
* | ||
* @return void | ||
*/ | ||
public function requestAccessTokenForExistingAgentUser(AgentAuthRestApiTester $I): void | ||
{ | ||
// Act | ||
$I->sendPOST(AgentAuthRestApiConfig::RESOURCE_AGENT_ACCESS_TOKENS, [ | ||
'data' => [ | ||
'type' => AgentAuthRestApiConfig::RESOURCE_AGENT_ACCESS_TOKENS, | ||
'attributes' => [ | ||
'username' => $this->fixtures->getUserTransfer()->getUsername(), | ||
'password' => AgentAccessTokensRestApiFixtures::TEST_PASSWORD, | ||
], | ||
], | ||
]); | ||
|
||
// Assert | ||
$I->seeResponseCodeIs(HttpCode::CREATED); | ||
$I->seeResponseHasAccessToken(); | ||
$I->seeResponseHasRefreshToken(); | ||
$I->seeResponseMatchesOpenApiSchema(); | ||
} | ||
|
||
/** | ||
* @depends loadFixtures | ||
* | ||
* @param \PyzTest\Glue\AgentAuth\AgentAuthRestApiTester $I | ||
* | ||
* @return void | ||
*/ | ||
public function requestAccessTokenForNonExistingAgentUser(AgentAuthRestApiTester $I): void | ||
{ | ||
// Act | ||
$I->sendPOST(AgentAuthRestApiConfig::RESOURCE_AGENT_ACCESS_TOKENS, [ | ||
'data' => [ | ||
'type' => AgentAuthRestApiConfig::RESOURCE_AGENT_ACCESS_TOKENS, | ||
'attributes' => [ | ||
'username' => 'NonExistingAgent', | ||
'password' => AgentAccessTokensRestApiFixtures::TEST_PASSWORD, | ||
], | ||
], | ||
]); | ||
|
||
// Assert | ||
$I->seeResponseCodeIs(HttpCode::UNAUTHORIZED); | ||
$I->seeResponseDoesNotHaveAccessToken(); | ||
$I->seeResponseDoesNotHaveRefreshToken(); | ||
$I->seeResponseMatchesOpenApiSchema(); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
tests/PyzTest/Glue/AgentAuth/RestApi/Fixtures/AgentAccessTokensRestApiFixtures.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Spryker Commerce OS. | ||
* For full license information, please view the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PyzTest\Glue\AgentAuth\RestApi\Fixtures; | ||
|
||
use Generated\Shared\Transfer\UserTransfer; | ||
use PyzTest\Glue\AgentAuth\AgentAuthRestApiTester; | ||
use SprykerTest\Shared\Testify\Fixtures\FixturesBuilderInterface; | ||
use SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface; | ||
|
||
class AgentAccessTokensRestApiFixtures implements FixturesBuilderInterface, FixturesContainerInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public const TEST_PASSWORD = 'change123'; | ||
|
||
/** | ||
* @var \Generated\Shared\Transfer\UserTransfer | ||
*/ | ||
protected UserTransfer $userTransfer; | ||
|
||
/** | ||
* @param \PyzTest\Glue\AgentAuth\AgentAuthRestApiTester $I | ||
* | ||
* @return \SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface | ||
*/ | ||
public function buildFixtures(AgentAuthRestApiTester $I): FixturesContainerInterface | ||
{ | ||
$this->userTransfer = $this->createAgentUserTransfer($I); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return \Generated\Shared\Transfer\UserTransfer | ||
*/ | ||
public function getUserTransfer(): UserTransfer | ||
{ | ||
return $this->userTransfer; | ||
} | ||
|
||
/** | ||
* @param \PyzTest\Glue\AgentAuth\AgentAuthRestApiTester $I | ||
* | ||
* @return \Generated\Shared\Transfer\UserTransfer | ||
*/ | ||
protected function createAgentUserTransfer(AgentAuthRestApiTester $I): UserTransfer | ||
{ | ||
return $I->haveRegisteredAgent([ | ||
UserTransfer::PASSWORD => static::TEST_PASSWORD, | ||
]); | ||
} | ||
} |
Oops, something went wrong.