Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
user system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
23 Feb 2015 at 19:49 UTC
Updated:
9 Jun 2015 at 09:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
cpj commentedComment #2
andypostThis actually depends on that
Comment #3
dawehnerComment #4
xjm#2228393: Decouple session from cookie based user authentication is in; should this issue be repurposed for test coverage, or marked fixed?
Comment #5
andypostProper parenting
Comment #6
znerol commentedComment #7
pfrenssenThis should be pretty easy, we already have all the necessary ingredients in SessionAuthenticationTest.
Comment #8
pfrenssenSomething like this should do the trick. I'm testing both that cookie sets a cookie, and basic auth doesn't.
Comment #9
benjifisherI am removing the Novice Tag from this Issue because there are no Novice tasks left.
Comment #10
pfrenssenFixed a little typo in my patch.
Comment #11
znerol commentedPlease only use the verb set, not save and not yield when describing the process of a cookie being passed from the server into the browser. This test is about the
Set-CookieHTTP response header.What about
testBasicAuthNoSessionwith the docstring: Tests that a session is not started automatically by basic authentication. (in analogy to what we've ended up in #2283637: Provide test coverage to prove that an AuthenticationProvider can initiate a session).Comment #12
pfrenssenGood points, will address these today during my lunch break.
Comment #13
pfrenssenUpdated the documentation with @znerol's suggestions.
Comment #14
pfrenssenAlso replaced "yield a cookie" with "set a cookie" in the assert messages.
Comment #16
znerol commentedThanks. Added the beta evaluation.
Comment #18
pfrenssenPatch didn't apply any more since #2283637: Provide test coverage to prove that an AuthenticationProvider can initiate a session went in. Rerolled against latest HEAD.
Comment #20
pfrenssenInteresting, seems we have a cookie :)
Comment #21
znerol commentedFunny, it looks like
$this->cookiesis bleeding over from the previous test.Comment #22
pfrenssenI'll have a look. If this is the case then this is a separate issue. I'll reorder the tests and open a followup to ensure that the cookies are properly initialized on every request.
Comment #23
pfrenssenThis is a bit more robust. I'm now inspecting the request headers to see if the string "Set-Cookie" is present.
I looked into the cookie bleeding issue and this is indeed what is happening. In
WebTestBase::curlHeaderCallback()the$this->cookiesproperty is filled whenever a cookie is set on the request but these are never cleared to simulate the browser persisting the cookies inbetween requests. We should clear this whenever a new test starts.Comment #24
pfrenssenCreated followup for the cookie bleeding issue: #2491353: Cookies from previous tests are still present when a new test starts.
Comment #25
znerol commentedAs mentioned in the other issue, use
$this->drupalGetHeader().Edit: And then the helper method probably gets superflous, so you may inline it for better comprehension.
Comment #26
andypostI already pointed about cookie leak in #2484991-3: Add the session to the request in KernelTestBase, BrowserTestBase, and drush
Great to have separate issue for that
Comment #27
pfrenssenUsed
$this->drupalGetHeader()as suggested in #25.Also changing this to a task, the bug is already fixed in HEAD.
Comment #28
znerol commentedIs there a redirect involved here? Otherwise it is not necessary to specify
TRUEfor the optional$all_requestsparameter.Comment #29
pfrenssenThe second one has a redirect. The first one doesn't but I kept the
TRUEparameter for consistency. I'll get rid of it.Comment #30
pfrenssenGot rid of the needless
TRUE.Comment #31
znerol commentedThis new test covers the problem. Thanks.
Comment #34
pfrenssenComment #35
alexpottHmmm... I think we should be consistent here. Not sure I agree with the change in #30 since the tests are supposed to be opposite.
Comment #36
znerol commentedThe normal case throughout our tests is to not specify
$all_requestsparameter (default isFALSE). If a redirect happens, then this will only examine the headers of the last request. In my understanding that parameter is a lot like a strict flag, which we only should disable if its really necessary.It is necessary to relax the check in the second instance because the cookie is set in response to the
POSTrequest, and not during the subsequent redirect. IMHO we should not relax that check for the first assertion.Comment #37
pfrenssenI'm siding with Alex on this, because it doesn't look as if we are doing a regular positive-negative test here. Even though this is totally correct it just looks a bit suspicious to me.
As a middle ground, would it perhaps be a good idea to set
$this->maximumRedirectsto 0 to stop the redirection taking place?Comment #38
alexpottI dunno - in my opinion it makes sense to set the
$all_requeststo TRUE in both instances because what you are looking to test is that no request has set a cookie or that at least one has.Comment #39
znerol commentedOk, let's not make this more complex as nessecary and revert #30
Comment #40
pfrenssenOK! Re-uploading the one from #27.
Comment #41
znerol commentedThanks.
Comment #42
alexpottCommitted 72fb794 and pushed to 8.0.x. Thanks!
Thanks @pfrenssen and @znerol for sticking with this and adding the beta evaluation to the issue summary.