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 69ca753532..b238dc337b 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 @@ -22,6 +22,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; +import org.hamcrest.Matcher; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; @@ -67,7 +68,9 @@ public class IdPSuccessTest extends IdPTestBase { private static final String ACCESS_TOKEN_VALUE = "testBearerToken"; private static final String PASSWORD_VALUE = "testPassword"; private static final String IDP_NAME = "Google"; + private static final String TRUSTED_TOKEN_ISS_IDP_NAME = "Trusted Token Issuer IdP"; private String idPId; + private String trustedTokenIdPId; private String customIdPId; private String idPTemplateId; private UserDefinedAuthenticatorPayload userDefinedAuthenticatorPayload; @@ -916,4 +919,52 @@ public void testDeleteIdPTemplate() throws Exception { .assertThat() .statusCode(HttpStatus.SC_NO_CONTENT); } + + @Test + public void testAddTrustedTokenIssuerIdP() throws IOException { + + String body = readResource("add-trusted-token-issuer-idp.json"); + Response response = getResponseOfPost(IDP_API_BASE_PATH, body); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_CREATED) + .header(HttpHeaders.LOCATION, notNullValue()); + + String location = response.getHeader(HttpHeaders.LOCATION); + assertNotNull(location); + trustedTokenIdPId = location.substring(location.lastIndexOf("/") + 1); + assertNotNull(trustedTokenIdPId); + } + + @Test(dependsOnMethods = "testAddTrustedTokenIssuerIdP") + public void testGetTrustedTokenIssuerIdP() { + + Response response = getResponseOfGet(IDP_API_BASE_PATH + PATH_SEPARATOR + trustedTokenIdPId); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("id", equalTo(trustedTokenIdPId)) + .body("name", equalTo(TRUSTED_TOKEN_ISS_IDP_NAME)); + } + + @Test (dependsOnMethods = "testGetTrustedTokenIssuerIdP") + public void testDeleteTrustedTokenIssuerIdP() { + + Response response = getResponseOfDelete(IDP_API_BASE_PATH + PATH_SEPARATOR + trustedTokenIdPId); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_NO_CONTENT); + + Response responseOfGet = getResponseOfGet(IDP_API_BASE_PATH + PATH_SEPARATOR + trustedTokenIdPId); + responseOfGet.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_NOT_FOUND) + .body("message", equalTo("Resource not found.")) + .body("description", equalTo("Unable to find a resource matching the provided identity " + + "provider identifier " + trustedTokenIdPId + ".")); + } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/idp/v1/add-trusted-token-issuer-idp.json b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/idp/v1/add-trusted-token-issuer-idp.json new file mode 100644 index 0000000000..7dfdc70e33 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/idp/v1/add-trusted-token-issuer-idp.json @@ -0,0 +1,34 @@ +{ + "name": "Trusted Token Issuer IdP", + "description": "A trusted token issuer to exchange its token for a token issued by WSO2 Identity Server", + "alias": "sample", + "image": "assets/images/icons/trusted-token-issuer.svg", + "isPrimary": false, + "roles": { + "mappings": [], + "outboundProvisioningRoles": [] + }, + "certificate": { + "jwksUri": "https://localhost:9443/t/carbon.super/console/connections/templates", + "certificates": [ + "" + ] + }, + "claims": { + "userIdClaim": { + "uri": "" + }, + "provisioningClaims": [], + "roleClaim": { + "uri": "" + } + }, + "federatedAuthenticators": { + "defaultAuthenticatorId": "", + "authenticators": [] + }, + "homeRealmIdentifier": "", + "isFederationHub": false, + "idpIssuerName": "test-issuer", + "templateId": "trusted-token-issuer" +}