Skip to content

Commit

Permalink
Modify unit tests to test for both nashorn and graaljs script engines.
Browse files Browse the repository at this point in the history
  • Loading branch information
shanggeeth committed Feb 6, 2024
1 parent 45bcf7c commit 88bd785
Show file tree
Hide file tree
Showing 26 changed files with 328 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.ops4j.pax.logging</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
~ Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com) All Rights Reserved.
~
~ WSO2 LLC. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Identity-connector-analytics-functions-validation-test-suite">
<test name="call-analytics-nashorn" parallel="false">
<parameter name="scriptEngine" value="nashorn"/>
<classes>
<class name="org.wso2.carbon.identity.conditional.auth.functions.analytics.CallAnalyticsFunctionImplTest"/>
</classes>
</test>
<test name="call-analytics-graaljs" parallel="false">
<parameter name="scriptEngine" value="graaljs"/>
<classes>
<class name="org.wso2.carbon.identity.conditional.auth.functions.analytics.CallAnalyticsFunctionImplTest"/>
</classes>
</test>
</suite>
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.ops4j.pax.logging</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
~ Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com) All Rights Reserved.
~
~ WSO2 LLC. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Identity-connector-choreo-functions-validation-test-suite">
<test name="call-choreo-nashorn" parallel="false">
<parameter name="scriptEngine" value="nashorn"/>
<classes>
<class name="org.wso2.carbon.identity.conditional.auth.functions.choreo.CallChoreoFunctionImplTest"/>
</classes>
</test>
<test name="call-choreo-graaljs" parallel="false">
<parameter name="scriptEngine" value="graaljs"/>
<classes>
<class name="org.wso2.carbon.identity.conditional.auth.functions.choreo.CallChoreoFunctionImplTest"/>
</classes>
</test>
</suite>
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.ops4j.pax.logging</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
~ Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com) All Rights Reserved.
~
~ WSO2 LLC. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Identity-connector-elk-analytics-functions-validation-test-suite">
<test name="call-elk-analytics-nashorn" parallel="false">
<parameter name="scriptEngine" value="nashorn"/>
<classes>
<class name="org.wso2.carbon.identity.conditional.auth.functions.elk.CallElasticFunctionImplTest"/>
</classes>
</test>
<test name="call-elk-analytics-graaljs" parallel="false">
<parameter name="scriptEngine" value="graaljs"/>
<classes>
<class name="org.wso2.carbon.identity.conditional.auth.functions.elk.CallElasticFunctionImplTest"/>
</classes>
</test>
</suite>
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,18 @@
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.ops4j.pax.logging</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!--
~ Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com) All Rights Reserved.
~
~ WSO2 LLC. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Identity-connector-http-functions-validation-test-suite">
<test name="http-functions-nashorn" parallel="false">
<parameter name="scriptEngine" value="nashorn"/>
<classes>
<class name="org.wso2.carbon.identity.conditional.auth.functions.http.CookieFunctionImplTest"/>
<class name="org.wso2.carbon.identity.conditional.auth.functions.http.HTTPGetFunctionImplTest"/>
<class name="org.wso2.carbon.identity.conditional.auth.functions.http.HTTPPostFunctionImplTest"/>
</classes>
</test>
<test name="http-functions-graaljs" parallel="false">
<parameter name="scriptEngine" value="graaljs"/>
<classes>
<class name="org.wso2.carbon.identity.conditional.auth.functions.http.CookieFunctionImplTest"/>
<class name="org.wso2.carbon.identity.conditional.auth.functions.http.HTTPGetFunctionImplTest"/>
<class name="org.wso2.carbon.identity.conditional.auth.functions.http.HTTPPostFunctionImplTest"/>
</classes>
</test>
</suite>
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.ops4j.pax.logging</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
~ Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com) All Rights Reserved.
~
~ WSO2 LLC. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Identity-connector-notifications-functions-validation-test-suite">
<test name="call-analytics-nashorn" parallel="false">
<parameter name="scriptEngine" value="nashorn"/>
<classes>
<class name="org.wso2.carbon.identity.conditional.auth.functions.notification.SendEmailFunctionImplTest"/>
</classes>
</test>
<test name="call-analytics-graaljs" parallel="false">
<parameter name="scriptEngine" value="graaljs"/>
<classes>
<class name="org.wso2.carbon.identity.conditional.auth.functions.notification.SendEmailFunctionImplTest"/>
</classes>
</test>
</suite>
Loading

0 comments on commit 88bd785

Please sign in to comment.