Skip to content

Commit 61ff3c3

Browse files
reset the resident idp cache
1 parent 00ec946 commit 61ff3c3

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/session/SessionMgtTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@
1818

1919
package org.wso2.identity.integration.test.rest.api.server.session;
2020

21-
import io.restassured.RestAssured;
2221
import io.restassured.response.Response;
23-
import org.apache.commons.lang.StringUtils;
2422
import org.apache.http.HttpStatus;
2523
import org.apache.http.client.CookieStore;
2624
import org.testng.annotations.AfterClass;
27-
import org.testng.annotations.AfterMethod;
2825
import org.testng.annotations.BeforeClass;
29-
import org.testng.annotations.BeforeMethod;
3026
import org.testng.annotations.DataProvider;
3127
import org.testng.annotations.Factory;
3228
import org.testng.annotations.Test;
@@ -78,6 +74,7 @@ public static Object[][] restAPIUserConfigProvider() {
7874
public void init() throws Exception {
7975

8076
super.testInit(API_VERSION, swaggerDefinition, tenant);
77+
resetResidentIDPCache();
8178
restClient = new OAuth2RestClient(serverURL, context.getContextTenant());
8279

8380
// Create test application.

modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/session/SessionMgtTestBase.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import io.restassured.RestAssured;
2222
import io.restassured.response.Response;
2323
import org.apache.commons.lang.StringUtils;
24+
import org.apache.commons.lang.ArrayUtils;
2425
import org.apache.http.HttpHeaders;
2526
import org.apache.http.HttpStatus;
2627
import org.apache.http.NameValuePair;
@@ -44,6 +45,9 @@
4445
import org.testng.annotations.AfterClass;
4546
import org.testng.annotations.AfterMethod;
4647
import org.testng.annotations.BeforeMethod;
48+
import org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig;
49+
import org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider;
50+
import org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient;
4751
import org.wso2.identity.integration.test.rest.api.server.common.RESTAPIServerTestBase;
4852

4953
import java.io.IOException;
@@ -408,4 +412,23 @@ private String removeTenantDomain(String username) {
408412
}
409413
return username;
410414
}
415+
416+
/**
417+
* Resets the resident IDP cache to ensure that any changes to the IDP (e.g. enabling
418+
* just the SAML SSO federated authenticator) are reflected in the test execution.
419+
*/
420+
protected void resetResidentIDPCache() throws Exception {
421+
422+
IdentityProviderMgtServiceClient idpMgtClient = new IdentityProviderMgtServiceClient(sessionCookie, backendURL);
423+
IdentityProvider residentIdp = idpMgtClient.getResidentIdP();
424+
425+
FederatedAuthenticatorConfig[] configs = residentIdp.getFederatedAuthenticatorConfigs();
426+
for (FederatedAuthenticatorConfig cfg : configs) {
427+
if (!cfg.getName().equalsIgnoreCase("samlsso")) {
428+
configs = (FederatedAuthenticatorConfig[]) ArrayUtils.removeElement(configs, cfg);
429+
}
430+
}
431+
residentIdp.setFederatedAuthenticatorConfigs(configs);
432+
idpMgtClient.updateResidentIdP(residentIdp);
433+
}
411434
}

0 commit comments

Comments
 (0)