blob: e21371467993da43ecb750abb1f9d092ae4fe3ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
use envoy_types::ext_authz::v3::pb::CheckRequest;
use std::collections::HashMap;
use tonic::Request;
pub fn create_test_request_with_headers(headers: HashMap<String, String>) -> Request<CheckRequest> {
use envoy_types::pb::envoy::service::auth::v3::{AttributeContext, attribute_context};
let http_request = attribute_context::HttpRequest {
headers,
..Default::default()
};
let request_context = attribute_context::Request {
http: Some(http_request),
..Default::default()
};
let attributes = AttributeContext {
request: Some(request_context),
..Default::default()
};
let check_request = CheckRequest {
attributes: Some(attributes),
..Default::default()
};
Request::new(check_request)
}
pub fn create_headers_with_auth(auth_value: &str) -> HashMap<String, String> {
let mut headers = HashMap::new();
headers.insert("authorization".to_string(), auth_value.to_string());
headers
}
|