test: Add test for token-based authentication (bearer_auth)

This commit is contained in:
Vincent Ambo 2019-02-26 16:47:51 +01:00
parent b493bc3c84
commit 791e2958fc

View file

@ -92,6 +92,15 @@ fn test_http_post_json() {
// Tests for different authentication methods that are supported // Tests for different authentication methods that are supported
// out-of-the-box: // out-of-the-box:
#[test]
fn test_bearer_auth() {
let response = Request::new(Method::Get, "https://httpbin.org/bearer")
.bearer_auth("some-token").expect("failed to set auth header")
.send().expect("failed to send request");
assert!(response.is_success(), "authorized request should succeed");
}
#[cfg(feature = "basic_auth")] #[test] #[cfg(feature = "basic_auth")] #[test]
fn test_basic_auth() { fn test_basic_auth() {
let request = Request::new( let request = Request::new(