about summary refs log tree commit diff
path: root/src/tests.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2019-02-26T15·47+0100
committerVincent Ambo <mail@tazj.in>2019-02-26T16·30+0100
commit791e2958fc1c5c3f9efe88f84db798fcaea319bb (patch)
treedb9d3fee4e97d4898a99e94188f72a2c773e3f6a /src/tests.rs
parentb493bc3c8436be9812a58e7ddaf3777df642836c (diff)
test: Add test for token-based authentication (bearer_auth)
Diffstat (limited to 'src/tests.rs')
-rw-r--r--src/tests.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/tests.rs b/src/tests.rs
index 088334aa2784..9fce04b15f21 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -92,6 +92,15 @@ fn test_http_post_json() {
 // Tests for different authentication methods that are supported
 // 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]
 fn test_basic_auth() {
     let request = Request::new(