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

Make Guzzle request options configurable #655

Merged
merged 8 commits into from
Dec 8, 2023

Conversation

claudiu-cristea
Copy link
Contributor

@claudiu-cristea claudiu-cristea commented Dec 6, 2023

Problem

Behat tests are failing for logged in users when the site is accessed via HTTPS and SSL peer verification is failing. But with BrowserTestBase we're able to run such tests. Testing should not require a valid SSL certificate

Proposal

Make Guzzle request options configurable

Example:

default:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
  extensions:
    Drupal\MinkExtension:
      base_url: https://localhost
      browserkit_http:
        guzzle_request_options:
          verify: false

In this example, browserkit_http.guzzle_request_options is configured to instantiate the Guzzle underlying HTTP client with the verify request option set to false, same as BrowserTestBase:: initMink() is doing

@claudiu-cristea
Copy link
Contributor Author

We have now the proof, see the test failures

@Berdir
Copy link
Contributor

Berdir commented Dec 6, 2023

this should probably say *with self-signed certificate in the title, because that's the only issue here afaik, would need a setting to allow those I guess.

Also has nothing to with this project, if not already supported it's something that the driver needs to support? I know some chrome drivers have this

@claudiu-cristea
Copy link
Contributor Author

claudiu-cristea commented Dec 6, 2023

@Berdir, now we're using DrupalTestBrowser (core) as client which uses Guzzle as HTTP client. When DrupalTestBrowser is used in BrowserTestBase, Guzzle is instantiated with verify: false config. We need the same here

EDIT: Relevant code: \Drupal\Tests\BrowserTestBase::initMink()

@claudiu-cristea claudiu-cristea changed the title Allow tests to run against an HTTPS site Allow tests to run against an HTTPS site with failing SSL peer verification Dec 6, 2023
@claudiu-cristea claudiu-cristea changed the title Allow tests to run against an HTTPS site with failing SSL peer verification Run against an HTTPS site with failing SSL peer verification Dec 6, 2023
@claudiu-cristea
Copy link
Contributor Author

Yes, maybe we should do the Guzzle request options configurable

@claudiu-cristea claudiu-cristea changed the title Run against an HTTPS site with failing SSL peer verification Make Guzzle request options configurable Dec 6, 2023
@claudiu-cristea
Copy link
Contributor Author

Ready for review

@jhedstrom jhedstrom merged commit 5847e41 into jhedstrom:master Dec 8, 2023
7 checks passed
@jhedstrom
Copy link
Owner

This looks great. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants