Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Integration Tests for Trusted Token Issuer IdP #21977

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}