summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock6
-rw-r--r--Cargo.toml1
-rw-r--r--src/authorization/cedar_authorizer.rs36
3 files changed, 18 insertions, 25 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 9d1c3bdc..9ceb88cf 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -76,6 +76,7 @@ name = "authzd"
version = "0.1.0"
dependencies = [
"envoy-types",
+ "please",
"tokio",
"tokio-test",
"tonic",
@@ -568,6 +569,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
+name = "please"
+version = "0.1.0"
+source = "git+https://github.com/xlgmokha/please.git#bff13caf9ee2f806dd32c5d77f0e4ac9eb28c7f5"
+
+[[package]]
name = "prettyplease"
version = "0.2.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index a13b9464..5eeecac3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,6 +13,7 @@ path = "src/lib.rs"
[dependencies]
envoy-types = "0.6.0"
+please = { git = "https://github.com/xlgmokha/please.git", version = "0.1.0" }
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
tonic = "*"
tonic-health = "0.13.1"
diff --git a/src/authorization/cedar_authorizer.rs b/src/authorization/cedar_authorizer.rs
index 16a3f405..c1f5455d 100644
--- a/src/authorization/cedar_authorizer.rs
+++ b/src/authorization/cedar_authorizer.rs
@@ -35,22 +35,6 @@ impl Authorizer for CedarAuthorizer {
}
}
-mod x {
- pub fn build<T: Default>() -> T {
- T::default()
- }
-
- pub fn build_with<T, F>(initializer: F) -> T
- where
- T: Default,
- F: std::ops::FnOnce(&mut T),
- {
- let mut item = build::<T>();
- initializer(&mut item);
- item
- }
-}
-
#[cfg(test)]
mod tests {
use super::*;
@@ -58,15 +42,17 @@ mod tests {
use std::collections::HashMap;
fn create_test_request_with_headers(headers: HashMap<String, String>) -> CheckRequest {
- x::build_with(|item: &mut CheckRequest| {
- item.attributes = Some(x::build_with(|item: &mut AttributeContext| {
- item.request = Some(x::build_with(|item: &mut attribute_context::Request| {
- item.http = Some(x::build_with(
- |item: &mut attribute_context::HttpRequest| {
- item.headers = headers;
- },
- ));
- }));
+ please::build_with(|item: &mut CheckRequest| {
+ item.attributes = Some(please::build_with(|item: &mut AttributeContext| {
+ item.request = Some(please::build_with(
+ |item: &mut attribute_context::Request| {
+ item.http = Some(please::build_with(
+ |item: &mut attribute_context::HttpRequest| {
+ item.headers = headers;
+ },
+ ));
+ },
+ ));
}));
})
}