Skip to content

Commit

Permalink
Merge pull request #21977 from Shenali-SJ/trsuted-token-issuer-test
Browse files Browse the repository at this point in the history
Add Integration Tests for Trusted Token Issuer IdP
  • Loading branch information
Thisara-Welmilla authored Dec 10, 2024
2 parents f6365be + 73136b2 commit e9eddab
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 + "."));
}
}
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit e9eddab

Please sign in to comment.