Skip to content

Commit 1f6c899

Browse files
authored
updates for cedar#1027 (#376) (#415)
1 parent b983bbc commit 1f6c899

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

cedar-drt/fuzz/src/dump.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ pub fn dump(
102102
resource: dump_request_var(q.resource()),
103103
context: dump_context(
104104
q.context()
105-
.expect("`dump` does not support requests missing context"),
105+
.expect("`dump` does not support requests missing context")
106+
.clone(),
106107
),
107108
enable_request_validation: true,
108109
decision: a.decision,
@@ -230,22 +231,19 @@ fn dump_request_var(var: &EntityUIDEntry) -> Option<JsonValueWithNoDuplicateKeys
230231
}
231232

232233
/// Dump the context to a "natural" json value
233-
fn dump_context(context: &Context) -> JsonValueWithNoDuplicateKeys {
234+
fn dump_context(context: Context) -> JsonValueWithNoDuplicateKeys {
234235
let context = context
235-
.iter()
236-
.map(|it| {
237-
it.map(|(k, pval)| {
238-
(
239-
k.clone(),
240-
RestrictedExpr::try_from(pval)
241-
.unwrap()
242-
.to_natural_json()
243-
.unwrap(),
244-
)
245-
})
246-
.collect::<HashMap<_, _>>()
236+
.into_iter()
237+
.map(|(k, pval)| {
238+
(
239+
k,
240+
RestrictedExpr::try_from(pval)
241+
.unwrap()
242+
.to_natural_json()
243+
.unwrap(),
244+
)
247245
})
248-
.unwrap_or_default();
246+
.collect::<HashMap<_, _>>();
249247
serde_json::to_value(context)
250248
.expect("failed to serialize context")
251249
.into()

cedar-policy-generators/src/request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl std::fmt::Display for Request {
5858
"(principal : {}, action: {}, resource: {})",
5959
self.principal, self.action, self.resource
6060
)?;
61-
let mut context = self.context.iter().unwrap().peekable();
61+
let mut context = self.context.clone().into_iter().peekable();
6262
if context.peek().is_some() {
6363
writeln!(f, "\nWith context: {{")?;
6464
for (attr, val) in context {

0 commit comments

Comments
 (0)