Skip to content

Commit

Permalink
Merge pull request #17088 from wso2/revert-16925-thamindu-config
Browse files Browse the repository at this point in the history
Revert "Add integration tests for inbound auth config APIs"
  • Loading branch information
Thisara-Welmilla committed Oct 20, 2023
2 parents 6a50ed1 + c0a0d78 commit e445996
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,4 @@ public void testPatchCORSConfigsWithInvalidOperation() throws Exception {
Response response = getResponseOfPatch(CORS_CONFIGS_API_BASE_PATH, body);
validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "CNF-60003", "Unsupported patch operation");
}

@Test
public void testUpdateSAMLInboundAuthConfigsWithEmptyDestinationUrls() throws IOException {

String body = readResource("update-saml-inbound-auth-configs-invalid.json");
Response response = getResponseOfPatch(SAML_INBOUND_AUTH_CONFIG_API_PATH, body);
validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "CNF-60003",
"One of the given inputs is invalid. Should contain at least one destination URL.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import io.restassured.response.Response;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpStatus;
import org.junit.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
Expand All @@ -29,13 +28,9 @@
import org.testng.annotations.Factory;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;

import java.io.IOException;
import java.util.Arrays;

import javax.xml.xpath.XPathExpressionException;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
Expand Down Expand Up @@ -264,85 +259,4 @@ public void testPatchCORSConfigs() throws Exception {
.body("supportsCredentials", equalTo(false))
.body("maxAge", equalTo(3600));
}

@Test
public void testGetSAMLInboundAuthConfigs() throws XPathExpressionException {

Response response = getResponseOfGet(SAML_INBOUND_AUTH_CONFIG_API_PATH);
response.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK)
.body("destinationURLs", notNullValue())
.body("metadataValidityPeriod", equalTo(60))
.body("enableMetadataSigning", equalTo(false))
.body("metadataEndpoint",
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(context.getContextTenant().getDomain())
? equalTo(SAML_METADATA_ENDPOINT_SUPER_TENANT)
: equalTo(SAML_METADATA_ENDPOINT_TENANT));

String[] destinationUrls = response.jsonPath().getString("destinationURLs")
.replace("[", "").replace("]", "").split(",");
if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(context.getContextTenant().getDomain())) {
Assert.assertArrayEquals(new String[]{SAML_SSO_URL_SUPER_TENANT}, destinationUrls);
} else {
Assert.assertArrayEquals(new String[]{SAML_SSO_URL_TENANT}, destinationUrls);
}
}

@Test(dependsOnMethods = {"testGetSAMLInboundAuthConfigs"})
public void testUpdateSAMLInboundAuthConfigs() throws IOException {

String body = readResource("update-saml-inbound-auth-configs.json");
Response response = getResponseOfPatch(SAML_INBOUND_AUTH_CONFIG_API_PATH, body);
response.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK);

response = getResponseOfGet(SAML_INBOUND_AUTH_CONFIG_API_PATH);

response.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK)
.body("destinationURLs", notNullValue())
.body("metadataValidityPeriod", equalTo(120))
.body("enableMetadataSigning", equalTo(true));

String[] destinationUrls = response.jsonPath().getString("destinationURLs")
.replace("[", "").replace("]", "").replace(" ", "").split(",");
Assert.assertEquals(2, destinationUrls.length);
Assert.assertTrue(Arrays.asList(destinationUrls).contains("https://localhost:9853/test/updated"));
}

@Test
public void testGetPassiveSTSInboundAuthConfigs() throws XPathExpressionException {

Response response = getResponseOfGet(PASSIVE_STS_INBOUND_AUTH_CONFIG_API_PATH);
response.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK)
.body("enableRequestSigning", equalTo(false))
.body("passiveSTSUrl", equalTo(PASSIVE_STS_URL));
}

@Test(dependsOnMethods = {"testGetPassiveSTSInboundAuthConfigs"})
public void testUpdatePassiveSTSInboundAuthConfigs() throws IOException {

String body = readResource("update-passive-sts-inbound-auth-configs.json");
Response response = getResponseOfPatch(PASSIVE_STS_INBOUND_AUTH_CONFIG_API_PATH, body);
response.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK);

response = getResponseOfGet(PASSIVE_STS_INBOUND_AUTH_CONFIG_API_PATH);
response.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK)
.body("enableRequestSigning", equalTo(true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ public class ConfigTestBase extends RESTAPIServerTestBase {
public static final String CONFIGS_INBOUND_SCIM_API_BASE_PATH = "/configs/provisioning/inbound/scim";
public static final String CORS_CONFIGS_API_BASE_PATH = "/configs/cors";
public static final String HOME_REALM_IDENTIFIERS_API_BASE_PATH = "/configs/home-realm-identifiers";
public static final String SAML_INBOUND_AUTH_CONFIG_API_PATH = "/configs/authentication/inbound/saml2";
public static final String PASSIVE_STS_INBOUND_AUTH_CONFIG_API_PATH = "/configs/authentication/inbound/passivests";
public static final String SAML_METADATA_ENDPOINT_SUPER_TENANT = "https://localhost:9853/identity/metadata/saml2";
public static final String SAML_METADATA_ENDPOINT_TENANT =
"https://localhost:9853/t/wso2.com/identity/metadata/saml2";
public static final String SAML_SSO_URL_SUPER_TENANT = "https://localhost:9853/samlsso";
public static final String SAML_SSO_URL_TENANT = "https://localhost:9853/samlsso?tenantDomain=wso2.com";
public static final String PASSIVE_STS_URL = "https://localhost:9853/passivests";

public static final String PATH_SEPARATOR = "/";
public static final String SAMPLE_AUTHENTICATOR_ID = "QmFzaWNBdXRoZW50aWNhdG9y";
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit e445996

Please sign in to comment.