-
Notifications
You must be signed in to change notification settings - Fork 119
[Mosip-44280] - updated method postWithBodyAndCookieForAutoGeneratedIdForUrlEncoded #1877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Likhitha R L <[email protected]>
WalkthroughThe Changes
Sequence DiagramsequenceDiagram
participant Test as Test Method
participant AdminUtil as AdminTestUtil
participant RestClient as RestClient
participant HTTP as HTTP Endpoint
participant CertsUtil as CertsUtil
Test->>AdminUtil: postWithBodyAndCookieForAutoGeneratedIdForUrlEncoded(inputJson, testCaseName)
AdminUtil->>AdminUtil: Parse inputJson -> Map<String,Object>\nConvert entries -> Map<String,String> (serialize non-strings)
AdminUtil->>AdminUtil: Log sanitized formData and request URL
AdminUtil->>RestClient: postRequestWithFormDataBody(formData)
RestClient->>HTTP: Execute POST request
HTTP-->>RestClient: Response
RestClient-->>AdminUtil: Return response
AdminUtil->>AdminUtil: If testCaseName contains "UIN_Cookie" or "Vid_Cookie"\nderive keyName
alt Certificate caching required
AdminUtil->>CertsUtil: addCertificateToCache(keyName, responseBody)
CertsUtil-->>AdminUtil: Certificate cached
end
AdminUtil-->>Test: Return response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.40.5)apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.javaThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this 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/utils/AdminTestUtil.java`:
- Around line 1398-1409: The current heuristic using startsWith("{"/"[") causes
legitimate String values like "{hello}" to be double-encoded via
mapper.writeValueAsString; update the loop that builds formValue (iterating
jsonMap entries) to treat any instance of String as a raw value (formValue =
(String) value) and only call mapper.writeValueAsString for non-String types
(e.g., List, Map, arrays, POJOs), removing the startsWith checks so strings are
never serialized.
apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Likhitha R L <[email protected]>
There was a problem hiding this 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/utils/AdminTestUtil.java`:
- Around line 1414-1418: The code logs and reports full form data (see
AdminTestUtil using logger.info("Form data: " + formData.toString()) and
GlobalMethods.reportRequest(..., formData.toString(), ...)) which can leak
sensitive values; change this to either mask sensitive fields (e.g., password,
otp, token) before logging/reporting or gate the logging behind a debug flag so
only non-production debug builds emit the full payload; update the logging lines
and the argument passed to GlobalMethods.reportRequest and keep the actual call
to RestClient.postRequestWithFormDataBody(url, formData) unchanged.
🧹 Nitpick comments (1)
apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java (1)
1426-1433: Guard certificate caching on successful responses.
Avoid caching error payloads by checking status/body before storing.♻️ Suggested guard
- if (testCaseName.contains("UIN_Cookie") || testCaseName.contains("Vid_Cookie")) { + if ((testCaseName.contains("UIN_Cookie") || testCaseName.contains("Vid_Cookie")) + && response != null + && response.getStatusCode() >= 200 && response.getStatusCode() < 300 + && response.getBody() != null + && !response.getBody().asString().isBlank()) { String keyName = null; if (testCaseName.contains("UIN_Cookie")) keyName = ESIGNETUINCOOKIESRESPONSE; else keyName = ESIGNETVIDCOOKIESRESPONSE; - CertsUtil.addCertificateToCache(keyName, response.getBody().asString()); + String certPayload = response.getBody().asString(); + CertsUtil.addCertificateToCache(keyName, certPayload); }
apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java
Show resolved
Hide resolved
Signed-off-by: Likhitha R L <[email protected]>
Signed-off-by: Likhitha R L <[email protected]>
There was a problem hiding this 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/utils/AdminTestUtil.java`:
- Around line 1398-1412: In AdminTestUtil where jsonMap is converted to formData
(the loop that reads jsonMap entries and calls mapper.writeValueAsString), add a
null check for entry.getValue() before serializing: if value is null either skip
calling mapper.writeValueAsString and omit the key from formData or map it to an
empty string (e.g., formValue = "") instead of allowing
mapper.writeValueAsString(null) which yields the literal "null"; ensure the code
updates formData.put(entry.getKey(), formValue) accordingly and references the
same jsonMap/mapper/formData variables to locate the change.
Added conversion in method postWithBodyAndCookieForAutoGeneratedIdForUrlEncoded ,
simple strings → raw values, complex → JSON string
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.