Search in sources :

Example 11 with ScopeInfo

use of org.wso2.carbon.apimgt.core.auth.dto.ScopeInfo in project carbon-apimgt by wso2.

the class DefaultScopeRegistrationImpl method getScopeInfo.

private ScopeInfo getScopeInfo(Scope scope) {
    ScopeInfo scopeInfo = new ScopeInfo();
    scopeInfo.setName(scope.getName());
    scopeInfo.setDescription(scope.getDescription());
    scopeInfo.setBindings(scope.getBindings());
    return scopeInfo;
}
Also used : ScopeInfo(org.wso2.carbon.apimgt.core.auth.dto.ScopeInfo)

Example 12 with ScopeInfo

use of org.wso2.carbon.apimgt.core.auth.dto.ScopeInfo in project carbon-apimgt by wso2.

the class WSO2ISScopeRegistrationImpl method getScopeInfo.

private ScopeInfo getScopeInfo(Scope scope) {
    ScopeInfo scopeInfo = new ScopeInfo();
    scopeInfo.setName(scope.getName());
    scopeInfo.setDisplayName(scope.getName());
    scopeInfo.setDescription(scope.getDescription());
    scopeInfo.setBindings(scope.getBindings());
    return scopeInfo;
}
Also used : ScopeInfo(org.wso2.carbon.apimgt.core.auth.dto.ScopeInfo)

Example 13 with ScopeInfo

use of org.wso2.carbon.apimgt.core.auth.dto.ScopeInfo in project carbon-apimgt by wso2.

the class DefaultScopeRegistrationImpl method registerScope.

@Override
public boolean registerScope(Scope scope) throws KeyManagementException {
    ScopeInfo scopeInfo = getScopeInfo(scope);
    Response response = scopeRegistrationServiceStub.registerScope(scopeInfo);
    if (response.status() == APIMgtConstants.HTTPStatusCodes.SC_201_CREATED) {
        return true;
    } else {
        throw new KeyManagementException("Scope Registration Failed", ExceptionCodes.SCOPE_REGISTRATION_FAILED);
    }
}
Also used : Response(feign.Response) ScopeInfo(org.wso2.carbon.apimgt.core.auth.dto.ScopeInfo) KeyManagementException(org.wso2.carbon.apimgt.core.exception.KeyManagementException)

Example 14 with ScopeInfo

use of org.wso2.carbon.apimgt.core.auth.dto.ScopeInfo in project carbon-apimgt by wso2.

the class DefaultScopeRegistrationImplTest method getScopeInfo.

private ScopeInfo getScopeInfo(Scope scope) {
    ScopeInfo scopeInfo = new ScopeInfo();
    scopeInfo.setName(scope.getName());
    scopeInfo.setDescription(scope.getDescription());
    scopeInfo.setBindings(scope.getBindings());
    return scopeInfo;
}
Also used : ScopeInfo(org.wso2.carbon.apimgt.core.auth.dto.ScopeInfo)

Example 15 with ScopeInfo

use of org.wso2.carbon.apimgt.core.auth.dto.ScopeInfo in project carbon-apimgt by wso2.

the class DefaultScopeRegistrationImplTest method testUpdateScope.

@Test
public void testUpdateScope() throws KeyManagementException {
    DefaultScopeRegistrationServiceStub defaultScopeRegistrationServiceStub = Mockito.mock(DefaultScopeRegistrationServiceStub.class);
    DefaultScopeRegistrationImpl defaultScopeRegistration = new DefaultScopeRegistrationImpl(defaultScopeRegistrationServiceStub);
    ScopeInfo scopeInfo = new ScopeInfo();
    scopeInfo.setDescription("cde");
    scopeInfo.setDisplayName("abc");
    Scope scope = new Scope();
    scope.setName("abc");
    scope.setDescription("cde");
    Mockito.when(defaultScopeRegistrationServiceStub.updateScope(Mockito.any(ScopeInfo.class), Mockito.anyString())).thenReturn(Response.builder().status(200).headers(new HashMap<>()).body(new Gson().toJson(scopeInfo), feign.Util.UTF_8).build());
    boolean status = defaultScopeRegistration.updateScope(scope);
    Assert.assertTrue(status);
}
Also used : Scope(org.wso2.carbon.apimgt.core.models.Scope) HashMap(java.util.HashMap) Gson(com.google.gson.Gson) ScopeInfo(org.wso2.carbon.apimgt.core.auth.dto.ScopeInfo) Test(org.testng.annotations.Test)

Aggregations

ScopeInfo (org.wso2.carbon.apimgt.core.auth.dto.ScopeInfo)15 Scope (org.wso2.carbon.apimgt.core.models.Scope)8 Test (org.testng.annotations.Test)6 KeyManagementException (org.wso2.carbon.apimgt.core.exception.KeyManagementException)6 Gson (com.google.gson.Gson)5 HashMap (java.util.HashMap)5 Response (feign.Response)4 GsonDecoder (feign.gson.GsonDecoder)2 ArrayList (java.util.ArrayList)1