Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to make API requests using self signed certificate to HTTPS domain #37

Closed
Cristian101 opened this issue Feb 15, 2018 · 2 comments

Comments

@Cristian101
Copy link
Contributor

Preconditions

  1. Magento 2.3.0 dev
  2. Manually install MFTF into dev folder (using magento2 2.2-develop latest)
  3. Virtual Host setup with https and a self signed certificate (in my case it's https://magento22mftfcombine.test/)

Steps to reproduce

  1. Run a test that uses the Magento API. For example, the checkout test uses the API to create a category and a product before it starts interacting with the UI.

vendor/bin/robo group checkout

Expected result

  1. Both "checkout" test should run without any errors.

Actual result

I get this result in the cli:

`[Exec] Running ./vendor/bin/codecept run functional --verbose --steps --skip-group skip --group checkout
Codeception PHP Testing Framework v2.3.8
Powered by PHPUnit 6.5.6 by Sebastian Bergmann and contributors.
[Groups] checkout

Magento\FunctionalTestingFramework.functional Tests (2) ------------------
Modules: \Magento\FunctionalTestingFramework\Module\MagentoWebDriver, \Magento\FunctionalTestingFramework\Helper\Acceptance, \Magento\FunctionalTestingFramework\Helper\MagentoFakerData, \Magento\FunctionalTestingFramework\Module\MagentoRestDriver, PhpBrowser, \Magento\FunctionalTestingFramework\Module\MagentoSequence, Asserts

StorefrontCustomerCheckoutTestCest: Storefront customer checkout test
Signature: Magento\AcceptanceTest_generated\Backend\StorefrontCustomerCheckoutTestCest:StorefrontCustomerCheckoutTest
Test: tests/functional/Magento/FunctionalTest/_generated/StorefrontCustomerCheckoutTestCest.php:StorefrontCustomerCheckoutTest
Scenario --
I am going to create entity that has the stepKey: simplecategory
ERROR

StorefrontGuestCheckoutTestCest: Storefront guest checkout test
Signature: Magento\AcceptanceTest_generated\Backend\StorefrontGuestCheckoutTestCest:StorefrontGuestCheckoutTest
Test: tests/functional/Magento/FunctionalTest/_generated/StorefrontGuestCheckoutTestCest.php:StorefrontGuestCheckoutTest
Scenario --
I am going to create entity that has the stepKey: createCategory
ERROR


Time: 3.14 seconds, Memory: 18.00MB

There were 2 errors:


  1. StorefrontCustomerCheckoutTestCest: Storefront customer checkout test
    Test tests/functional/Magento/FunctionalTest/_generated/StorefrontCustomerCheckoutTestCest.php:StorefrontCustomerCheckoutTest

[Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException] SSL: certificate subject name 'localhost' does not match target host name 'magento22mftfcombine.test'

Scenario Steps:

  1. // I am going to create entity that has the stepKey: simplecategory

#1 /var/www/html/magento22mftfcombine/dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Util/Protocol/CurlTransport.php:173
#2 /var/www/html/magento22mftfcombine/dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/Curl/WebapiExecutor.php:116
#3 /var/www/html/magento22mftfcombine/dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/Curl/WebapiExecutor.php:83
#4 /var/www/html/magento22mftfcombine/dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/Curl/WebapiExecutor.php:65
#5 /var/www/html/magento22mftfcombine/dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/CurlHandler.php:132
#6 /var/www/html/magento22mftfcombine/dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/DataPersistenceHandler.php:72
#7 /var/www/html/magento22mftfcombine/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/_generated/StorefrontCustomerCheckoutTestCest.php:48
#8 Magento\AcceptanceTest_generated\Backend\StorefrontCustomerCheckoutTestCest->_before


  1. StorefrontGuestCheckoutTestCest: Storefront guest checkout test
    Test tests/functional/Magento/FunctionalTest/_generated/StorefrontGuestCheckoutTestCest.php:StorefrontGuestCheckoutTest

[Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException] SSL: certificate subject name 'localhost' does not match target host name 'magento22mftfcombine.test'

Scenario Steps:

  1. // I am going to create entity that has the stepKey: createCategory

#1 /var/www/html/magento22mftfcombine/dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Util/Protocol/CurlTransport.php:173
#2 /var/www/html/magento22mftfcombine/dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/Curl/WebapiExecutor.php:116
#3 /var/www/html/magento22mftfcombine/dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/Curl/WebapiExecutor.php:83
#4 /var/www/html/magento22mftfcombine/dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/Curl/WebapiExecutor.php:65
#5 /var/www/html/magento22mftfcombine/dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/CurlHandler.php:132
#6 /var/www/html/magento22mftfcombine/dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/DataPersistenceHandler.php:72
#7 /var/www/html/magento22mftfcombine/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/_generated/StorefrontGuestCheckoutTestCest.php:43
#8 Magento\AcceptanceTest_generated\Backend\StorefrontGuestCheckoutTestCest->_before

ERRORS!
Tests: 2, Assertions: 0, Errors: 2.
[Exec] Exit code 1 Time 3.293s
`
################################################################

I also get the same error in Magento 2.3

It might just be that I don't know how to properly configure MFTF, however I looked into the source code and there doesn't seem to be any way to give curl and parameter to make it ignore insercure certificates.

I found a way to make it work by going inside the core of MFTF, more specifically to the Magento\FunctionalTestingFramework\Util\Protocol\CurlTransport class and inside the write method adding CURLOPT_SSL_VERIFYHOST => false to the initial $options array. Of courrse this is not a good solution since I shouldn't be editing the core files, but in case this is a real issue, would this be a proper solution? Or am I completely off the mark here?

@Cristian101 Cristian101 changed the title Unable to make API requests to using self signed certificate to HTTPS domain Unable to make API requests using self signed certificate to HTTPS domain Feb 15, 2018
@sshrewz
Copy link

sshrewz commented Feb 27, 2018

@Cristian101 , we have logged this as MQE-804 for tracking purposes. This will be included in the upcoming release MFTF 2.1.0.

@okolesnyk
Copy link
Member

Hi @Cristian101
As you can see your PR was merged to develop so this issue can be closed.
PR changes will be available in MFTF 2.1.0

Please feel free to reopen or create new issue.
Thank you.

magento-cicd2 pushed a commit that referenced this issue Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants