@@ -643,6 +643,7 @@ class TestSuiteWriter {
643643 if (config.ssrf && solution.hasSsrfFaults()) {
644644 httpCallbackVerifier.getActionVerifierMappings().forEach { v ->
645645 addStatement(" private static WireMockServer ${v.getVerifierName()} " , lines)
646+ addStatement(" private static final String SSRF_METADATA_TAG = \" SSRF\" " , lines)
646647 }
647648 }
648649
@@ -676,6 +677,7 @@ class TestSuiteWriter {
676677 addStatement(" private lateinit var ${v.getVerifierName()} : WireMockServer" , lines)
677678 addStatement(" private const val SSRF_METADATA_TAG: String = \" SSRF\" " , lines)
678679 }
680+ assertionUtilFunctionForSSRF(lines, config.outputFormat)
679681 }
680682
681683 if (config.problemType == EMConfig .ProblemType .WEBFRONTEND ){
@@ -1038,7 +1040,7 @@ class TestSuiteWriter {
10381040 initTestMethod(solution, lines, testSuiteFileName)
10391041 lines.addEmpty(2 )
10401042
1041- if (config.ssrf && solution.hasSsrfFaults()) {
1043+ if (config.ssrf && solution.hasSsrfFaults() && format.isJava() ) {
10421044 assertionUtilFunctionForSSRF(lines, config.outputFormat)
10431045 }
10441046 }
@@ -1150,15 +1152,18 @@ class TestSuiteWriter {
11501152 }
11511153
11521154 private fun assertionUtilFunctionForSSRF (lines : Lines , format : OutputFormat ) {
1153- lines.startCommentBlock()
1154- lines.addBlockCommentLine(" A method for verifying requests sent to HttpCallbackVerifier." )
1155- lines.endCommentBlock()
1155+ lines.addEmpty(1 )
1156+
11561157 when {
11571158 format.isKotlin() -> {
1159+ lines.addSingleCommentLine(" To verify whether the HttpCallbackVerifier has received any requests." )
11581160 lines.add(" fun verifierHasReceivedRequests(verifier: WireMockServer, actionName: String) : Boolean" )
11591161 }
11601162 format.isJava() -> {
1161- lines.add(" public boolean verifierHasReceivedRequests(WireMockServer verifier, String actionName)" )
1163+ lines.startCommentBlock()
1164+ lines.addBlockCommentLine(" Method to verify whether the HttpCallbackVerifier has received any requests." )
1165+ lines.endCommentBlock()
1166+ lines.add(" public static boolean verifierHasReceivedRequests(WireMockServer verifier, String actionName)" )
11621167 }
11631168 }
11641169 lines.block {
@@ -1169,6 +1174,11 @@ class TestSuiteWriter {
11691174 lines.add(" .filter { it.wasMatched && it.stubMapping.metadata != null }" )
11701175 lines.add(" .any { it.stubMapping.metadata.getString(SSRF_METADATA_TAG) == actionName }" )
11711176 }
1177+ if (format.isJava()) {
1178+ lines.add(" .getAllServeEvents()" )
1179+ lines.add(" .stream().filter( r -> r.getWasMatched() && r.getStubMapping().getMetadata() != null)" )
1180+ lines.add(" .anyMatch( r -> r.getStubMapping().getMetadata().getString(SSRF_METADATA_TAG).equals(actionName));" )
1181+ }
11721182 }
11731183 }
11741184 }
0 commit comments