Skip to content

Commit 19d7478

Browse files
committed
Reproducer for issue 69
1 parent 023d6be commit 19d7478

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

core/src/test/java/com/styra/opa/wasm/OpaTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212

1313
public class OpaTest {
1414
static Path wasmFile;
15+
static Path issue69WasmFile;
1516

1617
@BeforeAll
1718
public static void beforeAll() throws Exception {
1819
wasmFile = OpaCli.compile("base", "opa/wasm/test/allowed").resolve("policy.wasm");
20+
issue69WasmFile = OpaCli.compile("issue69", "authz/allow").resolve("policy.wasm");
1921
}
2022

2123
@Test
@@ -92,4 +94,16 @@ public void highLevelAPI() throws Exception {
9294
policy.input("{\"user\": \"alice\"}");
9395
Assertions.assertFalse(Utils.getResult(policy.evaluate()).asBoolean());
9496
}
97+
98+
@Test
99+
public void issue69() throws Exception {
100+
var policy = OpaPolicy.builder().withPolicy(issue69WasmFile).build();
101+
policy.data("");
102+
103+
policy.input("{\"method\":\"GET\"}");
104+
Assertions.assertTrue(Utils.getResult(policy.evaluate()).asBoolean());
105+
106+
policy.input("{\"method\":\"POST\"}");
107+
Assertions.assertFalse(Utils.getResult(policy.evaluate()).asBoolean());
108+
}
95109
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package authz
2+
3+
import rego.v1
4+
5+
default allow := false
6+
7+
allow if {
8+
input.method == "GET"
9+
}

0 commit comments

Comments
 (0)