Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failed integration tests #16802

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class SelfSignUpConsentTest extends ISIntegrationTest {
private static final String FINANCIAL = "Financial";
private static final String ERROR_MESSAGE_SELF_REGISTRATION_DISABLED = "Self registration is disabled for tenant" +
" - %s";
private static final String ERROR_MESSAGE_INVALID_TENANT = "Invalid tenant domain :%s";
private static final String ERROR_MESSAGE_INVALID_TENANT = "%s is an invalid tenant domain";
private static final String ERROR_MESSAGE_USERNAME_TAKEN = "Username '%s' is already taken. Please pick a " +
"different username";

Expand Down Expand Up @@ -141,6 +141,7 @@ public void testInitialSelfSignUpPage() throws IOException {

HttpClient client = HttpClientBuilder.create().build();
String selfRegisterEndpoint = selfRegisterDoEndpoint + "?" + CALLBACK_QUERY_PARAM + "=" + CALLBACK_ENDPOINT;
selfRegisterEndpoint = getTenantQualifiedURL(selfRegisterEndpoint, secondaryTenantDomain);
HttpResponse httpResponse = sendGetRequest(client, selfRegisterEndpoint);
String content = DataExtractUtil.getContentData(httpResponse);
Assert.assertNotNull(content);
Expand Down Expand Up @@ -296,6 +297,7 @@ private String doCallSignUpDo(String username) throws IOException {
}
String selfRegisterEndpoint =
signupDoEndpoint + "?" + USERNAME_QUERY_PARAM + "=" + username;
selfRegisterEndpoint = getTenantQualifiedURL(selfRegisterEndpoint, tenantDomain);
HttpResponse httpResponse = sendGetRequest(client, selfRegisterEndpoint);
return DataExtractUtil.getContentData(httpResponse);
}
Expand Down Expand Up @@ -434,12 +436,12 @@ private void selfRegister(String username, String password, String givenName, St

private String getConsentReqBody(String purposeId, int piiCategoryId, String username) {

return "{\\\"jurisdiction\\\":\\\"someJurisdiction\\\",\\\"collectionMethod\\\":\\\"Web Form - Self " +
return "{\\\"jurisdiction\\\":\\\"someJurisdiction\\\",\\\"collectionMethod\\\":\\\"Web Form - Self " +
"Registration\\\"," +
"\\\"language\\\":\\\"en\\\",\\\"piiPrincipalId\\\":\\\""+username+"\\\",\\\"services\\\":" +
"[{\\\"tenantDomain\\\":\\\"wso2.com\\\",\\\"serviceDisplayName\\\":\\\"Resident IDP\\\"," +
"\\\"serviceDescription\\\":\\\"Resident IDP\\\",\\\"purposes\\\":[{\\\"purposeId\\\":"+purposeId+"," +
"\\\"purposeCategoryId\\\":[1]," +
"\\\"purposeCategoryId\\\":[1]," +
"\\\"consentType\\\":\\\"EXPLICIT\\\",\\\"piiCategory\\\":[{\\\"piiCategoryId\\\":"+piiCategoryId+"," +
"\\\"validity\\\":\\\"DATE_UNTIL:INDEFINITE\\\"}],\\\"primaryPurpose\\\":true," +
"\\\"termination\\\":\\\"DATE_UNTIL:INDEFINITE\\\",\\\"thirdPartyDisclosure\\\":false}],\\\"tenantId\\\":1}]," +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,41 +140,41 @@ public static Object[][] federatedAuthConfigURLProvider() {
"Expected OAuth10a Authorize URL is not found in the tenant mode"},
{"wso2.com", "OAuth1RequestTokenUrl", "https://localhost:9853/oauth/request-token",
"Expected OAuth10a Request Token URL is not found in the tenant mode"},
{"wso2.com", "IdentityProviderUrl", "https://localhost:9853/passivests",
{"wso2.com", "IdentityProviderUrl", "https://localhost:9853/t/wso2.com/passivests",
"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/t/wso2.com/samlecp",
"Expected ECP URL is not found in the tenant mode"},
{"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",
{"wso2.com", "ArtifactResolveUrl", "https://localhost:9853/t/wso2.com/samlartresolve",
"Expected Artifact Resolution URL is not found in the tenant mode"},
{"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"},
{"wso2.com", "OIDCWebFingerEPUrl", "https://localhost:9853/.well-known/webfinger",
"Expected Web finger Endpoint URL is not found in the tenant mode"},
{"wso2.com", "OIDCCheckSessionEPUrl", "https://localhost:9853/oidc/checksession",
{"wso2.com", "OIDCCheckSessionEPUrl", "https://localhost:9853/t/wso2.com/oidc/checksession",
"Expected Session IFrame Endpoint URL is not found in the tenant mode"},
{"wso2.com", "OAuth2IntrospectEPUrl", "https://localhost:9853/t/wso2.com/oauth2/introspect",
"Expected Token Introspection Endpoint URL is not found in the tenant mode"},
{"wso2.com", "OAuth2RevokeEPUrl", "https://localhost:9853/oauth2/revoke",
{"wso2.com", "OAuth2RevokeEPUrl", "https://localhost:9853/t/wso2.com/oauth2/revoke",
"Expected Token Revocation Endpoint URL is not found in the tenant mode"},
{"wso2.com", "OIDCLogoutEPUrl", "https://localhost:9853/oidc/logout",
{"wso2.com", "OIDCLogoutEPUrl", "https://localhost:9853/t/wso2.com/oidc/logout",
"Expected Logout Endpoint URL not found in the tenant mode"},
{"wso2.com", "OAuth2AuthzEPUrl", "https://localhost:9853/oauth2/authorize",
{"wso2.com", "OAuth2AuthzEPUrl", "https://localhost:9853/t/wso2.com/oauth2/authorize",
"Expected Authorization Endpoint URL is not found in the tenant mode"},
{"wso2.com", "OAuth2DCREPUrl", "https://localhost:9853/t/wso2.com/api/identity/oauth2/dcr/v1.1/register",
"Expected Dynamic Client Registration Endpoint URL is not found in the tenant mode"},
{"wso2.com", "OIDCDiscoveryEPUrl", "https://localhost:9853/t/wso2.com/oauth2/oidcdiscovery",
"Expected Dynamic Client Registration Endpoint URL is not found in the tenant mode"},
{"wso2.com", "OAuth2JWKSPage", "https://localhost:9853/t/wso2.com/oauth2/jwks",
"Expected OAuth2 JWKS Page is not found in the tenant mode"},
{"wso2.com", "OAuth2TokenEPUrl", "https://localhost:9853/oauth2/token",
{"wso2.com", "OAuth2TokenEPUrl", "https://localhost:9853/t/wso2.com/oauth2/token",
"Expected Token Endpoint URL is not found in the tenant mode"},
{"wso2.com", "OAuth2UserInfoEPUrl", "https://localhost:9853/oauth2/userinfo",
{"wso2.com", "OAuth2UserInfoEPUrl", "https://localhost:9853/t/wso2.com/oauth2/userinfo",
"Expected User Info Endpoint URL is not found in the tenant mode"}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void testInit() throws Exception {

super.init(TestUserMode.TENANT_USER);

this.USERNAME = tenantInfo.getContextUser().getUserName();
this.USERNAME = tenantInfo.getContextUser().getUserNameWithoutDomain();
this.PASSWORD = tenantInfo.getContextUser().getPassword();
setSystemproperties();
client = HttpClients.createDefault();
Expand Down Expand Up @@ -126,7 +126,8 @@ public void testRegisterApplication() throws Exception {
"testRegisterApplication")
public void testSendAuthorizedPost() throws Exception {

HttpPost request = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT);
HttpPost request = new HttpPost(getTenantQualifiedURL(
OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
List<NameValuePair> urlParameters = new ArrayList<>();
urlParameters.add(new BasicNameValuePair("grant_type",
OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER));
Expand Down Expand Up @@ -159,7 +160,8 @@ public void testSendAuthorizedPostAfterRoleUpdate() throws Exception {

scim2RestClient.updateUserRole(getAddUserPatchRole(userId), roleId);

HttpPost request = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT);
HttpPost request = new HttpPost(getTenantQualifiedURL(
OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
List<NameValuePair> urlParameters = new ArrayList<>();
urlParameters.add(new BasicNameValuePair("grant_type",
OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void testGetTokenUsingClientCredentialsGrant() throws Exception {
ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret);
Scope scope = new Scope(OAUTH2_SCOPE_OPENID, "xyz");

URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT);
URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, clientCredentialsGrant, scope);
HTTPResponse tokenHTTPResp = request.toHTTPRequest().send();
Assert.assertNotNull(tokenHTTPResp, "Access token http response is null.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ public void testSendAuthorozedPost() throws Exception {
urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey));
urlParameters.add(new BasicNameValuePair("scope", scopes));
urlParameters.add(new BasicNameValuePair("callbackurl", OAuth2Constant.CALLBACK_URL));
urlParameters.add(new BasicNameValuePair("authorizeEndpoint", OAuth2Constant.APPROVAL_URL));
urlParameters.add(new BasicNameValuePair("authorizeEndpoint",
getTenantQualifiedURL(OAuth2Constant.APPROVAL_URL, tenantInfo.getDomain())));
urlParameters.add(new BasicNameValuePair("authorize", OAuth2Constant.AUTHORIZE_PARAM));
urlParameters.add(new BasicNameValuePair("consumerSecret", consumerSecret));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void testGetAccessToken() throws Exception {
urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey));
urlParameters.add(new BasicNameValuePair("consumerSecret", consumerSecret));
urlParameters.add(new BasicNameValuePair("accessEndpoint",
OAuth2Constant.ACCESS_TOKEN_ENDPOINT));
getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())));
urlParameters.add(new BasicNameValuePair("authorize", OAuth2Constant.AUTHORIZE_PARAM));
HttpResponse response =
sendPostRequestWithParameters(client, urlParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class OAuth2ServiceRefreshTokenGrantTestCase extends OAuth2ServiceAbstrac
@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
super.init(TestUserMode.SUPER_TENANT_USER);
adminUsername = userInfo.getUserName();
adminUsername = userInfo.getUserNameWithoutDomain();
adminPassword = userInfo.getPassword();

setSystemproperties();
Expand Down Expand Up @@ -111,7 +111,8 @@ public void testRefreshTokenGrant() throws Exception {
}

private JSONObject responseObject(List<NameValuePair> postParameters) throws Exception {
HttpPost httpPost = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT);
HttpPost httpPost = new HttpPost(getTenantQualifiedURL(
OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
//generate post request
httpPost.setHeader("Authorization", "Basic " + getBase64EncodedString(consumerKey, consumerSecret));
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ private boolean getTokenAndValidate(Scope scope) throws Exception {

try {
Secret password = new Secret(userInfo.getPassword());
AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(userInfo.getUserName(),
password);
AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(
userInfo.getUserNameWithoutDomain(), password);
ClientID clientID = new ClientID(consumerKey);
Secret clientSecret = new Secret(consumerSecret);
ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret);
URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT);
URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, passwordGrant, scope);

HTTPResponse tokenHTTPResp = request.toHTTPRequest().send();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void testWebFinger() throws IOException {
Object links = ((JSONObject)obj).get("links");
Assert.assertNotNull(links);
String openIdProviderIssuerLocation = ((JSONObject)((JSONArray)links).get(0)).get("href").toString();
String urlExpected = isServerBackendUrl + "/oauth2/token";
String urlExpected = getTenantQualifiedURL(isServerBackendUrl + "/oauth2/token", config.getTenant());
Assert.assertEquals(openIdProviderIssuerLocation, urlExpected);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ private boolean getTokenAndValidate(Scope scope) throws Exception {

try {
Secret password = new Secret(userInfo.getPassword());
AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(userInfo.getUserName(),
password);
AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(
userInfo.getUserNameWithoutDomain(), password);
ClientID clientID = new ClientID(consumerKey);
Secret clientSecret = new Secret(consumerSecret);
ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret);
URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT);
URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, passwordGrant, scope);

HTTPResponse tokenHTTPResp = request.toHTTPRequest().send();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class SystemScopePermissionValidationTestCase extends OAuth2ServiceAbstra
private String consumerSecret;
private CloseableHttpClient client;
private final String username;
private final String usernameWithoutTenantDomain;
private final String userPassword;
private final String activeTenant;
private final TestUserMode testUserMode;
Expand All @@ -82,6 +83,7 @@ public SystemScopePermissionValidationTestCase(TestUserMode userMode) throws Exc
super.init(userMode);
AutomationContext context = new AutomationContext("IDENTITY", userMode);
this.username = context.getContextTenant().getTenantAdmin().getUserName();
this.usernameWithoutTenantDomain = context.getContextTenant().getTenantAdmin().getUserNameWithoutDomain();
this.userPassword = context.getContextTenant().getTenantAdmin().getPassword();
this.activeTenant = context.getContextTenant().getDomain();
this.testUserMode = userMode;
Expand Down Expand Up @@ -127,7 +129,7 @@ public void testGetAccessToken() throws Exception {
urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey));
urlParameters.add(new BasicNameValuePair("consumerSecret", consumerSecret));
urlParameters.add(new BasicNameValuePair("accessEndpoint",
OAuth2Constant.ACCESS_TOKEN_ENDPOINT));
getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain())));
urlParameters.add(new BasicNameValuePair("authorize", OAuth2Constant.AUTHORIZE_PARAM));
urlParameters.add(new BasicNameValuePair("scope", SYSTEM_SCOPE));
HttpResponse response =
Expand Down Expand Up @@ -164,11 +166,12 @@ public void getTokenAndValidate() throws Exception {
try {
client = HttpClientBuilder.create().disableRedirectHandling().build();
Secret password = new Secret(userPassword);
AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(username, password);
AuthorizationGrant passwordGrant = new ResourceOwnerPasswordCredentialsGrant(
usernameWithoutTenantDomain, password);
ClientID clientID = new ClientID(consumerKey);
Secret clientSecret = new Secret(consumerSecret);
ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret);
URI tokenEndpoint = new URI(OAuth2Constant.ACCESS_TOKEN_ENDPOINT);
URI tokenEndpoint = new URI(getTenantQualifiedURL(OAuth2Constant.ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
Scope systemScope = new Scope(SYSTEM_SCOPE);
TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, passwordGrant, systemScope);

Expand Down