Skip to content

MOSIP-44099 - Added property dynamically to call testcasedependency#1887

Merged
mohanachandran-s merged 3 commits intomosip:developfrom
prathmeshj12:develop
Feb 10, 2026
Merged

MOSIP-44099 - Added property dynamically to call testcasedependency#1887
mohanachandran-s merged 3 commits intomosip:developfrom
prathmeshj12:develop

Conversation

@prathmeshj12
Copy link
Contributor

@prathmeshj12 prathmeshj12 commented Feb 7, 2026

Added property dynamically to call testcasedependency

Summary by CodeRabbit

  • Refactor
    • Centralized and hardened test-case inter-dependency path handling: replaced the previous static-path approach with a controlled accessor system that enables plugin-specific configuration file resolution, improves path robustness, and consolidates access logic for safer, more flexible configuration lookups.

Signed-off-by: Prathmesh Jadhav <prathmesh.j@cyberpwn.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 7, 2026

Walkthrough

Replaced a public static string field in BaseTestCase with a private static final Path BASE_CONFIG_PATH and added two public static accessors: getTestCaseInterDependencyPath() and getTestCaseInterDependencyPath(String pluginName) to return default or plugin-specific JSON paths.

Changes

Cohort / File(s) Summary
Path Encapsulation Refactor
apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/BaseTestCase.java
Removed public static String testCaseInterDependencyPath; added private static final Path BASE_CONFIG_PATH, imported java.nio.file.Path, and added public static String getTestCaseInterDependencyPath() plus public static String getTestCaseInterDependencyPath(String pluginName) which return BASE_CONFIG_PATH.resolve("testCaseInterDependency.json") or BASE_CONFIG_PATH.resolve("testCaseInterDependency_<plugin>.json") when pluginName provided.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I hopped and hid a Base_CONFIG_PATH bright,
Two little getters guide files just right.
Default or plugin, I point the way,
Neat paths now dance throughout the day. 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: converting a static field to dynamic, plugin-specific property accessor methods for test case dependency paths.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/BaseTestCase.java`:
- Around line 199-204: The BASE_CONFIG_PATH constant assumes an IDE project
layout and will fail from a JAR; update getTestCaseInterDependencyPath() to
resolve the config path using the same JAR-vs-IDE logic as
getGlobalResourcePath() (or replace BASE_CONFIG_PATH with a computed path via
getGlobalResourcePath()), so getTestCaseInterDependencyPath() returns
getGlobalResourcePath().resolve("config").resolve("testCaseInterDependency.json").toString()
(and remove or refactor BASE_CONFIG_PATH) to keep behavior consistent with
init() and other methods that use getGlobalResourcePath().
🧹 Nitpick comments (1)
apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/BaseTestCase.java (1)

206-212: pluginName is not sanitized — path traversal risk.

If pluginName contains characters like ../, the resolved path could escape the intended config directory. Even in a test framework, this is worth guarding against, especially if the value originates from external configuration or user input.

Suggested guard
 	public static String getTestCaseInterDependencyPath(String pluginName) {
 		if (pluginName == null || pluginName.isBlank()) {
 			return getTestCaseInterDependencyPath();
 		}
+		if (pluginName.contains("..") || pluginName.contains("/") || pluginName.contains("\\")) {
+			throw new IllegalArgumentException("Invalid pluginName: " + pluginName);
+		}
 		return BASE_CONFIG_PATH.resolve("testCaseInterDependency_" + pluginName + ".json").toString();
 	}

Signed-off-by: Prathmesh Jadhav <prathmesh.j@cyberpwn.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/BaseTestCase.java`:
- Around line 202-208: The getTestCaseInterDependencyPath method concatenates
pluginName into a file name allowing path traversal; validate/sanitize
pluginName (in getTestCaseInterDependencyPath) by rejecting null/blank as before
and additionally checking for forbidden sequences such as "/" "\" or ".." (or
any path-separator characters) and throw an IllegalArgumentException for invalid
names, or alternatively sanitize by stripping those characters, then build the
filename ("testCaseInterDependency_" + sanitizedName + ".json") and resolve it
against BASE_CONFIG_PATH; for extra safety normalize the resolved Path and
assert it startsWith(BASE_CONFIG_PATH) before returning the string.

Signed-off-by: Prathmesh Jadhav <prathmesh.j@cyberpwn.com>
@mohanachandran-s mohanachandran-s merged commit 6eb4b89 into mosip:develop Feb 10, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants