Skip to content

Commit

Permalink
Add a test case for search functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Shenali-SJ committed Dec 3, 2024
1 parent 525880f commit e21d169
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ private void deleteCreatedIdP(String idPId) {
responseOfGet.then()
.log().ifValidationFails()
.assertThat()
.assertThat()
.statusCode(HttpStatus.SC_NOT_FOUND)
.body("message", equalTo("Resource not found."))
.body("description", equalTo("Unable to find a resource matching the provided identity " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -310,6 +314,22 @@ 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(getTenantedRelativePath(
"/api/server/v1/identity-providers/" + idPId,
context.getContextTenant().getDomain())));
}

@Test(dependsOnMethods = {"testGetIdPs"})
public void testGetIdPsWithRequiredAttribute() throws Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
"isFederationHub": false,
"idpIssuerName": "",
"templateId": "enterprise-oidc-idp"
}
}

0 comments on commit e21d169

Please sign in to comment.