test: Add test for token-based authentication (bearer_auth)
This commit is contained in:
		
							parent
							
								
									b493bc3c84
								
							
						
					
					
						commit
						791e2958fc
					
				
					 1 changed files with 9 additions and 0 deletions
				
			
		| 
						 | 
					@ -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(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue