Skip to content

Commit

Permalink
Merge pull request #16793 from Thisara-Welmilla/remove-tenant-param-i…
Browse files Browse the repository at this point in the history
…n-url

Modify to tenant qualified urls.
  • Loading branch information
Thisara-Welmilla authored Sep 27, 2023
2 parents b5b579b + 726bc6f commit 66624f2
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ private HttpResponse sendSAMLMessage(String url, String samlMsgKey, String samlM
HttpPost post = new HttpPost(url);
post.setHeader(USER_AGENT, OAuth2Constant.USER_AGENT);
urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue));
urlParameters.add(new BasicNameValuePair("tenantDomain", "carbon.super"));
post.setEntity(new UrlEncodedFormEntity(urlParameters));
return client.execute(post);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public class EmailOTPTestCase extends ISIntegrationTest {
CommonConstants.IS_DEFAULT_HTTPS_PORT + "/authenticationendpoint/email_otp.do";
private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)";
private static final String profileName = "default";
private static final String TENANT_DOMAIN_PARAM = "tenantDomain";

private Lookup<CookieSpecProvider> cookieSpecRegistry;
private RequestConfig requestConfig;
Expand Down Expand Up @@ -225,10 +224,9 @@ private void deleteUser() {
private HttpResponse sendSAMLMessage(String url, String samlMsgValue) throws IOException {

List<NameValuePair> urlParameters = new ArrayList<>();
HttpPost post = new HttpPost(url);
HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain()));
post.setHeader("User-Agent", USER_AGENT);
urlParameters.add(new BasicNameValuePair(CommonConstants.SAML_REQUEST_PARAM, samlMsgValue));
urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, config.getTenantDomain()));
post.setEntity(new UrlEncodedFormEntity(urlParameters));
return httpClient.execute(post);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public abstract class AbstractAnalyticsLoginTestCase extends ISIntegrationTest {
private static final String INBOUND_AUTH_TYPE = "samlsso";
private static final String ATTRIBUTE_CS_INDEX_VALUE = "1239245949";
private static final String ATTRIBUTE_CS_INDEX_NAME = "attrConsumServiceIndex";
private static final String TENANT_DOMAIN_PARAM = "tenantDomain";

private static final String SAML_SSO_URL = "https://localhost:9853/samlsso";
private static final String ACS_URL = "http://localhost:8490/%s/home.jsp";
Expand Down Expand Up @@ -390,12 +389,9 @@ private HttpResponse sendSAMLMessage(String url, String samlMsgKey, String samlM

HttpClient httpClient = sharedHttpClient;
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
HttpPost post = new HttpPost(url);
HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain()));
post.setHeader("User-Agent", USER_AGENT);
urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue));
if (config.getUserMode() == TestUserMode.TENANT_ADMIN || config.getUserMode() == TestUserMode.TENANT_USER) {
urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, config.getUser().getTenantDomain()));
}
post.setEntity(new UrlEncodedFormEntity(urlParameters));
return httpClient.execute(post);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public class SelfSignUpConsentTest extends ISIntegrationTest {
private static final String COUNTRY_WSO2_CLAIM = "http://wso2.org/claims/country";
private static final String CALLBACK_QUERY_PARAM = "callback";
private static final String USERNAME_QUERY_PARAM = "username";
private static final String TENANT_DOMAIN_QUERY_PARAM = "tenantDomain";
private static final String ADMIN = "admin";
private static final String EBONY = "ebony";
private static final String PASSWORD = "UsEr@123";
Expand Down Expand Up @@ -296,8 +295,7 @@ private String doCallSignUpDo(String username) throws IOException {
username = MultitenantUtils.getTenantAwareUsername(username);
}
String selfRegisterEndpoint =
signupDoEndpoint + "?" + USERNAME_QUERY_PARAM + "=" + username + "&" + TENANT_DOMAIN_QUERY_PARAM + "="
+ tenantDomain;
signupDoEndpoint + "?" + USERNAME_QUERY_PARAM + "=" + username;
HttpResponse httpResponse = sendGetRequest(client, selfRegisterEndpoint);
return DataExtractUtil.getContentData(httpResponse);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ public static Object[][] federatedAuthConfigURLProvider() {
"Expected Passive STS URL is not found in the tenant mode"},
{"wso2.com", "OpenIdUrl", "https://localhost:9853/openidserver",
"Expected OpenID Server URL is not found in the tenant mode"},
{"wso2.com", "ECPUrl", "https://localhost:9853/samlecp?tenantDomain=wso2.com",
{"wso2.com", "ECPUrl", "https://localhost:9853/t/wso2.com/samlecp",
"Expected ECP URL is not found in the tenant mode"},
{"wso2.com", "LogoutReqUrl", "https://localhost:9853/samlsso?tenantDomain=wso2.com",
{"wso2.com", "LogoutReqUrl", "https://localhost:9853/t/wso2.com/samlsso",
"Expected Logout URL is not found in the tenant mode"},
{"wso2.com", "ArtifactResolveUrl", "https://localhost:9853/samlartresolve",
"Expected Artifact Resolution URL is not found in the tenant mode"},
{"wso2.com", "SSOUrl", "https://localhost:9853/samlsso?tenantDomain=wso2.com",
{"wso2.com", "SSOUrl", "https://localhost:9853/t/wso2.com/samlsso",
"Expected SSO URL is not found in the tenant mode"},
{"wso2.com", "IDENTITY_PROVIDER_URL", "https://localhost:9853/services/t/wso2.com/wso2carbon-sts",
"Expected Security Token Service URL is not found in the tenant mode"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public class OAuth2ServiceSAML2BearerGrantTestCase extends OAuth2ServiceAbstract
private static final String COMMON_AUTH_URL = "https://localhost:9853/commonauth";
private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)";
private static final String ACS_URL = "http://localhost:8490/%s/home.jsp";
private static final String TENANT_DOMAIN_PARAM = "tenantDomain";
private static final String SAML_SSO_URL = "https://localhost:9853/samlsso";
private static final String ISSUER = "travelocity.com";

Expand Down Expand Up @@ -359,7 +358,6 @@ private HttpResponse sendSAMLRequest(String samlMsgValue) throws IOException {
post.setHeader("User-Agent", USER_AGENT);

urlParameters.add(new BasicNameValuePair(CommonConstants.SAML_REQUEST_PARAM, samlMsgValue));
urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, "carbon.super"));

post.setEntity(new UrlEncodedFormEntity(urlParameters));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ public class OIDCFederatedIdpInitLogoutTest extends AbstractIdentityFederationTe
private static final String HTTPS_LOCALHOST_SERVICES = "https://localhost:%s/";
private static final String SAML_IDP_SLO_URL = SECONDARY_IS_SAML_SSO_URL + "?slo=true";

private static final String TENANT_DOMAIN_PARAM = "tenantDomain";

private SCIM2RestClient scim2RestClient;
private String secondaryISClientID;
private String secondaryISClientSecret;
Expand Down Expand Up @@ -349,10 +347,9 @@ public HttpResponse sendSAMLMessage(String url, String samlMsgKey, String samlMs
throws IOException {

List<NameValuePair> urlParameters = new ArrayList<>();
HttpPost post = new HttpPost(url);
HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain()));
post.setHeader("User-Agent", USER_AGENT);
urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue));
urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, "carbon.super"));
post.setEntity(new UrlEncodedFormEntity(urlParameters));

