Skip to content

Commit

Permalink
smoke test for new product now work with HTTPS domain (#2214)
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmannmartin authored Feb 2, 2021
1 parent 41c4b98 commit df00350
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/App/Smoke/NewProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public function createOrEditProductProvider()
public function testCreateOrEditProduct($relativeUrl)
{
$domainUrl = $this->domain->getDomainConfigById(Domain::FIRST_DOMAIN_ID)->getUrl();
$isDomainSecured = parse_url($domainUrl, PHP_URL_SCHEME) === 'https';
$server = [
'HTTP_HOST' => sprintf('%s:%d', parse_url($domainUrl, PHP_URL_HOST), parse_url($domainUrl, PHP_URL_PORT)),
'HTTPS' => $isDomainSecured,
];

$client1 = $this->findClient(false, 'admin', 'admin123');
Expand All @@ -47,7 +49,9 @@ public function testCreateOrEditProduct($relativeUrl)

/** @var \Symfony\Component\Security\Csrf\CsrfTokenManager $tokenManager */
$tokenManager = $client2->getContainer()->get('security.csrf.token_manager');
$token = $tokenManager->getToken(ProductFormType::CSRF_TOKEN_ID);
// if domain is on HTTPS, previously created token is prefixed with https-
$tokenId = ($isDomainSecured ? 'https-' : '') . ProductFormType::CSRF_TOKEN_ID;
$token = $tokenManager->getToken($tokenId);
$this->setFormCsrfToken($form, $token);

$client2->submit($form);
Expand Down

0 comments on commit df00350

Please sign in to comment.