use of org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeRespDTO in project identity-inbound-auth-oauth by wso2-extensions.
the class AuthorizationHandlerManagerTest method testHandleAuthorizationTokenResponseUnauthorizedAccess.
@Test
public void testHandleAuthorizationTokenResponseUnauthorizedAccess() throws Exception {
authorizationHandlerManager = AuthorizationHandlerManager.getInstance();
authzReqDTO.setResponseType(TestConstants.AUTHORIZATION_HANDLER_RESPONSE_TYPE_TOKEN);
authzReqDTO.setConsumerKey(TestConstants.CLIENT_ID);
authzReqDTO.setScopes(TestConstants.SCOPE_UNAUTHORIZED_ACCESS.split(" "));
AuthenticatedUser user = new AuthenticatedUser();
user.setUserName(TestConstants.USER_NAME);
user.setTenantDomain(TestConstants.TENANT_DOMAIN);
user.setUserStoreDomain(TestConstants.USER_DOMAIN_PRIMARY);
authzReqDTO.setUser(user);
OAuth2AuthorizeRespDTO respDTO = authorizationHandlerManager.handleAuthorization(authzReqDTO);
String errorCode = respDTO.getErrorCode();
Assert.assertNotNull(respDTO, "Response is null");
Assert.assertNotNull(respDTO.getErrorCode(), "Error code returned is null");
Assert.assertEquals(errorCode, OAuthError.CodeResponse.UNAUTHORIZED_CLIENT, "Expected " + OAuthError.CodeResponse.UNAUTHORIZED_CLIENT + " error code but found : " + errorCode);
}
use of org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeRespDTO in project identity-inbound-auth-oauth by wso2-extensions.
the class AuthorizationHandlerManagerTest method testHandleAuthorizationTokenResponseTypeUnauthorized.
@Test
public void testHandleAuthorizationTokenResponseTypeUnauthorized() throws Exception {
authzReqDTO.setResponseType(TestConstants.AUTHORIZATION_HANDLER_RESPONSE_TYPE_TOKEN);
authzReqDTO.setConsumerKey(TestConstants.CLIENT_ID_UNAUTHORIZED_CLIENT);
authzReqDTO.setScopes(TestConstants.SCOPE_STRING.split(" "));
AuthenticatedUser user = new AuthenticatedUser();
user.setUserName(TestConstants.USER_NAME);
user.setTenantDomain(TestConstants.TENANT_DOMAIN);
user.setUserStoreDomain(TestConstants.USER_DOMAIN_PRIMARY);
authzReqDTO.setUser(user);
OAuth2AuthorizeRespDTO respDTO = authorizationHandlerManager.handleAuthorization(authzReqDTO);
String errorCode = respDTO.getErrorCode();
Assert.assertNotNull(respDTO, "Response is null");
Assert.assertNotNull(respDTO.getErrorCode(), "Error code returned is null");
Assert.assertEquals(errorCode, TestConstants.UNAUTHORIZED_CLIENT_ERROR_CODE, "Expected unauthorized_client error code but found : " + errorCode);
}
use of org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeRespDTO in project identity-inbound-auth-oauth by wso2-extensions.
the class AuthorizationHandlerManagerTest method testHandleInvalidResponseType.
@Test
public void testHandleInvalidResponseType() throws Exception {
authzReqDTO.setResponseType(TestConstants.AUTHORIZATION_HANDLER_RESPONSE_TYPE_INVALID);
OAuth2AuthorizeRespDTO respDTO = authorizationHandlerManager.handleAuthorization(authzReqDTO);
String errorCode = respDTO.getErrorCode();
Assert.assertNotNull(respDTO, "Response is null");
Assert.assertNotNull(respDTO.getErrorCode(), "Error code returned is null");
Assert.assertEquals(errorCode, OAuthError.CodeResponse.UNSUPPORTED_RESPONSE_TYPE, "Expected " + OAuthError.CodeResponse.UNSUPPORTED_RESPONSE_TYPE + " error code but found : " + errorCode);
}
use of org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeRespDTO in project identity-inbound-auth-oauth by wso2-extensions.
the class AuthorizationHandlerManagerTest method testHandleAuthorizationTokenResponseUnauthorizedScope.
@Test
public void testHandleAuthorizationTokenResponseUnauthorizedScope() throws Exception {
authorizationHandlerManager = AuthorizationHandlerManager.getInstance();
authzReqDTO.setResponseType(TestConstants.AUTHORIZATION_HANDLER_RESPONSE_TYPE_TOKEN);
authzReqDTO.setConsumerKey(TestConstants.CLIENT_ID);
authzReqDTO.setScopes(TestConstants.SCOPE_UNAUTHORIZED_SCOPE.split(" "));
AuthenticatedUser user = new AuthenticatedUser();
user.setUserName(TestConstants.USER_NAME);
user.setTenantDomain(TestConstants.TENANT_DOMAIN);
user.setUserStoreDomain(TestConstants.USER_DOMAIN_PRIMARY);
authzReqDTO.setUser(user);
OAuth2AuthorizeRespDTO respDTO = authorizationHandlerManager.handleAuthorization(authzReqDTO);
String errorCode = respDTO.getErrorCode();
Assert.assertNotNull(respDTO, "Response is null");
Assert.assertNotNull(respDTO.getErrorCode(), "Error code returned is null");
Assert.assertEquals(errorCode, OAuthError.CodeResponse.INVALID_SCOPE, "Expected " + OAuthError.CodeResponse.INVALID_SCOPE + " error code but found : " + errorCode);
}
use of org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeRespDTO in project identity-inbound-auth-oauth by wso2-extensions.
the class AuthorizationHandlerManagerTest method testHandleAuthorizationIDTokenResponseTypeUnauthorized.
@Test
public void testHandleAuthorizationIDTokenResponseTypeUnauthorized() throws Exception {
authzReqDTO.setResponseType(TestConstants.AUTHORIZATION_HANDLER_RESPONSE_TYPE_ID_TOKEN);
authzReqDTO.setConsumerKey(TestConstants.CLIENT_ID_UNAUTHORIZED_CLIENT);
authzReqDTO.setScopes(TestConstants.SCOPE_STRING.split(" "));
AuthenticatedUser user = new AuthenticatedUser();
user.setUserName(TestConstants.USER_NAME);
user.setTenantDomain(TestConstants.TENANT_DOMAIN);
user.setUserStoreDomain(TestConstants.USER_DOMAIN_PRIMARY);
authzReqDTO.setUser(user);
OAuth2AuthorizeRespDTO respDTO = authorizationHandlerManager.handleAuthorization(authzReqDTO);
String errorCode = respDTO.getErrorCode();
Assert.assertNotNull(respDTO, "Response is null");
Assert.assertNotNull(respDTO.getErrorCode(), "Error code returned is null");
Assert.assertEquals(errorCode, TestConstants.UNAUTHORIZED_CLIENT_ERROR_CODE, "Expected unauthorized_client error code but found : " + errorCode);
}
Aggregations