return client.execute(post);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@

public class ChallengeQuestionPostAuthnHandlerTestCase extends ISIntegrationTest {

private static final String TENANT_DOMAIN_PARAM = "tenantDomain";
private static final Log log = LogFactory.getLog(ChallengeQuestionPostAuthnHandlerTestCase.class);
// SAML Application attributes
private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)";
Expand Down Expand Up @@ -395,12 +394,9 @@ public void testLoginWithChallengeQuestions() {

private HttpResponse sendSAMLMessage(String url, String samlMsgKey, String samlMsgValue, CloseableHttpClient httpClient) throws IOException {
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
HttpPost post = new HttpPost(url);
HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain()));
post.setHeader("User-Agent", USER_AGENT);
urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue));
if (config.getUserMode() == TestUserMode.TENANT_ADMIN || config.getUserMode() == TestUserMode.TENANT_USER) {
urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, config.getUser().getTenantDomain()));
}
post.setEntity(new UrlEncodedFormEntity(urlParameters));
return httpClient.execute(post);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public abstract class AbstractSAMLSSOTestCase extends ISIntegrationTest {
private static final String INBOUND_AUTH_TYPE = "samlsso";
private static final String ATTRIBUTE_CS_INDEX_VALUE = "1239245949";
private static final String ATTRIBUTE_CS_INDEX_NAME = "attrConsumServiceIndex";
public static final String TENANT_DOMAIN_PARAM = "tenantDomain";
protected static final String SAML = "saml";
protected static final String SAML_SSO_URL = "https://localhost:9853/samlsso";
protected static final String SAML_IDP_SLO_URL = SAML_SSO_URL + "?slo=true";
Expand Down Expand Up @@ -644,12 +643,9 @@ public HttpResponse sendSAMLMessage(String url, String samlMsgKey, String samlMs
throws IOException {

List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
HttpPost post = new HttpPost(url);
HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain()));
post.setHeader("User-Agent", USER_AGENT);
urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue));
if (config.getUserMode() == TestUserMode.TENANT_ADMIN || config.getUserMode() == TestUserMode.TENANT_USER) {
urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, config.getUser().getTenantDomain()));
}
post.setEntity(new UrlEncodedFormEntity(urlParameters));

