diff options
Diffstat (limited to 'tests/common')
| -rw-r--r-- | tests/common/factory_bot.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/common/factory_bot.rs b/tests/common/factory_bot.rs index bd2cb163..a16a1213 100644 --- a/tests/common/factory_bot.rs +++ b/tests/common/factory_bot.rs @@ -3,6 +3,7 @@ use envoy_types::pb::envoy::service::auth::v3::AttributeContext; use envoy_types::pb::envoy::service::auth::v3::attribute_context::{HttpRequest, Request}; use std::collections::HashMap; +#[allow(dead_code)] pub fn build<T: Default>() -> T { return please::build(); } @@ -33,10 +34,18 @@ pub fn create_test_request_with_headers( })) } +pub fn build_headers(headers: Vec<(String, String)>) -> HashMap<String, String> { + return build_with(|item: &mut HashMap<String, String>| { + for (key, value) in headers { + item.insert(key, value); + } + }); +} + pub fn create_headers_with_auth(auth_value: &str) -> HashMap<String, String> { - let mut headers = build::<HashMap<String, String>>(); - headers.insert(String::from("authorization"), auth_value.to_string()); - headers + return build_with(|item: &mut HashMap<String, String>| { + item.insert(String::from("authorization"), String::from(auth_value)); + }); } pub fn create_token() -> String { |
