diff --git a/src/main/java/org/biscuitsec/biscuit/datalog/SymbolTable.java b/src/main/java/org/biscuitsec/biscuit/datalog/SymbolTable.java index 94e6a499..489dae2f 100644 --- a/src/main/java/org/biscuitsec/biscuit/datalog/SymbolTable.java +++ b/src/main/java/org/biscuitsec/biscuit/datalog/SymbolTable.java @@ -177,7 +177,7 @@ public String print_scope(final Scope scope) { case PublicKey: Option pk = this.get_pk((int) scope.publicKey); if(pk.isDefined()) { - return pk.toString(); + return pk.get().toString(); } } return "?"; diff --git a/src/main/java/org/biscuitsec/biscuit/datalog/expressions/Op.java b/src/main/java/org/biscuitsec/biscuit/datalog/expressions/Op.java index 62b2c99d..dfdcfe27 100644 --- a/src/main/java/org/biscuitsec/biscuit/datalog/expressions/Op.java +++ b/src/main/java/org/biscuitsec/biscuit/datalog/expressions/Op.java @@ -157,7 +157,7 @@ public String print(Deque stack, SymbolTable symbols) { String _s = ""; switch (this.op) { case Negate: - _s = "! " + prec; + _s = "!" + prec; stack.push(_s); break; case Parens: diff --git a/src/main/java/org/biscuitsec/biscuit/token/Authorizer.java b/src/main/java/org/biscuitsec/biscuit/token/Authorizer.java index 0d2d3618..9462c8d3 100644 --- a/src/main/java/org/biscuitsec/biscuit/token/Authorizer.java +++ b/src/main/java/org/biscuitsec/biscuit/token/Authorizer.java @@ -631,15 +631,11 @@ public String print_world() { } public FactSet facts() { - return this.world.facts();/*.stream() - .map((f) -> org.biscuitsec.biscuit.token.builder.Fact.convert_from(f, this.symbols)) - .collect(Collectors.toList());*/ + return this.world.facts(); } public RuleSet rules() { - return this.world.rules();/*.stream() - .map((r) -> org.biscuitsec.biscuit.token.builder.Rule.convert_from(r, this.symbols)) - .collect(Collectors.toList());*/ + return this.world.rules(); } public List>> checks() { diff --git a/src/test/java/org/biscuitsec/biscuit/token/SamplesTest.java b/src/test/java/org/biscuitsec/biscuit/token/SamplesTest.java index 8fb90775..0ae50204 100644 --- a/src/test/java/org/biscuitsec/biscuit/token/SamplesTest.java +++ b/src/test/java/org/biscuitsec/biscuit/token/SamplesTest.java @@ -92,20 +92,18 @@ DynamicTest process_testcase(final TestCase testCase, final PublicKey publicKey, world.fixOrigin(); System.out.println("fixed origin"); - World authorizerWorld = new World(authorizer); - System.out.println("validation world"+world); System.out.println("authorizer world"+authorizerWorld); assertEquals(world.factMap(), authorizerWorld.factMap()); - /*assertEquals(world.rules.size(), authorizerWorld.rules.size()); + assertEquals(world.rules.size(), authorizerWorld.rules.size()); for (int i = 0; i < world.rules.size(); i++) { assertEquals(world.rules.get(i), authorizerWorld.rules.get(i)); } - assertEquals(world.checks.size(), authorizerWorld.checks.size()); + /*assertEquals(world.checks.size(), authorizerWorld.checks.size()); for (int i = 0; i < world.checks.size(); i++) { assertEquals(world.checks.get(i), authorizerWorld.checks.get(i)); } @@ -129,12 +127,15 @@ DynamicTest process_testcase(final TestCase testCase, final PublicKey publicKey, System.out.println(world.facts); System.out.println(authorizerWorld.facts); assertEquals(world.factMap(), authorizerWorld.factMap()); - - /*assertEquals(world.rules.size(), authorizerWorld.rules.size()); + + System.out.println(world.rules); + System.out.println(authorizerWorld.rules); + + assertEquals(world.rules.size(), authorizerWorld.rules.size()); for (int i = 0; i < world.rules.size(); i++) { assertEquals(world.rules.get(i), authorizerWorld.rules.get(i)); } - assertEquals(world.checks.size(), authorizerWorld.checks.size()); + /*assertEquals(world.checks.size(), authorizerWorld.checks.size()); for (int i = 0; i < world.checks.size(); i++) { assertEquals(world.checks.get(i), authorizerWorld.checks.get(i)); } @@ -381,6 +382,7 @@ public void fixOrigin() { this.origin.set(i, Long.MAX_VALUE); } } + Collections.sort(this.origin); System.out.println("->: "+this.origin); @@ -434,6 +436,32 @@ public int compareTo(RuleSet ruleSet) { return this.origin.compareTo(ruleSet.origin); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + RuleSet ruleSet = (RuleSet) o; + + if (!Objects.equals(origin, ruleSet.origin)) return false; + return Objects.equals(rules, ruleSet.rules); + } + + @Override + public int hashCode() { + int result = origin != null ? origin.hashCode() : 0; + result = 31 * result + (rules != null ? rules.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "RuleSet{" + + "origin=" + origin + + ", rules=" + rules + + '}'; + } } class CheckSet implements Comparable { @@ -462,6 +490,14 @@ public int compareTo(RuleSet ruleSet) { return this.origin.compareTo(ruleSet.origin); } } + + @Override + public String toString() { + return "CheckSet{" + + "origin=" + origin + + ", checks=" + checks + + '}'; + } } }