return httpClient.execute(post);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public class RegistryMountTestCase extends ISIntegrationTest {
private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)";
private static final String APPLICATION_NAME = "SAML-SSO-TestApplication";
private static final String ATTRIBUTE_CS_INDEX_VALUE = "1239245949";
private static final String TENANT_DOMAIN_PARAM = "tenantDomain";

private static final String ACS_URL = "http://localhost:8490/%s/home.jsp";
private static final String COMMON_AUTH_URL = "https://localhost:9853/commonauth";
Expand Down Expand Up @@ -214,10 +213,9 @@ private HttpResponse sendGetRequest(String url) throws Exception {

private HttpResponse sendSAMLMessage(String url, String samlMsgKey, String samlMsgValue) throws IOException {
List<NameValuePair> urlParameters = new ArrayList<>();
HttpPost post = new HttpPost(url);
HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain()));
post.setHeader("User-Agent", USER_AGENT);
urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue));
urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, TENANT_DOMAIN));

post.setEntity(new UrlEncodedFormEntity(urlParameters));
return httpClient.execute(post);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public class SAMLErrorResponseTestCase extends ISIntegrationTest {
private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)";
private static final String APPLICATION_NAME = "SAML-SSO-TestApplication";
private static final String ARTIFACT_ID = "travelocity.com";
private static final String TENANT_DOMAIN_PARAM = "tenantDomain";

