From 88bd7851831d6eeacaca419401483ea8e8b82ad9 Mon Sep 17 00:00:00 2001 From: shanggeeth Date: Tue, 6 Feb 2024 11:40:59 +0530 Subject: [PATCH] Modify unit tests to test for both nashorn and graaljs script engines. --- .../pom.xml | 12 ++++++ .../CallAnalyticsFunctionImplTest.java | 2 +- .../src/test/resources/testng.xml | 34 +++++++++++++++++ .../pom.xml | 12 ++++++ .../choreo/CallChoreoFunctionImplTest.java | 2 - .../src/test/resources/testng.xml | 34 +++++++++++++++++ .../pom.xml | 12 ++++++ .../elk/CallElasticFunctionImplTest.java | 6 ++- .../src/test/resources/testng.xml | 34 +++++++++++++++++ .../pom.xml | 12 ++++++ .../http/CookieFunctionImplTest.java | 1 - .../http/HTTPGetFunctionImplTest.java | 6 ++- .../http/HTTPPostFunctionImplTest.java | 6 ++- .../src/test/resources/testng.xml | 38 +++++++++++++++++++ .../pom.xml | 12 ++++++ .../SendEmailFunctionImplTest.java | 2 - .../src/test/resources/testng.xml | 34 +++++++++++++++++ .../JsSequenceHandlerAbstractTest.java | 6 ++- .../sequence/JsSequenceHandlerRunner.java | 25 ++++++++++-- .../pom.xml | 12 ++++++ .../user/model/JsGraalWrapperFactory.java | 2 +- .../HasAnyOfTheRolesFunctionImplTest.java | 2 - .../user/HasRoleFunctionImplTest.java | 2 - ...IsMemberOfAnyOfGroupsFunctionImplTest.java | 1 - .../src/test/resources/testng.xml | 38 +++++++++++++++++++ pom.xml | 8 ++-- 26 files changed, 328 insertions(+), 27 deletions(-) create mode 100644 components/org.wso2.carbon.identity.conditional.auth.functions.analytics/src/test/resources/testng.xml create mode 100644 components/org.wso2.carbon.identity.conditional.auth.functions.choreo/src/test/resources/testng.xml create mode 100644 components/org.wso2.carbon.identity.conditional.auth.functions.elk/src/test/resources/testng.xml create mode 100644 components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/resources/testng.xml create mode 100644 components/org.wso2.carbon.identity.conditional.auth.functions.notification/src/test/resources/testng.xml create mode 100644 components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/resources/testng.xml diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/pom.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/pom.xml index 79ff5b55..3bc120c8 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/pom.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/pom.xml @@ -196,6 +196,18 @@ org.jacoco jacoco-maven-plugin + + org.apache.maven.plugins + maven-surefire-plugin + + + src/test/resources/testng.xml + + + org.ops4j.pax.logging + + + diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/analytics/CallAnalyticsFunctionImplTest.java b/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/analytics/CallAnalyticsFunctionImplTest.java index 6049264c..38d63885 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/analytics/CallAnalyticsFunctionImplTest.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/analytics/CallAnalyticsFunctionImplTest.java @@ -74,7 +74,7 @@ public class CallAnalyticsFunctionImplTest extends JsSequenceHandlerAbstractTest @BeforeMethod protected void setUp() throws Exception { - super.setUp(); +// super.setUp(); CarbonConstants.ENABLE_LEGACY_AUTHZ_RUNTIME = true; sequenceHandlerRunner.registerJsFunction("callAnalytics", new CallAnalyticsFunctionImpl()); diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/src/test/resources/testng.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/src/test/resources/testng.xml new file mode 100644 index 00000000..0f6f533c --- /dev/null +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/src/test/resources/testng.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.choreo/pom.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.choreo/pom.xml index 73042545..105d724a 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.choreo/pom.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.choreo/pom.xml @@ -234,6 +234,18 @@ org.jacoco jacoco-maven-plugin + + org.apache.maven.plugins + maven-surefire-plugin + + + src/test/resources/testng.xml + + + org.ops4j.pax.logging + + + diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.choreo/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/choreo/CallChoreoFunctionImplTest.java b/components/org.wso2.carbon.identity.conditional.auth.functions.choreo/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/choreo/CallChoreoFunctionImplTest.java index 8d3fd64a..e2ce573f 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.choreo/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/choreo/CallChoreoFunctionImplTest.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.choreo/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/choreo/CallChoreoFunctionImplTest.java @@ -109,8 +109,6 @@ public class CallChoreoFunctionImplTest extends JsSequenceHandlerAbstractTest { @BeforeMethod protected void setUp() throws Exception { - super.setUp(); - CarbonConstants.ENABLE_LEGACY_AUTHZ_RUNTIME = true; sequenceHandlerRunner.registerJsFunction("callChoreo", new CallChoreoFunctionImpl()); UserRealm userRealm = realmService.getTenantUserRealm(-1234); diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.choreo/src/test/resources/testng.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.choreo/src/test/resources/testng.xml new file mode 100644 index 00000000..57f93041 --- /dev/null +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.choreo/src/test/resources/testng.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.elk/pom.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.elk/pom.xml index 940bacf3..ba1ee77f 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.elk/pom.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.elk/pom.xml @@ -161,6 +161,18 @@ org.jacoco jacoco-maven-plugin + + org.apache.maven.plugins + maven-surefire-plugin + + + src/test/resources/testng.xml + + + org.ops4j.pax.logging + + + diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.elk/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/elk/CallElasticFunctionImplTest.java b/components/org.wso2.carbon.identity.conditional.auth.functions.elk/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/elk/CallElasticFunctionImplTest.java index 95a0cfe5..a5e0f0a2 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.elk/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/elk/CallElasticFunctionImplTest.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.elk/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/elk/CallElasticFunctionImplTest.java @@ -22,6 +22,7 @@ import org.json.JSONObject; import org.mockito.Mockito; import org.testng.annotations.BeforeClass; +import org.testng.annotations.Parameters; import org.testng.annotations.Test; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig; @@ -74,9 +75,10 @@ public class CallElasticFunctionImplTest extends JsSequenceHandlerAbstractTest { private int microServicePort; @BeforeClass - protected void initClass() throws Exception { + @Parameters({"scriptEngine"}) + protected void initClass(String scriptEngine) throws Exception { - super.setUp(); + super.setUp(scriptEngine); CarbonConstants.ENABLE_LEGACY_AUTHZ_RUNTIME = true; sequenceHandlerRunner.registerJsFunction("callElastic", new CallElasticFunctionImpl()); } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.elk/src/test/resources/testng.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.elk/src/test/resources/testng.xml new file mode 100644 index 00000000..88d6ab12 --- /dev/null +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.elk/src/test/resources/testng.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.http/pom.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.http/pom.xml index f46ce6c0..1e5f62f5 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.http/pom.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.http/pom.xml @@ -190,6 +190,18 @@ org.jacoco jacoco-maven-plugin + + org.apache.maven.plugins + maven-surefire-plugin + + + src/test/resources/testng.xml + + + org.ops4j.pax.logging + + + diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/http/CookieFunctionImplTest.java b/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/http/CookieFunctionImplTest.java index 6b7bc473..bf8c4871 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/http/CookieFunctionImplTest.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/http/CookieFunctionImplTest.java @@ -68,7 +68,6 @@ public class CookieFunctionImplTest extends JsSequenceHandlerAbstractTest { @BeforeMethod protected void setUp() throws Exception { - super.setUp(); CarbonConstants.ENABLE_LEGACY_AUTHZ_RUNTIME = true; sequenceHandlerRunner.registerJsFunction("setCookie", (SetCookieFunction) new CookieFunctionImpl()::setCookie); sequenceHandlerRunner.registerJsFunction("getCookieValue", (GetCookieFunction) new CookieFunctionImpl() diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/http/HTTPGetFunctionImplTest.java b/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/http/HTTPGetFunctionImplTest.java index 32929d19..0a474329 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/http/HTTPGetFunctionImplTest.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/http/HTTPGetFunctionImplTest.java @@ -20,6 +20,7 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; +import org.testng.annotations.Parameters; import org.testng.annotations.Test; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig; @@ -78,9 +79,10 @@ public class HTTPGetFunctionImplTest extends JsSequenceHandlerAbstractTest { private int microServicePort; @BeforeClass - protected void initClass() throws Exception { + @Parameters({"scriptEngine"}) + protected void initClass(String scriptEngine) throws Exception { - super.setUp(); + super.setUp(scriptEngine); CarbonConstants.ENABLE_LEGACY_AUTHZ_RUNTIME = true; LongWaitStatusDAOImpl daoImpl = new LongWaitStatusDAOImpl(); CacheBackedLongWaitStatusDAO cacheBackedDao = new CacheBackedLongWaitStatusDAO(daoImpl); diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/http/HTTPPostFunctionImplTest.java b/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/http/HTTPPostFunctionImplTest.java index 6388b46e..e321de80 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/http/HTTPPostFunctionImplTest.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/http/HTTPPostFunctionImplTest.java @@ -20,6 +20,7 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; +import org.testng.annotations.Parameters; import org.testng.annotations.Test; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig; @@ -80,9 +81,10 @@ public class HTTPPostFunctionImplTest extends JsSequenceHandlerAbstractTest { private int microServicePort; @BeforeClass - protected void initClass() throws Exception { + @Parameters({"scriptEngine"}) + protected void initClass(String scriptEngine) throws Exception { - super.setUp(); + super.setUp(scriptEngine); CarbonConstants.ENABLE_LEGACY_AUTHZ_RUNTIME = true; LongWaitStatusDAOImpl daoImpl = new LongWaitStatusDAOImpl(); CacheBackedLongWaitStatusDAO cacheBackedDao = new CacheBackedLongWaitStatusDAO(daoImpl); diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/resources/testng.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/resources/testng.xml new file mode 100644 index 00000000..3a8a40d8 --- /dev/null +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/test/resources/testng.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.notification/pom.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.notification/pom.xml index 57e6c377..a4d3562c 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.notification/pom.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.notification/pom.xml @@ -144,6 +144,18 @@ org.jacoco jacoco-maven-plugin + + org.apache.maven.plugins + maven-surefire-plugin + + + src/test/resources/testng.xml + + + org.ops4j.pax.logging + + + diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.notification/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/notification/SendEmailFunctionImplTest.java b/components/org.wso2.carbon.identity.conditional.auth.functions.notification/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/notification/SendEmailFunctionImplTest.java index 52b5f5ea..11be437b 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.notification/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/notification/SendEmailFunctionImplTest.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.notification/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/notification/SendEmailFunctionImplTest.java @@ -57,8 +57,6 @@ public class SendEmailFunctionImplTest extends JsSequenceHandlerAbstractTest { @BeforeMethod protected void setUp() throws Exception { - super.setUp(); - CarbonConstants.ENABLE_LEGACY_AUTHZ_RUNTIME = true; sequenceHandlerRunner.registerJsFunction("sendEmail", new SendEmailFunctionImpl()); } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.notification/src/test/resources/testng.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.notification/src/test/resources/testng.xml new file mode 100644 index 00000000..718d8cb8 --- /dev/null +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.notification/src/test/resources/testng.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.test.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/test/utils/sequence/JsSequenceHandlerAbstractTest.java b/components/org.wso2.carbon.identity.conditional.auth.functions.test.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/test/utils/sequence/JsSequenceHandlerAbstractTest.java index 172dfed4..931bde48 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.test.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/test/utils/sequence/JsSequenceHandlerAbstractTest.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.test.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/test/utils/sequence/JsSequenceHandlerAbstractTest.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Parameters; import org.wso2.carbon.identity.application.authentication.framework.internal.FrameworkServiceDataHolder; import org.wso2.carbon.identity.core.util.IdentityConfigParser; @@ -80,7 +81,8 @@ protected void initialize() throws IOException { } @BeforeMethod - protected void setUp() throws Exception { + @Parameters({"scriptEngine"}) + protected void setUp(String scriptEngine) throws Exception { if (sequenceHandlerRunner == null) { sequenceHandlerRunner = new JsSequenceHandlerRunner(); @@ -89,7 +91,7 @@ protected void setUp() throws Exception { if (applicationAuthenticatorFileName != null) { url = this.getClass().getClassLoader().getResource(applicationAuthenticatorFileName); } - sequenceHandlerRunner.init(url); + sequenceHandlerRunner.init(url, scriptEngine); } FrameworkServiceDataHolder.getInstance().setAdaptiveAuthenticationAvailable(true); } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.test.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/test/utils/sequence/JsSequenceHandlerRunner.java b/components/org.wso2.carbon.identity.conditional.auth.functions.test.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/test/utils/sequence/JsSequenceHandlerRunner.java index ee22edb2..56b6c0a9 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.test.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/test/utils/sequence/JsSequenceHandlerRunner.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.test.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/test/utils/sequence/JsSequenceHandlerRunner.java @@ -28,14 +28,20 @@ import org.wso2.carbon.identity.application.authentication.framework.config.loader.UIBasedConfigurationLoader; import org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JSExecutionSupervisor; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsBaseGraphBuilderFactory; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsGraphBuilderFactory; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsWrapperFactory; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsWrapperFactoryProvider; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.graaljs.JsGraalGraphBuilderFactory; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.graaljs.JsGraalWrapperFactory; import org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext; import org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException; import org.wso2.carbon.identity.application.authentication.framework.handler.sequence.impl.AsyncSequenceExecutor; import org.wso2.carbon.identity.application.authentication.framework.handler.sequence.impl.GraphBasedSequenceHandler; import org.wso2.carbon.identity.application.authentication.framework.internal.FrameworkServiceDataHolder; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; +import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants; import org.wso2.carbon.identity.application.common.model.ClaimMapping; import org.wso2.carbon.identity.application.common.model.ServiceProvider; import org.wso2.carbon.identity.conditional.auth.functions.test.utils.api.MockAuthenticator; @@ -91,7 +97,7 @@ public class JsSequenceHandlerRunner { protected GraphBasedSequenceHandler graphBasedSequenceHandler = new GraphBasedSequenceHandler(); protected UIBasedConfigurationLoader configurationLoader; - protected JsGraphBuilderFactory graphBuilderFactory; + protected JsBaseGraphBuilderFactory graphBuilderFactory; protected JSExecutionSupervisor jsExecutionSupervisor; private JsFunctionRegistryImpl jsFunctionRegistry; @@ -102,12 +108,17 @@ public class JsSequenceHandlerRunner { private static final String DEFAULT_APPLICATION_AUTHENTICATION_XML_FILE_NAME = "application-authentication-test.xml"; - public void init(URL applicationAuthenticatorConfigFileLocation) throws InvocationTargetException { + public void init(URL applicationAuthenticatorConfigFileLocation, String scriptEngine) + throws InvocationTargetException, NoSuchFieldException, IllegalAccessException { this.applicationAuthenticatorConfigFileLocation = applicationAuthenticatorConfigFileLocation; configurationLoader = new UIBasedConfigurationLoader(); - graphBuilderFactory = new JsGraphBuilderFactory(); + if (scriptEngine.contentEquals(FrameworkConstants.JSAttributes.NASHORN)) { + graphBuilderFactory = new JsGraphBuilderFactory(); + } else if (scriptEngine.contentEquals(FrameworkConstants.JSAttributes.GRAALJS)) { + graphBuilderFactory = new JsGraalGraphBuilderFactory(); + } jsFunctionRegistry = new JsFunctionRegistryImpl(); FrameworkServiceDataHolder.getInstance().setJsFunctionRegistry(jsFunctionRegistry); @@ -117,6 +128,14 @@ public void init(URL applicationAuthenticatorConfigFileLocation) throws Invocati graphBuilderFactory.init(); FrameworkServiceDataHolder.getInstance().setJsGraphBuilderFactory(graphBuilderFactory); + Field wrapperFactory = JsWrapperFactoryProvider.class.getDeclaredField("jsWrapperBaseFactory"); + wrapperFactory.setAccessible(true); + if (graphBuilderFactory instanceof JsGraphBuilderFactory) { + wrapperFactory.set(JsWrapperFactoryProvider.getInstance(), new JsWrapperFactory()); + } else if (graphBuilderFactory instanceof JsGraalGraphBuilderFactory) { + wrapperFactory.set(JsWrapperFactoryProvider.getInstance(), new JsGraalWrapperFactory()); + } + AsyncSequenceExecutor asyncSequenceExecutor = new AsyncSequenceExecutor(); asyncSequenceExecutor.init(); FrameworkServiceDataHolder.getInstance().setAsyncSequenceExecutor(asyncSequenceExecutor); diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/pom.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.user/pom.xml index 88455d37..e17441b5 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/pom.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/pom.xml @@ -216,6 +216,18 @@ org.jacoco jacoco-maven-plugin + + org.apache.maven.plugins + maven-surefire-plugin + + + src/test/resources/testng.xml + + + org.ops4j.pax.logging + + + diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsGraalWrapperFactory.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsGraalWrapperFactory.java index 2d347914..91ead611 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsGraalWrapperFactory.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/model/JsGraalWrapperFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/user/HasAnyOfTheRolesFunctionImplTest.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/user/HasAnyOfTheRolesFunctionImplTest.java index ee02610e..2357febf 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/user/HasAnyOfTheRolesFunctionImplTest.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/user/HasAnyOfTheRolesFunctionImplTest.java @@ -55,8 +55,6 @@ public class HasAnyOfTheRolesFunctionImplTest extends JsSequenceHandlerAbstractT @BeforeMethod protected void setUp() throws Exception { - super.setUp(); - CarbonConstants.ENABLE_LEGACY_AUTHZ_RUNTIME = true; sequenceHandlerRunner.registerJsFunction("hasAnyOfTheRoles", new HasAnyOfTheRolesFunctionImpl()); UserRealm userRealm = realmService.getTenantUserRealm(-1234); diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/user/HasRoleFunctionImplTest.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/user/HasRoleFunctionImplTest.java index e2751916..53fd21ea 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/user/HasRoleFunctionImplTest.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/user/HasRoleFunctionImplTest.java @@ -57,8 +57,6 @@ public class HasRoleFunctionImplTest extends JsSequenceHandlerAbstractTest { @BeforeMethod protected void setUp() throws Exception { - super.setUp(); - CarbonConstants.ENABLE_LEGACY_AUTHZ_RUNTIME = true; sequenceHandlerRunner.registerJsFunction("hasRole", new HasRoleFunctionImpl()); UserRealm userRealm = realmService.getTenantUserRealm(-1234); diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/user/IsMemberOfAnyOfGroupsFunctionImplTest.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/user/IsMemberOfAnyOfGroupsFunctionImplTest.java index 7b8afd19..84ea0349 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/user/IsMemberOfAnyOfGroupsFunctionImplTest.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/user/IsMemberOfAnyOfGroupsFunctionImplTest.java @@ -55,7 +55,6 @@ public class IsMemberOfAnyOfGroupsFunctionImplTest extends JsSequenceHandlerAbst @BeforeMethod protected void setUp() throws Exception { - super.setUp(); CarbonConstants.ENABLE_LEGACY_AUTHZ_RUNTIME = true; sequenceHandlerRunner.registerJsFunction("isMemberOfAnyOfGroups", new IsMemberOfAnyOfGroupsFunctionImpl()); diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/resources/testng.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/resources/testng.xml new file mode 100644 index 00000000..dcd52140 --- /dev/null +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/test/resources/testng.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index f9f821a9..c1ebe45f 100644 --- a/pom.xml +++ b/pom.xml @@ -170,9 +170,9 @@ ${json.wso2.version} - net.minidev - json-smart - ${json-smart.version} + net.minidev + json-smart + ${json-smart.version} @@ -539,7 +539,7 @@ [1.9.0,2.0.0) 1.4.01 15.3 - 20.2.0 + 22.3.4 **/*Exception.java, **/*Constants*.java,