From 874a1201453ea8ab6aa2b31508644748bcc9ed66 Mon Sep 17 00:00:00 2001 From: Jayesh Kharode Date: Wed, 25 Sep 2024 16:19:49 +0530 Subject: [PATCH 1/3] MOSIP-36024 Signed-off-by: Jayesh Kharode --- uitest-resident/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uitest-resident/pom.xml b/uitest-resident/pom.xml index 5031d61e..ba6e4b80 100644 --- a/uitest-resident/pom.xml +++ b/uitest-resident/pom.xml @@ -1,10 +1,10 @@ 4.0.0 io.mosip.test - residentui - 1.2.1 - resident-ui-automation - resident-ui-automation + uitest-resident + 1.2.1-SNAPSHOT + uitest-resident + Parent project of uitest-resident https://github.com/mosip/resident-ui From a0fba0bb82c4cc17f7c3444dafac9add96d10df9 Mon Sep 17 00:00:00 2001 From: Jayesh Kharode Date: Wed, 25 Sep 2024 18:33:52 +0530 Subject: [PATCH 2/3] MOSIP-33383 Signed-off-by: Jayesh Kharode --- .github/workflows/push-trigger.yml | 16 +- uitest-resident/pom.xml | 558 ++++++------------ .../residentui/utility/EmailableReport.java | 79 ++- .../residentui/utility/TestRunner.java | 2 +- 4 files changed, 254 insertions(+), 401 deletions(-) diff --git a/.github/workflows/push-trigger.yml b/.github/workflows/push-trigger.yml index 8b0001f0..7e585a57 100644 --- a/.github/workflows/push-trigger.yml +++ b/.github/workflows/push-trigger.yml @@ -67,7 +67,7 @@ jobs: ORG_KEY: ${{ secrets.ORG_KEY }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} build-maven-uitest-resident: - uses: mosip/kattu/.github/workflows/maven-build.yml@master + uses: mosip/kattu/.github/workflows/maven-build.yml@master-java21 with: SERVICE_LOCATION: ./uitest-resident BUILD_ARTIFACT: uitest-resident @@ -87,12 +87,12 @@ jobs: SERVICE_LOCATION: uitest-resident BUILD_ARTIFACT: uitest-resident-local steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 + - uses: actions/checkout@v3 + - name: Set up JDK 21 + uses: actions/setup-java@v3 with: - ref: ${{ github.ref }} - java-version: 11 + distribution: 'temurin' + java-version: 21 server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file @@ -146,7 +146,7 @@ jobs: BUILD_ARTIFACT: 'uitest-resident-local' fail-fast: false name: ${{ matrix.SERVICE_NAME }} - uses: mosip/kattu/.github/workflows/docker-build.yml@master + uses: mosip/kattu/.github/workflows/docker-build.yml@master-java21 with: SERVICE_LOCATION: ${{ matrix.SERVICE_LOCATION }} SERVICE_NAME: ${{ matrix.SERVICE_NAME }} @@ -172,7 +172,7 @@ jobs: sonar_analysis_uitest-resident: needs: build-uitest-resident-local if: "${{ github.event_name != 'pull_request' }}" - uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master + uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master-java21 with: SERVICE_LOCATION: uitest-resident SONAR_URL: 'https://sonarcloud.io' diff --git a/uitest-resident/pom.xml b/uitest-resident/pom.xml index ba6e4b80..2581b360 100644 --- a/uitest-resident/pom.xml +++ b/uitest-resident/pom.xml @@ -29,148 +29,9 @@ - - UTF-8 - - - 11 - 11 - 3.7.0 - 3.0.2 - 3.1.0 - 2.9 - 0.8.1 - 3.2 - 3.0.1 - 2.3 - true - 3.7.0.1746 - - 2.0.2.RELEASE - 2.0.7.RELEASE - 5.0.5.RELEASE - 2.0.0.RELEASE - - 2.0.7 - 1.5.20 - 2.9.2 - - 3.6.2 - 3.7.0 - - - - 1.2 - 3.0.0 - 1.3 - 2.2 - 2.0.1.Final - 2.2.6 - - - 1.4.197 - 5.1.46 - 42.2.2 - 2.5.0 - 6.0.12.Final - - - 1.10.19 - 1.7.4 - 2.0.0-beta.5 - - - 1.2.3 - 1.7.19 - 2.16.0 - 1.7.25 - - - 2.9.5 - 20180130 - 2.2.10 - 20180130 - - - 3.6.1 - 3.7 - 2.6 - 1.11 - 4.3 + 31.1-jre + 7.10.1 1.9.2 - 2.2 - 4.5.6 - 19.0 - 1.18.8 - 0.1.54 - 1.4.0 - 7.1.0 - 2.0.0 - 5.5.13 - 2.3.23 - 1.7 - 2.0 - 1.5.2 - 2.1.1 - 1.60 - 63.1 - 1.0.0 - 3.3.3 - 2.8.1 - 4.1.0-incubating - 1.11.368 - 0.2.4 - 2.3.0 - 3.0.1 - 1.9.12 - 0.6.0 - 2.0.0.AM2 - - - - - - - - 0.8.2 - 2.2 - 3.2 - UTF-8 - 3.7.0 - 3.0.1 - - - 1.1.6 - 1.7.19 - 1.10.19 - - - 1.4.6 - - - 5.0.6.RELEASE - - - 5.4.2.Final - - - 2.1.1 - - - 10.13.1.1 - - - 3.4.0 - - - 1.3.5 - - - 0.3.12 - - - 0.3.0 - 1.1.2-incubating 1.2.0.1-B1 @@ -183,14 +44,189 @@ 6.11 1.13 residentui-1.2.1-SNAPSHOT-jar-with-dependencies - + + + 21 + 21 + 3.8.0 + 3.0.2 + 3.1.0 + 3.7.0.1746 + + + + io.mosip.kernel + kernel-bom + 1.2.1-java21-SNAPSHOT + pom + import + + + + + + + + org.seleniumhq.selenium + selenium-java + + + com.google.guava + guava + + + + + org.json + json + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-databind + + + com.amazonaws + aws-java-sdk-s3 + 1.12.470 + + + org.awaitility + awaitility + + + ch.qos.logback + logback-core + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + + + com.paulhammant + ngwebdriver + 1.1.5 + + + com.aventstack + extentreports + 5.0.9 + + + io.github.bonigarcia + webdrivermanager + 5.1.0 + + + com.google.guava + guava + + + + + commons-io + commons-io + + + org.jboss.resteasy + resteasy-jaxrs + 3.15.0.Final + + + junit + junit + test + + + org.testng + testng + ${testng.version} + + + io.rest-assured + rest-assured + + + org.apache.logging.log4j + log4j-api + + + org.slf4j + slf4j-log4j12 + + + javax.ws.rs + javax.ws.rs-api + 2.1.1 + + + org.keycloak + keycloak-admin-client + 17.0.1 + + + com.google.guava + guava + + + + + commons-beanutils + commons-beanutils + ${commons.beanutils.version} + + + com.googlecode.json-simple + json-simple + + + org.apache.commons + commons-collections4 + + + commons-lang + commons-lang + 2.6 + + + com.google.guava + guava + ${guava.version} + + + org.apache.httpcomponents.client5 + httpclient5 + 5.1.3 + + + org.apache.httpcomponents.core5 + httpcore5 + 5.1.3 + + + com.github.jknack + handlebars + 3.0.0 + + + com.github.mifmif + generex + 1.0.2 + + - - + @@ -219,58 +255,33 @@ 3.0.1 - get-the-git-infos + populate-git-commit-information revision - validate + + true + MM/dd/yyyy HH:mm:ss Z + 8 + true + ${project.build.outputDirectory}/git.properties + - true - ${project.build.outputDirectory}/git.properties - - ^git.build.(time|version)$ - ^git.commit.id.(abbrev|full)$ - - full ${project.basedir}/.git - + org.apache.maven.plugins maven-compiler-plugin - 3.5.1 + ${maven.compiler.version} - 11 - 11 + ${maven.compiler.source} + ${maven.compiler.target} -Dfile.encoding=UTF-8 - org.apache.maven.plugins maven-shade-plugin @@ -283,16 +294,11 @@ ${fileName} - - - - + + io.mosip.testrig.residentui.utility.TestRunner - *:* @@ -320,8 +326,7 @@ - - + @@ -330,7 +335,6 @@ - selenium-tests @@ -400,176 +404,4 @@ - - - - - - - org.seleniumhq.selenium - selenium-java - 4.14.1 - - - - - - org.json - json - 20210307 - - - - - com.fasterxml.jackson.core - jackson-core - 2.12.5 - - - - com.fasterxml.jackson.core - jackson-databind - 2.12.5 - - - com.amazonaws - aws-java-sdk-s3 - 1.12.470 - - - - - org.awaitility - awaitility - 4.0.3 - - - ch.qos.logback - logback-core - 1.2.6 - - - org.slf4j - slf4j-api - 1.7.30 - - - - - ch.qos.logback - logback-classic - 1.2.6 - - - com.paulhammant - ngwebdriver - 1.1.5 - - - - - com.aventstack - extentreports - 5.0.9 - - - - - - io.github.bonigarcia - webdrivermanager - 5.1.0 - - - - org.testng - testng - 7.1.0 - - - - - - commons-io - commons-io - 2.6 - - - - - - org.jboss.resteasy - resteasy-jaxrs - 3.15.0.Final - - - - - - - junit - junit - 3.8.1 - test - - - org.testng - testng - ${testng.version} - - - io.rest-assured - rest-assured - ${rest.assured.version} - - - org.apache.logging.log4j - log4j-api - 2.11.1 - - - org.slf4j - slf4j-log4j12 - 1.6.2 - - - javax.ws.rs - javax.ws.rs-api - 2.1.1 - - - org.json - json - ${json.version} - - - org.keycloak - keycloak-admin-client - 17.0.1 - - - commons-beanutils - commons-beanutils - ${commons.beanutils.version} - - - com.googlecode.json-simple - json-simple - 1.1.1 - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - commons-lang - commons-lang - 2.6 - - - diff --git a/uitest-resident/src/main/java/io/mosip/testrig/residentui/utility/EmailableReport.java b/uitest-resident/src/main/java/io/mosip/testrig/residentui/utility/EmailableReport.java index b09bf9a6..b47a572e 100644 --- a/uitest-resident/src/main/java/io/mosip/testrig/residentui/utility/EmailableReport.java +++ b/uitest-resident/src/main/java/io/mosip/testrig/residentui/utility/EmailableReport.java @@ -10,6 +10,8 @@ import java.io.PrintWriter; import java.lang.reflect.Field; import java.text.NumberFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; @@ -142,16 +144,12 @@ private String getCommitId() { Properties properties = new Properties(); try (InputStream is = EmailableReport.class.getClassLoader().getResourceAsStream("git.properties")) { properties.load(is); - Process process = Runtime.getRuntime().exec("git rev-parse --abbrev-ref HEAD"); - // Read the output of the command - BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); - String branch = reader.readLine(); return "Commit Id is: " + properties.getProperty("git.commit.id.abbrev") + " & Branch Name is:" - + branch; + + properties.getProperty("git.branch"); - } catch (IOException io) { - logger.error(io.getMessage()); + } catch (IOException e) { + logger.error(e.getMessage()); return ""; } @@ -181,24 +179,31 @@ protected void writeHead() { protected void writeStylesheet() { writer.print(""); + writer.print("table {margin-bottom:10px;border-collapse:collapse;empty-cells:show;width: 100%;}"); + writer.print("th,td {border:1px solid #009;padding:.25em .5em;width: 25%;}"); // Set a fixed width for uniform cell sizes + writer.print("th {vertical-align:bottom}"); + writer.print("td {vertical-align:top}"); + writer.print("table a {font-weight:bold}"); + writer.print(".stripe td {background-color: #E6EBF9}"); + writer.print(".num {text-align:center}"); + writer.print(".orange-bg {background-color: #FFA500}"); + writer.print(".grey-bg {background-color: #808080}"); + writer.print(".thich-orange-bg {background-color: #CC5500}"); + writer.print(".green-bg {background-color: #0A0}"); + writer.print(".attn {background-color: #D00}"); + writer.print(".passedodd td {background-color: #3F3}"); + writer.print(".passedeven td {background-color: #0A0}"); + writer.print(".skippedodd td {background-color: #FFA500}"); + writer.print(".skippedeven td,.stripe {background-color: #FFA500}"); + writer.print(".failedodd td {background-color: #F33}"); + writer.print(".failedeven td,.stripe {background-color: #D00}"); + writer.print(".ignoredodd td {background-color: #808080}"); + writer.print(".ignoredeven td {background-color: #808080}"); + writer.print(".known_issuesodd td {background-color: #CC5500}"); + writer.print(".known_issueseven td {background-color: #CC5500}"); + writer.print(".stacktrace {white-space:pre;font-family:monospace}"); + writer.print(".totop {font-size:85%;text-align:center;border-bottom:2px solid #000}"); + writer.print(""); } protected void writeBody() { @@ -216,7 +221,21 @@ protected void writeDocumentEnd() { protected void writeSuiteSummary() { NumberFormat integerFormat = NumberFormat.getIntegerInstance(); NumberFormat decimalFormat = NumberFormat.getNumberInstance(); - + String formattedDate =null; + LocalDate currentDate = LocalDate.now(); + String branch = null; + + try { + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + formattedDate = currentDate.format(formatter); + Process process = Runtime.getRuntime().exec("git rev-parse --abbrev-ref HEAD"); + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + branch = reader.readLine(); + } + catch (Exception e) { + // TODO: handle exception + } totalPassedTests = 0; totalSkippedTests = 0; totalFailedTests = 0; @@ -226,13 +245,15 @@ protected void writeSuiteSummary() { for (SuiteResult suiteResult : suiteResults) { writer.print(""); - writer.print(Utils.escapeHtml(suiteResult.getSuiteName() + "-" + getCommitId())); - writer.print(""); + writer.print(Utils.escapeHtml(suiteResult.getSuiteName() + " ---- " + "Report Date: " + formattedDate + + " ---- " + "Tested Environment: " + + ConfigManager.getiam_apienvuser().replaceAll(".*?\\.([^\\.]+)\\..*", "$1") + " ---- " + + getCommitId())); writer.print(""); writer.print("
");
 			writer.print(Utils.escapeHtml("Server Component Details " + AdminTestUtil.getServerComponentsDetails()));
 			writer.print("
"); - // writer.print(GlobalConstants.TRTR); + writer.print(""); writer.print(""); // writer.print("Test Suite"); diff --git a/uitest-resident/src/main/java/io/mosip/testrig/residentui/utility/TestRunner.java b/uitest-resident/src/main/java/io/mosip/testrig/residentui/utility/TestRunner.java index 925d6da9..3762af14 100644 --- a/uitest-resident/src/main/java/io/mosip/testrig/residentui/utility/TestRunner.java +++ b/uitest-resident/src/main/java/io/mosip/testrig/residentui/utility/TestRunner.java @@ -60,7 +60,7 @@ public static void startTestRunner() throws Exception { TestNG runner = new TestNG(); if(!ConfigManager.gettestcases().equals("")) { XmlSuite suite = new XmlSuite(); - suite.setName("MySuite"); + suite.setName("RESIDENT-UI-AUTOMATION-RUN"); suite.addListener("io.mosip.testrig.residentui.utility.EmailableReport"); XmlClass getInformation = new XmlClass("io.mosip.testrig.residentui.testcase.GetInformation"); From 7c550ac033f152e8564541ffb8e6c826676fc291 Mon Sep 17 00:00:00 2001 From: Jayesh Kharode Date: Wed, 25 Sep 2024 22:08:53 +0530 Subject: [PATCH 3/3] MOSIP-36023 Signed-off-by: Jayesh Kharode --- uitest-resident/pom.xml | 2 +- .../residentui/fw/util/AdminTestUtil.java | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/uitest-resident/pom.xml b/uitest-resident/pom.xml index 2581b360..59f4eb10 100644 --- a/uitest-resident/pom.xml +++ b/uitest-resident/pom.xml @@ -60,7 +60,7 @@ io.mosip.kernel kernel-bom - 1.2.1-java21-SNAPSHOT + 1.2.1-SNAPSHOT pom import diff --git a/uitest-resident/src/main/java/io/mosip/testrig/residentui/fw/util/AdminTestUtil.java b/uitest-resident/src/main/java/io/mosip/testrig/residentui/fw/util/AdminTestUtil.java index 2c4b5c63..8c80b92a 100644 --- a/uitest-resident/src/main/java/io/mosip/testrig/residentui/fw/util/AdminTestUtil.java +++ b/uitest-resident/src/main/java/io/mosip/testrig/residentui/fw/util/AdminTestUtil.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.math.BigDecimal; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; @@ -121,11 +122,18 @@ public static void genrateCredentialRequest(String rid,String role) { } public static String buildaddIdentityRequestBody(String schemaJson, String uin, String rid) { - org.json.JSONObject schemaresponseJson = new org.json.JSONObject(schemaJson); + JSONObject schemaresponseJson = new JSONObject(schemaJson); - org.json.JSONObject schemaData = (org.json.JSONObject) schemaresponseJson.get("response"); - Double schemaVersion = (Double) schemaData.get("idVersion"); - String schemaJsonData = schemaData.getString("schemaJson"); + JSONObject schemaData = (JSONObject) schemaresponseJson.get("response"); + Double schemaVersion = null; + Object idVersion = schemaData.get("idVersion"); + if (idVersion instanceof BigDecimal) { + schemaVersion = ((BigDecimal) idVersion).doubleValue(); + } else if (idVersion instanceof Double) { + schemaVersion = (Double) idVersion; + } else { + throw new ClassCastException("Unsupported type for idVersion: " + idVersion.getClass().getName()); + } String schemaJsonData = schemaData.getString("schemaJson"); String schemaFile = schemaJsonData.toString(); JSONObject schemaFileJson = new JSONObject(schemaFile); // jObj