use of org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeException 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");
}
use of org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeException in project identity-inbound-auth-oauth by wso2-extensions.
the class ScopesApiServiceImplTest method testGetScopes.
@Test(dataProvider = "BuildgetScopes")
public void testGetScopes(Response.Status expectation) throws Exception {
Set<Scope> scopes = new HashSet<>();
scopes.add(new Scope(someScopeName, someScopeName, someScopeDescription));
int startIndex = 0;
int count = 1;
if (Response.Status.OK.equals(expectation)) {
when(oAuth2ScopeService.getScopes(any(Integer.class), any(Integer.class), any(Boolean.class), any(String.class))).thenReturn(scopes);
when(ScopeUtils.class, "getScopeDTOs", any(Set.class)).thenCallRealMethod();
Response response = scopesApiService.getScopes(startIndex, count);
assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), "Error occurred while getting scopes");
assertEquals(((HashSet) response.getEntity()).size(), count, "Cannot Retrieve Expected Scopes");
} else if (Response.Status.INTERNAL_SERVER_ERROR.equals(expectation)) {
when(oAuth2ScopeService.getScopes(any(Integer.class), any(Integer.class))).thenThrow(IdentityOAuth2ScopeException.class);
callRealMethod();
try {
scopesApiService.getScopes(startIndex, count);
} catch (ScopeEndpointException e) {
assertEquals(e.getResponse().getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), "Cannot find HTTP Response, Internal Server Error in case of " + "IdentityOAuth2ScopeException");
assertNull(e.getResponse().getEntity(), "Do not include error message in case of " + "Server Exception");
}
}
}
use of org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeException 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 } };
}
use of org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeException 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 } };
}
use of org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeException 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 } };
}
Aggregations