From c65599abc3a69578699a8b75f3e66e49ae220536 Mon Sep 17 00:00:00 2001 From: sahandilshan Date: Mon, 4 Dec 2023 10:46:03 +0530 Subject: [PATCH] Modify extractClaims to work with regex Modify the `extractClaims` method to select the div tags that contains the `claim-list` class. With the earlier implementation, if someone add a newer class to the div tag, the tests will get failed. With this implementation, it will check a regex match to identify the claim list, instead of string comparison. --- .../identity/integration/test/util/Utils.java | 65 ++++++++++++------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/util/Utils.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/util/Utils.java index 73a7d4ea74..f8ead9248b 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/util/Utils.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/util/Utils.java @@ -63,6 +63,8 @@ import java.util.List; import java.util.Map; import java.util.StringJoiner; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; import static org.apache.commons.lang.StringUtils.isBlank; @@ -364,31 +366,48 @@ private static List extractClaims(HttpResponse response) throws IOExcept String resultPage = rd.lines().collect(Collectors.joining()); List attributeList = new ArrayList<>(); - String claimListDiv = "
"; String labelOpenTag = "
". + + // Use a matcher to find each label within the claimString. + Matcher labelMatcher = Pattern.compile(labelOpenTag + "(.*?)" + labelCloseTag).matcher(claimString); + while (labelMatcher.find()) { + // Add the extracted label (from the 'for' attribute) to the list. + attributeList.add(labelMatcher.group(1)); } } }