Skip to content

Commit

Permalink
fix macro test coverage (#236)
Browse files Browse the repository at this point in the history
* more explicit test assert

* update run limits
  • Loading branch information
Geal authored Nov 3, 2024
1 parent e59f41d commit f099d38
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions biscuit-auth/tests/macros.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use biscuit_auth::{builder, KeyPair};
use biscuit_auth::{builder, datalog::RunLimits, KeyPair};
use biscuit_quote::{
authorizer, authorizer_merge, biscuit, biscuit_merge, block, block_merge, check, fact, policy,
rule,
};
use serde_json::json;
use std::{collections::BTreeSet, convert::TryInto};
use std::{collections::BTreeSet, convert::TryInto, time::Duration};

#[test]
fn block_macro() {
Expand Down Expand Up @@ -237,7 +237,7 @@ fn json() {
);
let json_value: biscuit_auth::builder::Term = value.try_into().unwrap();

let authorizer = authorizer!(
let mut authorizer = authorizer!(
r#"
user_roles({json_value});
allow if
Expand All @@ -247,5 +247,14 @@ fn json() {
$value.get("roles").contains("admin");"#
);

assert!(biscuit.authorize(&authorizer).is_ok());
authorizer.add_token(&biscuit).unwrap();
assert_eq!(
authorizer
.authorize_with_limits(RunLimits {
max_time: Duration::from_secs(1),
..Default::default()
})
.unwrap(),
0
);
}

0 comments on commit f099d38

Please sign in to comment.