use of org.graalvm.polyglot.PolyglotAccess in project graal by oracle.
the class ContextPolyglotAccessTest method testCustomPolyglotEvalBetweenThree2.
@Test
public void testCustomPolyglotEvalBetweenThree2() {
PolyglotAccess access = //
PolyglotAccess.newBuilder().allowEvalBetween(LANGUAGE1, LANGUAGE2, //
LANGUAGE3).denyEvalBetween(LANGUAGE1, //
LANGUAGE2).build();
setupEnv(Context.newBuilder(ProxyLanguage.ID, LANGUAGE1, LANGUAGE2, LANGUAGE3).allowPolyglotAccess(access).build());
context.initialize(LANGUAGE1);
context.initialize(LANGUAGE2);
context.initialize(LANGUAGE3);
Env language1 = Language1.getContext(LANGUAGE1);
Env language2 = Language2.getContext(LANGUAGE2);
Env language3 = Language2.getContext(LANGUAGE3);
assertPublicEvalDenied(language1, INTERNAL);
assertPublicEvalDenied(language1, DEPENDENT);
assertPublicEvalAllowed(language1, LANGUAGE1);
assertPublicEvalDenied(language1, LANGUAGE2);
assertPublicEvalAllowed(language1, LANGUAGE3);
assertInternalEvalAllowed(language1, INTERNAL);
assertInternalEvalAllowed(language1, DEPENDENT);
assertInternalEvalAllowed(language1, LANGUAGE1);
assertInternalEvalDenied(language1, LANGUAGE2);
assertInternalEvalAllowed(language1, LANGUAGE3);
assertPublicEvalDenied(language2, INTERNAL);
assertPublicEvalDenied(language2, DEPENDENT);
assertPublicEvalDenied(language2, LANGUAGE1);
assertPublicEvalAllowed(language2, LANGUAGE2);
assertPublicEvalAllowed(language2, LANGUAGE3);
assertInternalEvalAllowed(language2, INTERNAL);
assertInternalEvalDenied(language2, DEPENDENT);
assertInternalEvalDenied(language2, LANGUAGE1);
assertInternalEvalAllowed(language2, LANGUAGE2);
assertInternalEvalAllowed(language2, LANGUAGE3);
assertPublicEvalDenied(language3, INTERNAL);
assertPublicEvalDenied(language3, DEPENDENT);
assertPublicEvalAllowed(language3, LANGUAGE1);
assertPublicEvalAllowed(language3, LANGUAGE2);
assertPublicEvalAllowed(language3, LANGUAGE3);
assertInternalEvalAllowed(language3, INTERNAL);
assertInternalEvalDenied(language3, DEPENDENT);
assertInternalEvalAllowed(language3, LANGUAGE1);
assertInternalEvalAllowed(language3, LANGUAGE2);
assertInternalEvalAllowed(language3, LANGUAGE3);
}
use of org.graalvm.polyglot.PolyglotAccess in project graal by oracle.
the class ContextPolyglotAccessTest method testCustomPolyglotEvalDirectSame.
@Test
public void testCustomPolyglotEvalDirectSame() {
PolyglotAccess access = PolyglotAccess.newBuilder().allowEval(LANGUAGE1, LANGUAGE1).build();
setupEnv(Context.newBuilder(ProxyLanguage.ID, LANGUAGE1, LANGUAGE2).allowPolyglotAccess(access).build());
context.initialize(LANGUAGE1);
context.initialize(LANGUAGE2);
Env language1 = Language1.getContext(LANGUAGE1);
Env language2 = Language2.getContext(LANGUAGE2);
assertPublicEvalDenied(language1, INTERNAL);
assertPublicEvalDenied(language1, DEPENDENT);
assertPublicEvalAllowed(language1, LANGUAGE1);
assertPublicEvalDenied(language1, LANGUAGE2);
assertInternalEvalAllowed(language1, INTERNAL);
assertInternalEvalAllowed(language1, DEPENDENT);
assertInternalEvalAllowed(language1, LANGUAGE1);
assertInternalEvalDenied(language1, LANGUAGE2);
assertPublicEvalDenied(language2, INTERNAL);
assertPublicEvalDenied(language2, DEPENDENT);
assertPublicEvalDenied(language2, LANGUAGE1);
assertPublicEvalAllowed(language2, LANGUAGE2);
assertInternalEvalAllowed(language2, INTERNAL);
assertInternalEvalDenied(language2, DEPENDENT);
assertInternalEvalDenied(language2, LANGUAGE1);
assertInternalEvalAllowed(language2, LANGUAGE2);
assertNoEvalAccess(language1);
assertNoEvalAccess(language2);
}
Aggregations