diff --git a/biscuit-auth/src/token/authorizer.rs b/biscuit-auth/src/token/authorizer.rs index 6f217cb0..bf594a95 100644 --- a/biscuit-auth/src/token/authorizer.rs +++ b/biscuit-auth/src/token/authorizer.rs @@ -623,6 +623,9 @@ impl Authorizer { pub fn dump_code(&self) -> String { let (facts, rules, checks, policies) = self.dump(); let mut f = String::new(); + + let mut facts = facts.into_iter().map(|f| f.to_string()).collect::>(); + facts.sort(); for fact in &facts { let _ = writeln!(f, "{fact};"); } diff --git a/biscuit-auth/tests/macros.rs b/biscuit-auth/tests/macros.rs index 9ec905ff..adc2034e 100644 --- a/biscuit-auth/tests/macros.rs +++ b/biscuit-auth/tests/macros.rs @@ -78,9 +78,9 @@ fn authorizer_macro() { let authorizer = b.build().unwrap(); assert_eq!( authorizer.dump_code(), - r#"fact("test", hex:aabbcc, [true], "my_value"); + r#"appended(true); +fact("test", hex:aabbcc, [true], "my_value"); rule("test", true); -appended(true); rule($0, true) <- fact($0, $1, $2, "my_value");