mirror of https://github.com/fafhrd91/actix-web
Added Unit Test for HTTP Client Basic & Bearer Authorization
This commit is contained in:
parent
761b669175
commit
949c746b51
|
@ -506,3 +506,31 @@ fn client_read_until_eof() {
|
||||||
let bytes = sys.block_on(response.body()).unwrap();
|
let bytes = sys.block_on(response.body()).unwrap();
|
||||||
assert_eq!(bytes, Bytes::from_static(b"welcome!"));
|
assert_eq!(bytes, Bytes::from_static(b"welcome!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn client_basic_auth() {
|
||||||
|
let mut srv =
|
||||||
|
test::TestServer::new(|app| app.handler(|_| HttpResponse::Ok().body(STR)));
|
||||||
|
|
||||||
|
let request = srv
|
||||||
|
.get()
|
||||||
|
.basic_auth("username",Some("password"))
|
||||||
|
.finish()
|
||||||
|
.unwrap();
|
||||||
|
let repr = format!("{:?}", request);
|
||||||
|
assert!(repr.contains("Basic dXNlcm5hbWU6cGFzc3dvcmQ="));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn client_bearer_auth() {
|
||||||
|
let mut srv =
|
||||||
|
test::TestServer::new(|app| app.handler(|_| HttpResponse::Ok().body(STR)));
|
||||||
|
|
||||||
|
let request = srv
|
||||||
|
.get()
|
||||||
|
.bearer_auth("someS3cr3tAutht0k3n")
|
||||||
|
.finish()
|
||||||
|
.unwrap();
|
||||||
|
let repr = format!("{:?}", request);
|
||||||
|
assert!(repr.contains("Bearer someS3cr3tAutht0k3n"));
|
||||||
|
}
|
Loading…
Reference in New Issue