Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

samples verify block by block #88

Closed
wants to merge 10 commits into from

Conversation

KannarFr
Copy link
Contributor

@KannarFr KannarFr commented Apr 8, 2024

This is DRAFT.

@KannarFr KannarFr marked this pull request as draft April 8, 2024 15:36
@KannarFr KannarFr force-pushed the verifyBlocks branch 3 times, most recently from 50fbfd3 to fb4ae04 Compare April 9, 2024 10:09
@KannarFr KannarFr changed the title samples verify block by lock samples verify block by block Apr 9, 2024
@KannarFr KannarFr force-pushed the verifyBlocks branch 4 times, most recently from a04ce68 to e7a2e46 Compare April 9, 2024 20:56
src/main/java/org/biscuitsec/biscuit/token/Block.java Outdated Show resolved Hide resolved
SymbolTable sampleSymbols = new SymbolTable(sampleBlock.symbols);

Either<Map<Integer, List<org.biscuitsec.biscuit.token.builder.parser.Error>>, org.biscuitsec.biscuit.token.builder.Block> outputSample = Parser.datalog(sampleBlockIndex, baseSymbols, sampleDatalog);
assertTrue(outputSample.isRight());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should show the input that was parsed and the error we got, otherwise we don't have any context to fix it

System.out.println(outputSample.get().build().print(sampleSymbols));
System.out.println(block.symbols.symbols);
System.out.println(block.print(sampleSymbols));
assertArrayEquals(outputSample.get().build().to_bytes().get(), block.to_bytes().get());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, this should show the expected and actual arrays, because the errors don't help https://github.com/biscuit-auth/biscuit-java/actions/runs/8622173639/job/23632740026?pr=88#step:5:6259

@Geal
Copy link
Contributor

Geal commented Apr 14, 2024

BTW is there a good way in maven to capture stdout in tests, so that we only display it for tests that failed?

@Geal
Copy link
Contributor

Geal commented May 1, 2024

#94 merges the parts of this PR that were already usable, leaving the samples block checks and the Parser.datalog method.

Right now I am not too convinced about the implementation of that method that does manual string manipulations. An implementation that follows the rest of the parser, using parser combinators, would fit better here and prevent errors.
The Rust reference implementation can be used as inspiration here https://github.com/biscuit-auth/biscuit-rust/blob/main/biscuit-parser/src/parser.rs#L895-L970

@Geal Geal mentioned this pull request Jun 15, 2024
@Geal
Copy link
Contributor

Geal commented Jun 15, 2024

closing this since it has been merged as part of #102

@Geal Geal closed this Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants