Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upWrite unit tests for cookie isolation #7646
Conversation
|
Good start! Reviewed 1 of 1 files at r1. tests/unit/net/http_loader.rs, line 464 [r1] (raw file): tests/unit/net/http_loader.rs, line 467 [r1] (raw file): tests/unit/net/http_loader.rs, line 473 [r1] (raw file): tests/unit/net/http_loader.rs, line 482 [r1] (raw file): tests/unit/net/http_loader.rs, line 484 [r1] (raw file): tests/unit/net/http_loader.rs, line 495 [r1] (raw file): tests/unit/net/http_loader.rs, line 501 [r1] (raw file): Comments from the review on Reviewable.io |
|
thanks @jdm, updated it, but still have 2 issues:
on making a request that produces a response, should i use MockRequest/MockResponse ? |
|
That's the correct output; the code that fetches cookies for a given URL only returns data in the form "name=value" (see http://mxr.mozilla.org/servo/source/components/net/cookie_storage.rs#100), so the expected output needs to be corrected. |
|
As for making a response, yes, we want a MockRequest that uses ResponseType::WithHeaders like http://mxr.mozilla.org/servo/source/tests/unit/net/http_loader.rs#426 . |
|
-S-awaiting-review +S-needs-code-changes Reviewed 1 of 1 files at r2. tests/unit/net/http_loader.rs, line 178 [r2] (raw file): tests/unit/net/http_loader.rs, line 197 [r2] (raw file): Comments from the review on Reviewable.io |
|
thanks! updated
|
|
Oh! That's because the premise of the test is incorrect; my apologies! We do actually want to send NonHTTP cookies with HTTP requests, so let's make this test for that instead by using AssertRequestMustHaveHeaders :) My original request was confused - what I was thinking of is that cookies that are set with |
|
no problem :) |
|
Yes, it looks like we don't have any for that. Let's have the test use a request that uses Set-Cookie, rather than setting it directly, too. |
|
ok, added |
|
|
|
@jdm r+ ? |
|
@bors-servo: retry |
Write unit tests for cookie isolation closes #7624 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7646) <!-- Reviewable:end -->
|
|
|
Uh oh:
|
|
Ah, I misread the last change; my mistake. https://github.com/servo/servo/pull/7646/files#diff-c007a862cc2c468a1b2ae7aa7707e35dR876 says we're setting a secure cookie for https://mozilla.com as expected, but we're also making a request to https://mozilla.com, which explains why the test is failing. We should be requesting http://mozilla.com instead, and making sure that the previously stored cookie is not present in the request. |
|
updated, and makes sense! test still failing though |
|
Reviewed 1 of 1 files at r7. tests/unit/net/http_loader.rs, line 877 [r7] (raw file): Comments from the review on Reviewable.io |
|
@bors-servo: r+ Reviewed 1 of 1 files at r8, 1 of 1 files at r9. Comments from the review on Reviewable.io |
|
|
Write unit tests for cookie isolation closes #7624 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7646) <!-- Reviewable:end -->
|
|
jxs commentedSep 16, 2015
closes #7624