|
21 | 21 | import io.restassured.RestAssured; |
22 | 22 | import io.restassured.response.Response; |
23 | 23 | import org.apache.commons.lang.StringUtils; |
| 24 | +import org.apache.commons.lang.ArrayUtils; |
24 | 25 | import org.apache.http.HttpHeaders; |
25 | 26 | import org.apache.http.HttpStatus; |
26 | 27 | import org.apache.http.NameValuePair; |
|
44 | 45 | import org.testng.annotations.AfterClass; |
45 | 46 | import org.testng.annotations.AfterMethod; |
46 | 47 | 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; |
47 | 51 | import org.wso2.identity.integration.test.rest.api.server.common.RESTAPIServerTestBase; |
48 | 52 |
|
49 | 53 | import java.io.IOException; |
@@ -408,4 +412,23 @@ private String removeTenantDomain(String username) { |
408 | 412 | } |
409 | 413 | return username; |
410 | 414 | } |
| 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 | + } |
411 | 434 | } |
0 commit comments