diff --git a/tests/App/Smoke/NewProductTest.php b/tests/App/Smoke/NewProductTest.php index 140c12558c..c5631e54c8 100644 --- a/tests/App/Smoke/NewProductTest.php +++ b/tests/App/Smoke/NewProductTest.php @@ -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'); @@ -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);