auth url test
This commit is contained in:
@@ -491,7 +491,6 @@ pub fn set_stream(resp: &mut Response, unit: Option<Unit>, stream: Stream) {
|
||||
resp.stream = Some(stream);
|
||||
}
|
||||
|
||||
|
||||
fn read_next_line<R: Read>(reader: &mut R) -> IoResult<AsciiString> {
|
||||
let mut buf = Vec::new();
|
||||
let mut prev_byte_was_cr = false;
|
||||
|
||||
@@ -28,3 +28,32 @@ fn kind_auth() {
|
||||
.call();
|
||||
assert_eq!(resp.status(), 200);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn url_auth() {
|
||||
test::set_handler("/url_auth", |unit| {
|
||||
assert_eq!(
|
||||
unit.header("Authorization").unwrap(),
|
||||
"Basic QWxhZGRpbjpPcGVuU2VzYW1l"
|
||||
);
|
||||
test::make_response(200, "OK", vec![], vec![])
|
||||
});
|
||||
let resp = get("test://Aladdin:OpenSesame@host/url_auth").call();
|
||||
assert_eq!(resp.status(), 200);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn url_auth_overridden() {
|
||||
test::set_handler("/url_auth_overridden", |unit| {
|
||||
assert_eq!(
|
||||
unit.header("Authorization").unwrap(),
|
||||
"Basic bWFydGluOnJ1YmJlcm1hc2hndW0="
|
||||
);
|
||||
test::make_response(200, "OK", vec![], vec![])
|
||||
});
|
||||
let agent = agent().auth("martin", "rubbermashgum").build();
|
||||
let resp = agent
|
||||
.get("test://Aladdin:OpenSesame@host/url_auth_overridden")
|
||||
.call();
|
||||
assert_eq!(resp.status(), 200);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user