From 80c762637cd9a7680a5062ffdfbfc8ceedafb279 Mon Sep 17 00:00:00 2001 From: Shenali Date: Tue, 3 Dec 2024 15:42:23 +0530 Subject: [PATCH] Add a test case for search functionality --- .../rest/api/server/idp/v1/IdPSuccessTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java index ba7dfcc0609..c7d79b34b42 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java @@ -31,9 +31,12 @@ import org.wso2.carbon.automation.engine.context.TestUserMode; import java.io.IOException; +import java.util.Collections; import java.util.HashMap; import java.util.Map; +import javax.xml.xpath.XPathExpressionException; + import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.core.IsNull.notNullValue; import static org.hamcrest.core.IsNull.nullValue; @@ -46,6 +49,7 @@ public class IdPSuccessTest extends IdPTestBase { private String idPId; private String idPTemplateId; + private static final String IDP_NAME = "Google"; @Factory(dataProvider = "restAPIUserConfigProvider") public IdPSuccessTest(TestUserMode userMode) throws Exception { @@ -310,6 +314,20 @@ public void testGetIdPs() throws Exception { context.getContextTenant().getDomain()))); } + @Test(dependsOnMethods = "testGetIdP") + public void testSearchAllIdPs() throws XPathExpressionException { + + Response response = getResponseOfGetWithQueryParams(IDP_API_BASE_PATH, Collections.singletonMap("filter", + "name sw " + IDP_NAME)); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("identityProviders.find { it.id == '" + idPId + "' }.name", equalTo(IDP_NAME)) + .body("identityProviders.find { it.id == '" + idPId + "' }.isEnabled", equalTo(true)) + .body("identityProviders.find { it.id == '" + idPId + "' }.self", equalTo(true)); + } + @Test(dependsOnMethods = {"testGetIdPs"}) public void testGetIdPsWithRequiredAttribute() throws Exception {