Skip to content

Commit

Permalink
Merge pull request #427 from Pushpalanka/IDENTITY-3286
Browse files Browse the repository at this point in the history
Identity 3286
  • Loading branch information
Pushpalanka Jayawardhana committed Mar 6, 2016
2 parents 98aaf4e + a26baf3 commit ca40daf
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<!--<class name="org.wso2.identity.integration.test.identity.mgt.AccountLockingWhileSCIMEnabledTestCase"/>-->
<!--Identity Management Test Cases-->
<class name="org.wso2.identity.integration.test.identity.mgt.AccountCredentialMgtConfigServiceTestCase" />
<class name="org.wso2.identity.integration.test.identity.mgt.IdentityProviderMgtServiceTestCase" />
<class name="org.wso2.identity.integration.test.identity.mgt.UserIdentityManagementServiceTestCase"/>
<class name="org.wso2.identity.integration.test.identity.mgt.UserInformationRecoveryServiceTenantEmailUserTestCase"/>
<!--User Store Test Cases-->
Expand Down Expand Up @@ -98,6 +97,7 @@

<!--Identity Provider Management Test Cases-->
<class name="org.wso2.identity.integration.test.idp.mgt.IdentityProviderManagementTestCase"/>
<class name="org.wso2.identity.integration.test.idp.mgt.IdentityProviderMgtServiceTestCase" />
</classes>
</test>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ca40daf

Please sign in to comment.