private static final String SAML_SSO_URL = "https://localhost:9853/samlsso";
private static final String ACS_URL = "http://localhost:8490/%s/home.jsp";
Expand Down Expand Up @@ -185,12 +184,11 @@ private void setSystemProperties() {
private HttpResponse sendSAMLMessage(String url, Map<String, String> parameters) throws Exception {

List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
HttpPost post = new HttpPost(url);
HttpPost post = new HttpPost(getTenantQualifiedURL(url, tenantInfo.getDomain()));
post.setHeader("User-Agent", USER_AGENT);
for (Map.Entry<String, String> entry : parameters.entrySet()) {
urlParameters.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, isServer.getSuperTenant().getDomain()));
post.setEntity(new UrlEncodedFormEntity(urlParameters));
return httpClient.execute(post);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class SAMLIdPInitiatedSSOTestCase extends AbstractSAMLSSOTestCase {

private static final String IDP_INIT_SSO_URL = "https://localhost:%s/samlsso?spEntityID=%s";
private static final String IDP_INIT_SSO_TENANT_URL
= "https://localhost:%s/samlsso?tenantDomain=wso2.com&spEntityID=%s";
= "https://localhost:%s/t/wso2.com/samlsso?spEntityID=%s";
private static final String SAML_SSO_URL = "https://localhost:%s/samlsso";
private static final String SP_ACS_URL = "http://localhost:8490/%s/home.jsp";
private HttpClient httpClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public class SAMLLocalAndOutboundAuthenticatorsTestCase extends ISIntegrationTes
private static final String CALLBACK_URL = "callbackUrl";
private static final String SAML_SSO_LOGIN_URL = "http://localhost:8490/%s/samlsso?SAML2.HTTPBinding=%s";
private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)";
public static final String TENANT_DOMAIN_PARAM = "tenantDomain";
private static final String SAML_SSO_URL = "https://localhost:" + CommonConstants.IS_DEFAULT_HTTPS_PORT +
"/samlsso";
private static final String COMMON_AUTH_URL = "https://localhost:" + CommonConstants.IS_DEFAULT_HTTPS_PORT +
Expand Down Expand Up @@ -283,8 +282,8 @@ public void testErrorCodeInRedirectUrl() throws Exception {
String samlRequest = Utils.extractDataFromResponse(response, CommonConstants.SAML_REQUEST_PARAM, 5);
Map<String, String> paramters = new HashMap<String, String>();
paramters.put(CommonConstants.SAML_REQUEST_PARAM, samlRequest);
response = Utils.sendSAMLMessage(SAML_SSO_URL, paramters, USER_AGENT, config.getUserMode(),
TENANT_DOMAIN_PARAM, config.getUser().getTenantDomain(), httpClient);
response = Utils.sendSAMLMessage(getTenantQualifiedURL(SAML_SSO_URL, config.getUser().getTenantDomain())
, paramters, USER_AGENT, httpClient);
EntityUtils.consume(response.getEntity());
response = Utils.sendRedirectRequest(response, USER_AGENT, ACS_URL, config.getApplication()
.getArtifact(), httpClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class SAMLMetadataTestCase extends ISIntegrationTest {
"https://localhost:9853/t/wso2.com/identity/metadata/saml2";
private static final String SAML_METADATA_ENDPOINT_WITH_SUPER_TENANT_AS_PATH_PARAM =
"https://localhost:9853/t/carbon.super/identity/metadata/saml2";
private static final String SAML_SSO_ENDPOINT_TENANT = "https://localhost:9853/samlsso?tenantDomain=wso2.com";
private static final String SAML_SSO_ENDPOINT_TENANT = "https://localhost:9853/t/wso2.com/samlsso";
private static final String SAML_SSO_ENDPOINT_SUPER_TENANT = "https://localhost:9853/samlsso";
private static final String SAMLARTRESOLVE_ENDPOINT = "https://localhost:9853/samlartresolve";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ public void testSAMLRelayStateDecode() throws Exception {
Map<String, String> paramters = new HashMap<String, String>();
paramters.put(CommonConstants.SAML_REQUEST_PARAM, samlRequest);
paramters.put("RelayState", relayState);
response = Utils.sendSAMLMessage(SAML_SSO_URL, paramters, USER_AGENT, config.getUserMode(),
TENANT_DOMAIN_PARAM, config.getUser().getTenantDomain(), httpClient);
response = Utils.sendSAMLMessage(getTenantQualifiedURL(SAML_SSO_URL,
config.getUser().getTenantDomain()), paramters, USER_AGENT, httpClient);
EntityUtils.consume(response.getEntity());
response = Utils.sendRedirectRequest(response, USER_AGENT, ACS_URL, config.getApp().getArtifact(),
httpClient);
Expand Down
Loading

0 comments on commit 66624f2

Please sign in to comment.