@@ -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
@@ -674,7 +675,9 @@ class TestSuiteWriter {
674675 if (config.ssrf && solution.hasSsrfFaults()) {
675676 httpCallbackVerifier.getActionVerifierMappings().forEach { v ->
676677 addStatement(" private lateinit var ${v.getVerifierName()} : WireMockServer" , lines)
678+ addStatement(" private const val SSRF_METADATA_TAG: String = \" SSRF\" " , lines)
677679 }
680+ assertionUtilFunctionForSSRF(lines, config.outputFormat)
678681 }
679682
680683 if (config.problemType == EMConfig .ProblemType .WEBFRONTEND ){
@@ -1036,6 +1039,10 @@ class TestSuiteWriter {
10361039
10371040 initTestMethod(solution, lines, testSuiteFileName)
10381041 lines.addEmpty(2 )
1042+
1043+ if (config.ssrf && solution.hasSsrfFaults() && config.outputFormat.isJavaOrKotlin()) {
1044+ assertionUtilFunctionForSSRF(lines, config.outputFormat)
1045+ }
10391046 }
10401047
10411048
@@ -1144,4 +1151,37 @@ class TestSuiteWriter {
11441151 .toList()
11451152 }
11461153
1154+ private fun assertionUtilFunctionForSSRF (lines : Lines , format : OutputFormat ) {
1155+ lines.addEmpty(1 )
1156+
1157+ val methodComment = " Method to verify whether the HttpCallbackVerifier has received any requests."
1158+ when {
1159+ format.isKotlin() -> {
1160+ lines.addSingleCommentLine(methodComment)
1161+ lines.add(" fun verifierHasReceivedRequests(verifier: WireMockServer, actionName: String) : Boolean" )
1162+ }
1163+ format.isJava() -> {
1164+ lines.startCommentBlock()
1165+ lines.addBlockCommentLine(methodComment)
1166+ lines.endCommentBlock()
1167+ lines.add(" public static boolean verifierHasReceivedRequests(WireMockServer verifier, String actionName)" )
1168+ }
1169+ }
1170+ lines.block {
1171+ lines.add(" return verifier" )
1172+ lines.indented {
1173+ if (format.isKotlin()) {
1174+ lines.add(" .allServeEvents" )
1175+ lines.add(" .filter { it.wasMatched && it.stubMapping.metadata != null }" )
1176+ lines.add(" .any { it.stubMapping.metadata.getString(SSRF_METADATA_TAG) == actionName }" )
1177+ }
1178+ if (format.isJava()) {
1179+ lines.add(" .getAllServeEvents()" )
1180+ lines.add(" .stream().filter( r -> r.getWasMatched() && r.getStubMapping().getMetadata() != null)" )
1181+ lines.add(" .anyMatch( r -> r.getStubMapping().getMetadata().getString(SSRF_METADATA_TAG).equals(actionName));" )
1182+ }
1183+ }
1184+ }
1185+ }
1186+
11471187}
0 commit comments