Closed (fixed)
Project:
Drupal core
Version:
8.2.x-dev
Component:
rest.module
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Sep 2016 at 17:23 UTC
Updated:
25 Oct 2016 at 11:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
neclimdulComment #3
wim leersOhhh! Of course :)
Comment #4
wim leersThis was not triaged.
Comment #5
wim leersAnd patch!
I wanted to assert that the appropriate message was being returned. But … turns out the existing test coverage is not testing that either, because
WTB::assertResponse()is extremely misleading :(So in the test we were only really asserting we were getting 403 responses. I verified manually at the time (and again today) that this indeed works in real life. But in the test, we were getting not
application/hal+jsonresponses, but …text/htmlresponses!You'll never guess the root cause for that one, especially because the correct
DELETErequest works just fine. Well, it turns out that if you don't specify?_format=hal_json, you don't get the JSON exception subscriber for handling 4xx responses… which means you getDefaultExceptionSubscriberinstead, so you get an HTML response.This was supposed to be trivial, and it is, but the test fixes make it look less trivial. The big test-only patch shows that.
(I thought this patch would take me 4 to 5 minutes. It took me 4 to 5 hours.)
Comment #7
neclimdulSo this fixes testing the original implementation.
And this change lets us test the fixes for this issue?
It looks like forget_xcsrf is no longer an accurate description of this argument... This should probably be fixed but I don't really want to block this quick win. I assume that's why you crammed it in. How did this quickfix get so complicated.
Comment #8
wim leers$csrf_tokenbeing: A)TRUEby default (for "please generate it"), B)FALSE(for "please forget it") or C) a string (for "please use this as the CSRF token")? Does that make sense to you?Comment #9
neclimdulyucky tri-state. Yeah, I think if I was starting from scratch I'd use NULL but for what you described makes sense and doesn't break backwards compatibility.
Comment #10
wim leersIt does break BC, because the parameter name is no longer a negative, so the boolean values must be inverted. You'd use
NULLinstead ofFALSEin my example?Comment #11
neclimdulA) Null default. Generate token B) Truish use value C) False don't do anything with CSRF.
Its going to be complicated regardless because we're relying on loose typing but this makes it closer to being typed so it makes a little more sense to me. As long as we document it I think its fine.
Comment #12
wim leersThat makes sense! Thanks for your input, it's much appreciated :)
Done.
Comment #13
neclimdulWorks for me!
Comment #14
alexpottCommitted 676f38d and pushed to 8.3.x. Thanks!
Setting to patch to ported so that once 8.2.0 is released this can be cherry-picked to 8.2.x
Comment #16
wim leersComment #17
gnugetDrupal 8.2.0 is now out, Can we now cherry-pick this to the 8.2.x branch?
:D
Comment #18
alexpottCommitted eb38af5 and pushed to 8.2.x. Thanks!