Skip to content

Commit

Permalink
Merge pull request wso2#20218 from ImalshaG/integration-test-fix
Browse files Browse the repository at this point in the history
Enable App-Native Authentication related test case
  • Loading branch information
janakamarasena authored Apr 19, 2024
2 parents f0c5bdd + d3404eb commit 28444d2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.restassured.http.ContentType;
import io.restassured.response.ExtractableResponse;
import io.restassured.response.Response;
import org.apache.commons.lang.ArrayUtils;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
Expand All @@ -43,6 +44,9 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig;
import org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider;
import org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient;
import org.wso2.identity.integration.common.clients.UserManagementClient;
import org.wso2.identity.integration.test.oauth2.OAuth2ServiceAbstractIntegrationTest;
import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.AdvancedApplicationConfiguration;
Expand Down Expand Up @@ -110,6 +114,7 @@ public class ApplicationNativeAuthenticationTestCase extends OAuth2ServiceAbstra
private CloseableHttpClient client;
private UserManagementClient userMgtServiceClient;
private String code;
private IdentityProviderMgtServiceClient superTenantIDPMgtClient;

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
Expand All @@ -130,6 +135,8 @@ public void testInit() throws Exception {
userMgtServiceClient.addUser(TEST_USER_NAME, TEST_PASSWORD, null, TEST_PROFILE);

setSystemproperties();
// Reset the idp cache object to remove effects from previous test cases.
resetResidentIDPCache();
}

@AfterClass(alwaysRun = true)
Expand Down Expand Up @@ -396,4 +403,22 @@ private void validateBasicAuthenticationResponseBody(ExtractableResponse<Respons
.jsonPath()
.getString(AUTH_DATA_SESSION_STATE), "Session state is null in the authData");
}

private void resetResidentIDPCache() throws Exception {

superTenantIDPMgtClient = new IdentityProviderMgtServiceClient(sessionCookie, backendURL);
IdentityProvider residentIdp = superTenantIDPMgtClient.getResidentIdP();

FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs =
residentIdp.getFederatedAuthenticatorConfigs();
for (FederatedAuthenticatorConfig authenticatorConfig : federatedAuthenticatorConfigs) {
if (!authenticatorConfig.getName().equalsIgnoreCase("samlsso")) {
federatedAuthenticatorConfigs = (FederatedAuthenticatorConfig[])
ArrayUtils.removeElement(federatedAuthenticatorConfigs,
authenticatorConfig);
}
}
residentIdp.setFederatedAuthenticatorConfigs(federatedAuthenticatorConfigs);
superTenantIDPMgtClient.updateResidentIdP(residentIdp);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@
<class name="org.wso2.identity.integration.test.identityServlet.ExtendSessionEndpointAuthCodeGrantTestCase"/>
<class name="org.wso2.identity.integration.test.oauth2.OAuth2TokenRevocationWithSessionTerminationTestCase"/>
<class name="org.wso2.identity.integration.test.oauth2.OAuth2TokenRevocationWithMultipleSessionTerminationTestCase"/>
<!-- Temporarily commenting out following test case cause due to intermittent error-->
<!-- <class name="org.wso2.identity.integration.test.applicationNativeAuthentication.ApplicationNativeAuthenticationTestCase"/>-->
<class name="org.wso2.identity.integration.test.applicationNativeAuthentication.ApplicationNativeAuthenticationTestCase"/>
</classes>
</test>

Expand Down

0 comments on commit 28444d2

Please sign in to comment.