Search in sources :

Example 6 with IdentityOAuth2ScopeClientException

use of org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeClientException in project identity-inbound-auth-oauth by wso2-extensions.

the class OAuth2ScopeServiceTest method testRegisterWithInvalidScopeName.

@Test(dataProvider = "invalidScopeNameProvider")
public void testRegisterWithInvalidScopeName(String scopeName, String expected) {
    try {
        Scope scope = new Scope(scopeName, "displayName", "description");
        oAuth2ScopeService.registerScope(scope);
    } catch (IdentityOAuth2ScopeException ex) {
        assertEquals(ex.getMessage(), String.format(expected, scopeName));
        return;
    }
    fail("Expected IdentityOAuth2ScopeClientException was not thrown by registerScope method");
}
Also used : Scope(org.wso2.carbon.identity.oauth2.bean.Scope) Test(org.testng.annotations.Test)

Example 7 with IdentityOAuth2ScopeClientException

use of org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeClientException in project identity-inbound-auth-oauth by wso2-extensions.

the class ScopesApiServiceImplTest method buildRegisterApplication.

@DataProvider(name = "BuildRegisterScope")
public Object[][] buildRegisterApplication() {
    IdentityOAuth2ScopeClientException identityOAuth2ScopeClientException = new IdentityOAuth2ScopeClientException("Oauth2 Scope Client Exception");
    IdentityOAuth2ScopeException identityOAuth2ScopeException = new IdentityOAuth2ScopeException("Oauth2 Scope Exception");
    return new Object[][] { { Response.Status.OK, null }, { Response.Status.BAD_REQUEST, identityOAuth2ScopeClientException }, { Response.Status.CONFLICT, identityOAuth2ScopeClientException }, { Response.Status.INTERNAL_SERVER_ERROR, identityOAuth2ScopeException } };
}
Also used : IdentityOAuth2ScopeClientException(org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeClientException) IdentityOAuth2ScopeException(org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeException) DataProvider(org.testng.annotations.DataProvider)

Example 8 with IdentityOAuth2ScopeClientException

use of org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeClientException in project identity-inbound-auth-oauth by wso2-extensions.

the class ScopesApiServiceImplTest method checkScopeException.

@DataProvider(name = "checkisScopeException")
public Object[][] checkScopeException() {
    IdentityOAuth2ScopeClientException identityOAuth2ScopeClientException = new IdentityOAuth2ScopeClientException("Oauth2 Scope Client Exception");
    IdentityOAuth2ScopeException identityOAuth2ScopeException = new IdentityOAuth2ScopeException("Oauth2 Scope Exception");
    return new Object[][] { { Response.Status.OK, null }, { Response.Status.NOT_FOUND, null }, { Response.Status.BAD_REQUEST, identityOAuth2ScopeClientException }, { Response.Status.INTERNAL_SERVER_ERROR, identityOAuth2ScopeException } };
}
Also used : IdentityOAuth2ScopeClientException(org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeClientException) IdentityOAuth2ScopeException(org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeException) DataProvider(org.testng.annotations.DataProvider)

Example 9 with IdentityOAuth2ScopeClientException

use of org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeClientException in project identity-inbound-auth-oauth by wso2-extensions.

the class ScopesApiServiceImplTest method buildGetApplication.

@DataProvider(name = "BuildGetScope")
public Object[][] buildGetApplication() {
    IdentityOAuth2ScopeClientException identityOAuth2ScopeClientException = new IdentityOAuth2ScopeClientException("Oauth2 Scope Client Exception");
    IdentityOAuth2ScopeException identityOAuth2ScopeException = new IdentityOAuth2ScopeException("Oauth2 Scope Exception");
    return new Object[][] { { Response.Status.OK, null }, { Response.Status.BAD_REQUEST, identityOAuth2ScopeClientException }, { Response.Status.NOT_FOUND, identityOAuth2ScopeClientException }, { Response.Status.INTERNAL_SERVER_ERROR, identityOAuth2ScopeException } };
}
Also used : IdentityOAuth2ScopeClientException(org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeClientException) IdentityOAuth2ScopeException(org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeException) DataProvider(org.testng.annotations.DataProvider)

Example 10 with IdentityOAuth2ScopeClientException

use of org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeClientException in project identity-inbound-auth-oauth by wso2-extensions.

the class ScopesApiServiceImplTest method buildDeleteApplication.

@DataProvider(name = "BuildDeleteScope")
public Object[][] buildDeleteApplication() {
    IdentityOAuth2ScopeClientException identityOAuth2ScopeClientException = new IdentityOAuth2ScopeClientException("Oauth2 Scope Client Exception");
    IdentityOAuth2ScopeException identityOAuth2ScopeException = new IdentityOAuth2ScopeException("Oauth2 Scope Exception");
    return new Object[][] { { Response.Status.OK, null }, { Response.Status.BAD_REQUEST, identityOAuth2ScopeClientException }, { Response.Status.NOT_FOUND, identityOAuth2ScopeClientException } };
}
Also used : IdentityOAuth2ScopeClientException(org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeClientException) IdentityOAuth2ScopeException(org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeException) DataProvider(org.testng.annotations.DataProvider)

Aggregations

IdentityOAuth2ScopeException (org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeException)9 IdentityOAuth2ScopeClientException (org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeClientException)8 DataProvider (org.testng.annotations.DataProvider)5 Scope (org.wso2.carbon.identity.oauth2.bean.Scope)4 Test (org.testng.annotations.Test)3 ScopeDTO (org.wso2.carbon.identity.oauth.scope.endpoint.dto.ScopeDTO)3 PreparedStatement (java.sql.PreparedStatement)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 ErrorDTO (org.wso2.carbon.identity.oauth.scope.endpoint.dto.ErrorDTO)2 ScopeEndpointException (org.wso2.carbon.identity.oauth.scope.endpoint.exceptions.ScopeEndpointException)2 NamedPreparedStatement (org.wso2.carbon.identity.oauth2.util.NamedPreparedStatement)2 PowerMockIdentityBaseTest (org.wso2.carbon.identity.testutil.powermock.PowerMockIdentityBaseTest)2 ResultSet (java.sql.ResultSet)1 ScopeToUpdateDTO (org.wso2.carbon.identity.oauth.scope.endpoint.dto.ScopeToUpdateDTO)1 ScopeBinding (org.wso2.carbon.identity.oauth2.bean.ScopeBinding)1