Skip to content

Commit 2eeb0d9

Browse files
committed
add test for starting a python context without any allowed access
1 parent 6323a93 commit 2eeb0d9

File tree

1 file changed

+17
-1
lines changed
  • graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/interop

1 file changed

+17
-1
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/interop/JavaInteropTest.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@
4646

4747
import java.io.ByteArrayOutputStream;
4848
import java.io.IOException;
49+
import java.io.UnsupportedEncodingException;
4950
import java.util.Arrays;
5051
import java.util.List;
51-
import java.io.UnsupportedEncodingException;
5252

5353
import org.graalvm.polyglot.Context;
5454
import org.graalvm.polyglot.Context.Builder;
55+
import org.graalvm.polyglot.Engine;
5556
import org.graalvm.polyglot.Source;
5657
import org.graalvm.polyglot.Value;
5758
import org.junit.After;
@@ -434,4 +435,19 @@ public void accessJavaObjectGetters() throws IOException {
434435
"True <class 'bool'>\n" +
435436
"c <class 'str'>\n", out.toString("UTF-8"));
436437
}
438+
439+
@Test
440+
public void testSharedEngineNoAccess() {
441+
try (Engine engine = Engine.create()) {
442+
Source source = Source.create("python", "21 + 21");
443+
try (Context ctxt = Context.newBuilder().engine(engine).allowAllAccess(false).build()) {
444+
int v = ctxt.eval(source).asInt();
445+
assert v == 42;
446+
}
447+
try (Context ctxt = Context.newBuilder().engine(engine).allowAllAccess(false).build()) {
448+
int v = ctxt.eval(source).asInt();
449+
assert v == 42;
450+
}
451+
}
452+
}
437453
}

0 commit comments

Comments
 (0)