Skip to content

Commit

Permalink
display block version in samples
Browse files Browse the repository at this point in the history
this exposes a new public method on `Biscuit` and `UnverifiedBiscuit` to get a block’s version, same as printing a block contents or getting its external key.

Exposing it on `UnverifiedBiscuit` will be useful for biscuit-cli
  • Loading branch information
divarvel committed Nov 21, 2024
1 parent 17ea8f5 commit 8dada64
Show file tree
Hide file tree
Showing 5 changed files with 261 additions and 62 deletions.
3 changes: 3 additions & 0 deletions biscuit-auth/examples/testcases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ struct BlockContent {
pub public_keys: Vec<String>,
pub external_key: Option<String>,
pub code: String,
pub version: u32,
}

#[derive(Debug, Serialize)]
Expand Down Expand Up @@ -243,6 +244,7 @@ impl TestResult {
if let Some(key) = &block.external_key {
writeln!(&mut s, "external signature by: {:?}\n", key);
}
writeln!(&mut s, "block version: {}\n", block.version);
writeln!(&mut s, "```\n{}```\n", block.code);
}

Expand Down Expand Up @@ -2431,6 +2433,7 @@ fn print_blocks(token: &Biscuit) -> Vec<BlockContent> {
.map(|k| k.print())
.collect(),
external_key: token.block_external_key(i).unwrap().map(|k| k.print()),
version: token.block_version(i).unwrap(),
});
}

Expand Down
Loading

0 comments on commit 8dada64

Please sign in to comment.