auth headers
This commit is contained in:
27
src/test/auth.rs
Normal file
27
src/test/auth.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use test;
|
||||
|
||||
use super::super::*;
|
||||
|
||||
#[test]
|
||||
fn basic_auth() {
|
||||
test::set_handler("/basic_auth", |req, _url| {
|
||||
assert_eq!(req.get("Authorization").unwrap(), "Basic bWFydGluOnJ1YmJlcm1hc2hndW0=");
|
||||
test::make_stream(200, "OK", vec![], vec![])
|
||||
});
|
||||
let resp = get("test://host/basic_auth")
|
||||
.auth("martin", "rubbermashgum")
|
||||
.call();
|
||||
assert_eq!(*resp.status(), 200);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kind_auth() {
|
||||
test::set_handler("/kind_auth", |req, _url| {
|
||||
assert_eq!(req.get("Authorization").unwrap(), "Digest abcdefgh123");
|
||||
test::make_stream(200, "OK", vec![], vec![])
|
||||
});
|
||||
let resp = get("test://host/kind_auth")
|
||||
.auth_kind("Digest", "abcdefgh123")
|
||||
.call();
|
||||
assert_eq!(*resp.status(), 200);
|
||||
}
|
||||
Reference in New Issue
Block a user