Skip to content

Commit

Permalink
fixup! errors: display more info about failed checks and policies
Browse files Browse the repository at this point in the history
  • Loading branch information
divarvel committed Nov 25, 2024
1 parent 2d46af7 commit f1cb4a5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions biscuit-auth/src/token/authorizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,8 @@ impl AuthorizerExt for Authorizer {
mod tests {
use std::time::Duration;

use token::{public_keys::PublicKeys, DATALOG_3_1};

use crate::{
builder::{Algorithm, BiscuitBuilder, BlockBuilder},
KeyPair,
Expand Down Expand Up @@ -1815,4 +1817,38 @@ allow if true;
let authorizer = Authorizer::new();
assert_eq!("", authorizer.to_string())
}

#[test]
fn rule_validate_variables() {
let mut authorizer = Authorizer::new();
let mut syms = SymbolTable::new();
let rule_name = syms.insert("test");
let pred_name = syms.insert("pred");
let rule = datalog::rule(
rule_name,
&[datalog::var(&mut syms, "unbound")],
&[datalog::pred(pred_name, &[datalog::var(&mut syms, "any")])],
);
let mut block = Block {
symbols: syms.clone(),
facts: vec![],
rules: vec![rule],
checks: vec![],
context: None,
version: DATALOG_3_1,
external_key: None,
public_keys: PublicKeys::new(),
scopes: vec![],
};

assert_eq!(
authorizer
.load_and_translate_block(&mut block, 0, &syms)
.unwrap_err(),
error::Token::FailedLogic(error::Logic::InvalidBlockRule(
0,
"test($unbound) <- pred($any)".to_string()
))
);
}
}

0 comments on commit f1cb4a5

Please sign in to comment.