| 159 | #[test] |
| 160 | fn bearer_auth_omits_empty_token() { |
| 161 | let empty = AuthConfig { |
| 162 | auth_type: AuthType::Bearer, |
| 163 | token: String::new(), |
| 164 | ..Default::default() |
| 165 | }; |
| 166 | let filled = AuthConfig { |
| 167 | auth_type: AuthType::Bearer, |
| 168 | token: "abc123".to_string(), |
| 169 | ..Default::default() |
| 170 | }; |
| 171 | |
| 172 | assert_eq!(empty.to_header(), None); |
| 173 | assert_eq!( |
| 174 | filled.to_header(), |
| 175 | Some(("Authorization".to_string(), "Bearer abc123".to_string())) |
| 176 | ); |
| 177 | } |
| 178 | |
| 179 | #[test] |
| 180 | fn api_key_only_generates_header_for_header_mode() { |
| 181 | let query_param = AuthConfig { |
| 182 | auth_type: AuthType::ApiKey, |
| 183 | api_key_name: "X-Api-Key".to_string(), |