Problem/Motivation

Plus ça change, plus c'est la même chose. The exact same issue as #268148: Browser tests fail under HTTPS.

Proposed resolution

Replace the code in \Drupal\Tests\BrowserTestBase::initMink to use \Drupal::service('http_client_factory')->fromOptions(['verify' => FALSE]).

Remaining tasks

User interface changes

API changes

Data model changes

Comments

chx created an issue. See original summary.

chx’s picture

Issue summary: View changes
dawehner’s picture

Issue summary: View changes
Issue tags: +Novice
hardikpandya’s picture

Assigned: Unassigned » hardikpandya
hardikpandya’s picture

Assigned: hardikpandya » Unassigned
Status: Active » Needs review
StatusFileSize
new541 bytes

I have applied the patch but is unsure about how to test it.Can you please check it and suggest any changes needed?

dawehner’s picture

Status: Needs review » Needs work

You need to replace the call to \Drupal::httpClient() with your new code. Well I guess you need to setup https on your local system in order to test it?

hardikpandya’s picture

Status: Needs work » Needs review
StatusFileSize
new606 bytes

Adding patch.

dawehner’s picture

Thank you

@chx
It would be great if you could confirm that this fixes your issue.

klausi’s picture

Status: Needs review » Needs work

Ugh, ugly.

Can we have a comment why we need to do this? Like "Disable SSL peer verification so that testing under HTTPS always works."

dawehner’s picture

Maybe a pointer to #268148: Browser tests fail under HTTPS would be great as well.

Arndt’s picture

Assigned: Unassigned » Arndt
Arndt’s picture

StatusFileSize
new234 bytes

Replaced Code and added suggested Comment

klausi’s picture

Hm, looks like that is not a valid patch file? Can you create it with "git diff" as outlined on https://www.drupal.org/node/707484 ?

stefdewa’s picture

Assigned: Arndt » Unassigned
Status: Needs work » Needs review
StatusFileSize
new873 bytes

Created valid patch based on current 8.2.x-dev.

klausi’s picture

Status: Needs review » Needs work
  1. +++ b/core/tests/Drupal/Tests/BrowserTestBase.php
    @@ -357,8 +357,9 @@ protected function initMink() {
    +      // Also, disable SSL peer verification so that testing under HTTPS always works.
    

    Comment is over 80 characters, make sure to wrap the line at 80.

  2. +++ b/core/tests/Drupal/Tests/BrowserTestBase.php
    @@ -357,8 +357,9 @@ protected function initMink() {
    -      $client = $this->container->get('http_client_factory')->fromOptions(['timeout' => NULL]);
    +      $client = $this->container->get('http_client_factory')->fromOptions(['timeout' => NULL, 'verify' => FALSE]);
    

    this line is getting long as well, let's do the array entries on separate lines.

stefdewa’s picture

As requested comment is wrapped at a line length of 80 chars and the array entries are on separate lines.

stefdewa’s picture

Status: Needs work » Needs review
gambry’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice +SprintWeekend2017, +london_2017_january

Manual test fails without this patch with a self-signed certificate and passes with. Happy to RTBC as soon as @klausi is happy with his feedbacks at #15.

IMHO for the sake of testing Drupal, it doesn't matter what protocol you use.
But if you HAVE TO run tests against a https environment (i.e.: due client requirements), it means the https is a requirement for you test and so it NEEDS to be a verified SSL cert.
Testing on https without verifying is more or less like testing through http.

gambry’s picture

Status: Reviewed & tested by the community » Needs review

Sorry, left-over. Reverting to Needs Review.

The last submitted patch, 12: browserTest-2802427-12.patch, failed testing.

klausi’s picture

Status: Needs review » Needs work

Thanks!

+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -357,8 +357,13 @@ protected function initMink() {
+      $client = $this->container->get('http_client_factory')->fromOptions([
+        'timeout' => NULL,
+        'verify' => FALSE
+      ]);

there is a comma missing on the 'verify' line.

stefdewa’s picture

Status: Needs work » Needs review
StatusFileSize
new912 bytes

Added the missing comma.

klausi’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, thanks!

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

alexpott’s picture

Version: 8.3.x-dev » 8.4.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Unfortunately needs a re-roll.

+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -357,8 +357,13 @@ protected function initMink() {
       // test running, but it is a problem when debugging.
+      // Also, disable SSL peer verification so that testing under HTTPS always
+      // works.

The Also,... can be merged with the comment on the previous line.

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new1021 bytes

Re-roll and merge comments.

gambry’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC then.

  • catch committed 424b3e1 on 8.3.x
    Issue #2802427 by Stefdewa, hardik.p, Arndt, Jo Fitzgerald: Browser...
catch’s picture

Version: 8.4.x-dev » 8.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.4.x and cherry-picked to 8.3.x, thanks!

  • catch committed 8d6e9ef on 8.4.x
    Issue #2802427 by Stefdewa, hardik.p, Arndt, Jo Fitzgerald: Browser...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.