diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/identity/mgt/AccountLockingWhileSCIMEnabledTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/identity/mgt/AccountLockingWhileSCIMEnabledTestCase.java index 8edf9310e92..8166bd6ae18 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/identity/mgt/AccountLockingWhileSCIMEnabledTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/identity/mgt/AccountLockingWhileSCIMEnabledTestCase.java @@ -59,6 +59,7 @@ public class AccountLockingWhileSCIMEnabledTestCase extends ISIntegrationTest { private static final String TEST_USER_PASSWORD = "Ab@123"; private static final String WRONG_PASSWORD = "wrongPassword"; private static final String TEST_ROLE = "testRole"; + private static final String DISABLED_CLAIM = "http://wso2.org/claims/identity/accountDisabled"; @SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL}) @@ -121,9 +122,27 @@ public void testSuccessfulLoginInitially() throws Exception { loginManger.logOut(); } + @SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL}) + @Test(groups = "wso2.is", description = "Check whether the user cannot login when account is disabled", + dependsOnMethods = "testSuccessfulLoginInitially", expectedExceptions = LoginAuthenticationExceptionException.class) + public void testUnsuccessfulLoginWithAccountDisabled() throws Exception { + remoteUSMServiceClient.setUserClaimValue(TEST_USER_USERNAME, DISABLED_CLAIM, "true", null); + loginManger.login(TEST_USER_USERNAME, TEST_USER_PASSWORD, isServer.getInstance().getHosts().get("default")); + loginManger.logOut(); + } + + @SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL}) + @Test(groups = "wso2.is", description = "Check whether the user can login when account is enabled again", + dependsOnMethods = "testUnsuccessfulLoginWithAccountDisabled", expectedExceptions = LoginAuthenticationExceptionException.class) + public void testSuccessfulLoginWithAccountEnabled() throws Exception { + remoteUSMServiceClient.setUserClaimValue(TEST_USER_USERNAME, DISABLED_CLAIM, "false", null); + loginManger.login(TEST_USER_USERNAME, TEST_USER_PASSWORD, isServer.getInstance().getHosts().get("default")); + loginManger.logOut(); + } + @SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL}) @Test(groups = "wso2.is", description = "Check user account verification", - dependsOnMethods = "testSuccessfulLoginInitially", expectedExceptions = LoginAuthenticationExceptionException.class) + dependsOnMethods = "testSuccessfulLoginWithAccountEnabled", expectedExceptions = LoginAuthenticationExceptionException.class) public void testUnsuccessfulFirstLogin() throws Exception { loginManger.login(TEST_USER_USERNAME, WRONG_PASSWORD, isServer.getInstance().getHosts().get("default")); loginManger.logOut(); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/identity/mgt/IdentityProviderMgtServiceTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/IdentityProviderMgtServiceTestCase.java similarity index 99% rename from modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/identity/mgt/IdentityProviderMgtServiceTestCase.java rename to modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/IdentityProviderMgtServiceTestCase.java index 2ac75cdb3e7..c50c8430ee2 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/identity/mgt/IdentityProviderMgtServiceTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/IdentityProviderMgtServiceTestCase.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.identity.integration.test.identity.mgt; +package org.wso2.identity.integration.test.idp.mgt; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.ConfigurationContextFactory; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/utils/DataExtractUtil.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/utils/DataExtractUtil.java index 1064dc77584..ffd0031888e 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/utils/DataExtractUtil.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/utils/DataExtractUtil.java @@ -229,9 +229,9 @@ public static String extractAccessTokenFromQueryString(String query) { String[] params = query.split("&"); for (String param : params) { String name = param.split("=")[0]; - String value = param.split("=")[1]; - if (name.contains("access_token")) - return value; + if (name.contains(OAuth2Constant.ACCESS_TOKEN)) { + return param.split("=")[1]; + } } return null; } diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml index 73c44e5e7f0..017415b2f15 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml @@ -51,7 +51,6 @@ - @@ -98,6 +97,7 @@ + diff --git a/modules/samples/oauth2/custom-grant/src/main/java/org/wso2/sample/identity/oauth2/grant/mobile/MobileGrant.java b/modules/samples/oauth2/custom-grant/src/main/java/org/wso2/sample/identity/oauth2/grant/mobile/MobileGrant.java index 9f63da5d8ea..f36fc8ae3f9 100644 --- a/modules/samples/oauth2/custom-grant/src/main/java/org/wso2/sample/identity/oauth2/grant/mobile/MobileGrant.java +++ b/modules/samples/oauth2/custom-grant/src/main/java/org/wso2/sample/identity/oauth2/grant/mobile/MobileGrant.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; +import org.wso2.carbon.identity.oauth2.ResponseHeader; import org.wso2.carbon.identity.oauth2.model.RequestParameter; import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext; import org.wso2.carbon.identity.oauth2.token.handlers.grant.AbstractAuthorizationGrantHandler; @@ -67,7 +68,13 @@ public boolean validateGrant(OAuthTokenReqMessageContext oAuthTokenReqMessageCon mobileUser.setUserName(mobileNumber); oAuthTokenReqMessageContext.setAuthorizedUser(mobileUser); oAuthTokenReqMessageContext.setScope(oAuthTokenReqMessageContext.getOauth2AccessTokenReqDTO().getScope()); + } else{ + ResponseHeader responseHeader = new ResponseHeader(); + responseHeader.setKey("SampleHeader-999"); + responseHeader.setValue("Provided Mobile Number is Invalid."); + oAuthTokenReqMessageContext.addProperty("RESPONSE_HEADERS", new ResponseHeader[]{responseHeader}); } + } return authStatus;