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 up401 authorization UI then restart request/save successful auth creds #10328
Conversation
highfive
commented
Apr 1, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Apr 1, 2016
|
Great! I've suggested some ways to restructure the code to make it testable as well as avoid potentially including authorization headers when they aren't necessary. Reviewed 5 of 5 files at r1. vi, line 0 [r1] (raw file): components/net/http_loader.rs, line 690 [r1] (raw file): fn load<A,B>(mut load_data: LoadData,
ui_provider: &B,
...)
-> ... where B: UIProviderand write a unit test that verifies that this code works. components/net/http_loader.rs, line 768 [r1] (raw file): components/net/http_loader.rs, line 773 [r1] (raw file): components/net/http_loader.rs, line 779 [r1] (raw file): components/net/http_loader.rs, line 782 [r1] (raw file): components/net/http_loader.rs, line 788 [r1] (raw file): components/net/http_loader.rs, line 792 [r1] (raw file): components/net/http_loader.rs, line 793 [r1] (raw file): components/net/http_loader.rs, line 798 [r1] (raw file): components/servo/Cargo.lock, line 2085 [r1] (raw file): Comments from the review on Reviewable.io |
|
I am having trouble coming up with the unit test. I can make a mock request with a 401, however I do not know how to check the headers in the request create function and change the mock request to a non 401 after the headers have been set. What I have started for the unit test is in this pr. |
|
I just realized I should not be checking the response headers in the unit test but instead maybe the response status code |
|
That is correct. |
|
Looking good! I've laid out how I think the unit test can be implmented; let me know if anything's unclear! Reviewed 5 of 5 files at r2. components/net/http_loader.rs, line 145 [r2] (raw file): components/net/http_loader.rs, line 694 [r2] (raw file): components/net/http_loader.rs, line 715 [r2] (raw file): components/net/http_loader.rs, line 719 [r2] (raw file): components/net/http_loader.rs, line 724 [r2] (raw file): components/net/http_loader.rs, line 800 [r2] (raw file): if let Some(ref auth_header) = new_auth_header {
request_headers.set(auth_header.clone());
}components/net/http_loader.rs, line 815 [r2] (raw file): components/net/http_loader.rs, line 829 [r2] (raw file): tests/unit/net/http_loader.rs, line 102 [r2] (raw file): tests/unit/net/http_loader.rs, line 1576 [r2] (raw file): tests/unit/net/http_loader.rs, line 1608 [r2] (raw file): Comments from Reviewable |
|
Should I wait for #10555 before going further with the unit test stuff? |
|
No, I was intending to hold off merging that until after these changes. |
|
This new unit test makes sure a auth header is set with the ui on a 401 response. It does not explicitly check if the response was a 200, however the new testing type returns a 200 response once the auth header is set with the correct credentials. I am not sure if that is sufficient or not. |
|
This looks great! Please do check that the response we end up with in the test is the one we expect, but otherwise this is ready to merge after a rebase and squash. Reviewed 2 of 2 files at r4. components/net/http_loader.rs, line 796 [r4] (raw file): tests/unit/net/http_loader.rs, line 1652 [r4] (raw file): Comments from Reviewable |
|
rebasing now |
|
@bors-servo r=jdm |
|
|
401 authorization UI then restart request/save successful auth creds Step 7 of the NCSU student project Implement HTTP authorization UI > make an authorization UI appear when a 401 HTTP response is received (StatusCode::Unauthorized) - in load in http_loader.rs, right before trying to process an HTTP redirection, use the new tinyfiledialogs library to make two prompts appear (username and password), then restart the request with the new authorization value present applied. If an authorization value was present and the response is successful, add the credentials to the authorization cache. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10328) <!-- Reviewable:end -->
|
|
|
ran cargo-update -p net |
|
@bors-servo r=jdm |
|
|
401 authorization UI then restart request/save successful auth creds Step 7 of the NCSU student project Implement HTTP authorization UI > make an authorization UI appear when a 401 HTTP response is received (StatusCode::Unauthorized) - in load in http_loader.rs, right before trying to process an HTTP redirection, use the new tinyfiledialogs library to make two prompts appear (username and password), then restart the request with the new authorization value present applied. If an authorization value was present and the response is successful, add the credentials to the authorization cache. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10328) <!-- Reviewable:end -->
|
|
|
@bors-servo: retry |
|
|
|
|
DDEFISHER commentedApr 1, 2016
Step 7 of the NCSU student project Implement HTTP authorization UI
This change is