mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Remove test_auth_ui_sets_header_on_401.
The fetch stack does not yet support asking the user for credentials (#14305).
This commit is contained in:
parent
9f23949628
commit
4c34e9aa89
1 changed files with 0 additions and 55 deletions
|
@ -224,28 +224,6 @@ impl HttpRequest for MockRequest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AssertAuthHeaderRequestFactory {
|
|
||||||
expected_headers: Headers,
|
|
||||||
body: Vec<u8>
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HttpRequestFactory for AssertAuthHeaderRequestFactory {
|
|
||||||
type R = MockRequest;
|
|
||||||
|
|
||||||
fn create(&self, _: ServoUrl, _: Method, headers: Headers) -> Result<MockRequest, LoadError> {
|
|
||||||
let request = if headers.has::<Authorization<Basic>>() {
|
|
||||||
assert_headers_included(&self.expected_headers, &headers);
|
|
||||||
MockRequest::new(ResponseType::Text(self.body.clone()))
|
|
||||||
} else {
|
|
||||||
let mut headers = Headers::new();
|
|
||||||
headers.set_raw("WWW-Authenticate", vec![b"Basic realm=\"Test realm\"".to_vec()]);
|
|
||||||
MockRequest::new(ResponseType::NeedsAuth(headers))
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(request)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn assert_headers_included(expected: &Headers, request: &Headers) {
|
fn assert_headers_included(expected: &Headers, request: &Headers) {
|
||||||
assert!(expected.len() != 0);
|
assert!(expected.len() != 0);
|
||||||
for header in expected.iter() {
|
for header in expected.iter() {
|
||||||
|
@ -1529,39 +1507,6 @@ fn test_if_auth_creds_not_in_url_but_in_cache_it_sets_it() {
|
||||||
assert!(response.status.unwrap().is_success());
|
assert!(response.status.unwrap().is_success());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_auth_ui_sets_header_on_401() {
|
|
||||||
let url = ServoUrl::parse("http://mozilla.com").unwrap();
|
|
||||||
let http_state = HttpState::new();
|
|
||||||
let ui_provider = TestProvider { username: "test".to_owned(), password: "test".to_owned() };
|
|
||||||
|
|
||||||
let mut auth_header = Headers::new();
|
|
||||||
|
|
||||||
auth_header.set(
|
|
||||||
Authorization(
|
|
||||||
Basic {
|
|
||||||
username: "test".to_owned(),
|
|
||||||
password: Some("test".to_owned())
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
let load_data = LoadData::new(LoadContext::Browsing, url, &HttpTest);
|
|
||||||
|
|
||||||
match load(
|
|
||||||
&load_data, &ui_provider, &http_state,
|
|
||||||
None, &AssertAuthHeaderRequestFactory {
|
|
||||||
expected_headers: auth_header,
|
|
||||||
body: <[_]>::to_vec(&[])
|
|
||||||
}, DEFAULT_USER_AGENT.into(), &CancellationListener::new(None), None) {
|
|
||||||
Err(e) => panic!("response contained error {:?}", e),
|
|
||||||
Ok(response) => {
|
|
||||||
assert_eq!(response.metadata.status,
|
|
||||||
Some((200, b"OK".to_vec())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_auth_ui_needs_www_auth() {
|
fn test_auth_ui_needs_www_auth() {
|
||||||
let url = ServoUrl::parse("http://mozilla.com").unwrap();
|
let url = ServoUrl::parse("http://mozilla.com").unwrap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue