Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Lendude created an issue. See original summary.

Lendude’s picture

Status: Active » Needs review
FileSize
2.53 KB

This doesn't work at all, but it might be a first step.

Status: Needs review » Needs work

The last submitted patch, 2: 3011079-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

idebr’s picture

scott_euser’s picture

Getting this a bit further but I cannot get the mock session value to fill in with my ddev environment setup for tests, so may need someone else to continue on further test fails.

scott_euser’s picture

Fixed patch to include the removal of the old file; thanks for spotting @dawehner

Setting the interdiff from the original so it's a useful interdiff.

The last submitted patch, 5: drupal-session-https-test-to-phpunit-3011079-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

scott_euser’s picture

Status: Needs review » Needs work
dawehner’s picture

+++ b/core/modules/system/tests/src/Functional/Session/SessionHttpsTest.php
@@ -143,12 +156,29 @@ protected function loginHttp(AccountInterface $account) {
+    $html = $this->getSession()->getPage()->getHtml();
...
+    $form_tokens_found = preg_match('/\sname="form_build_id" value="([^"]+)"/', $html, $build_id_match);
+    $this->assertTrue($form_tokens_found, 'Form tokens found in output.');

🔧 How about using something like $this->session->getPage()->findField('form_build_id')

alexpott’s picture

Status: Needs work » Needs review
FileSize
21.59 KB

Here's a passing conversion. We need to disable redirects whilst logging in because otherwise it'll try to redirect us to a https site which might not work. The original test was preventing redirects too but we have to change how we do that because of the Goutte/Mink/BrowserKit architecture. There's also a bit of fun with Guzzle and BrowserKit CookieJar's which are different. For example, BrowserKit's CookieJar does not allow the secure attribute to be set when the cookies domain is not https so we have to test for that using the CookieJar guzzle fills up.

No interdiff because this is the first fully working conversion and all the changes need review. I've tried to only refactor what is necessary / makes things a bit easier. It would be possible to refactor loginHttps() and loginHttp() to share more code and thereby make maintaining this in the future a bit simpler but I don't think we should do that here.

alexpott’s picture

Ahh the docs are now out-of-date. Update them.

jibran’s picture

alexpott’s picture

I don;'t understand having the concurrent secure sessions unless we make some assertions so I've added some. This is a little bit of scope creep I guess but there must have been a reason for adding this and I want to make sure that the assumptions the test is making are still correct so I've added some assertions against those assumptions.

Lendude’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
819 bytes
21.35 KB

@alexpott nice!

+++ b/core/modules/system/tests/src/Functional/Session/SessionHttpsTest.php
@@ -0,0 +1,310 @@
+use Drupal\Tests\BrowserTestBase;
+use GuzzleHttp\Cookie\CookieJar;
+use Psr\Http\Message\ResponseInterface;
+use Symfony\Component\BrowserKit\Cookie;
+use Symfony\Component\HttpFoundation\Request;
+use Drupal\Component\Utility\Crypt;
+use Drupal\Core\Session\AccountInterface;

The only thing I can find is that these are not in alphabetical order, so quick cleanup for that, but since that is just a cosmetic change I'm going to RTBC this too.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed a51a8f5 and pushed to 8.7.x. Thanks!

  • catch committed a51a8f5 on 8.7.x
    Issue #3011079 by scott_euser, alexpott, Lendude: Convert \Drupal\system...

Status: Fixed » Closed (fixed)

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