auth headers

This commit is contained in:
Martin Algesten
2018-06-11 22:44:32 +02:00
parent ea6c4b1f3b
commit 9852960bd7
4 changed files with 35 additions and 19 deletions

27
src/test/auth.rs Normal file
View 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);
}