Search in sources :

Example 6 with ApiPermissionFilter

use of io.gravitee.rest.api.service.jackson.filter.ApiPermissionFilter in project gravitee-management-rest-api by gravitee-io.

the class ObjectMapperResolver method registerFilterProvider.

private void registerFilterProvider() {
    PropertyFilter apiMembershipTypeFilter = new ApiPermissionFilter();
    mapper.setFilterProvider(new SimpleFilterProvider(Collections.singletonMap("apiMembershipTypeFilter", apiMembershipTypeFilter)));
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) PropertyFilter(com.fasterxml.jackson.databind.ser.PropertyFilter) ApiPermissionFilter(io.gravitee.rest.api.service.jackson.filter.ApiPermissionFilter)

Example 7 with ApiPermissionFilter

use of io.gravitee.rest.api.service.jackson.filter.ApiPermissionFilter in project gravitee-management-rest-api by gravitee-io.

the class ObjectMapperResolver method registerFilterProvider.

private void registerFilterProvider() {
    PropertyFilter apiMembershipTypeFilter = new ApiPermissionFilter();
    mapper.setFilterProvider(new SimpleFilterProvider(Collections.singletonMap("apiMembershipTypeFilter", apiMembershipTypeFilter)));
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) PropertyFilter(com.fasterxml.jackson.databind.ser.PropertyFilter) ApiPermissionFilter(io.gravitee.rest.api.service.jackson.filter.ApiPermissionFilter)

Example 8 with ApiPermissionFilter

use of io.gravitee.rest.api.service.jackson.filter.ApiPermissionFilter in project gravitee-management-rest-api by gravitee-io.

the class ApiService_Update_DefaultLoggingMaxDurationTest method setUp.

@Before
public void setUp() throws TechnicalException {
    PropertyFilter apiMembershipTypeFilter = new ApiPermissionFilter();
    objectMapper.setFilterProvider(new SimpleFilterProvider(Collections.singletonMap("apiMembershipTypeFilter", apiMembershipTypeFilter)));
    when(apiRepository.findById(API_ID)).thenReturn(Optional.of(api));
    when(apiRepository.update(any())).thenReturn(api);
    when(api.getId()).thenReturn(API_ID);
    when(api.getName()).thenReturn(API_NAME);
    when(api.getApiLifecycleState()).thenReturn(ApiLifecycleState.CREATED);
    existingApi = new UpdateApiEntity();
    existingApi.setName(API_NAME);
    existingApi.setVersion("v1");
    existingApi.setDescription("Ma description");
    existingApi.setLifecycleState(io.gravitee.rest.api.model.api.ApiLifecycleState.CREATED);
    final Proxy proxy = new Proxy();
    EndpointGroup endpointGroup = new EndpointGroup();
    endpointGroup.setName("endpointGroupName");
    Endpoint endpoint = new HttpEndpoint("endpointName", null);
    endpointGroup.setEndpoints(singleton(endpoint));
    proxy.setGroups(singleton(endpointGroup));
    existingApi.setProxy(proxy);
    proxy.setVirtualHosts(Collections.singletonList(new VirtualHost("/context")));
    RoleEntity poRoleEntity = new RoleEntity();
    poRoleEntity.setName(SystemRole.PRIMARY_OWNER.name());
    poRoleEntity.setScope(RoleScope.API);
    when(roleService.findPrimaryOwnerRoleByOrganization("DEFAULT", RoleScope.API)).thenReturn(poRoleEntity);
    MemberEntity po = new MemberEntity();
    po.setId(USER_NAME);
    po.setReferenceId(API_ID);
    po.setReferenceType(io.gravitee.rest.api.model.MembershipReferenceType.API);
    po.setRoles(Collections.singletonList(poRoleEntity));
    when(membershipService.getMembersByReferencesAndRole(any(), any(), any())).thenReturn(singleton(po));
    mockStatic(System.class);
    when(System.currentTimeMillis()).thenReturn(0L);
    final SecurityContext securityContext = mock(SecurityContext.class);
    when(securityContext.getAuthentication()).thenReturn(mock(Authentication.class));
    SecurityContextHolder.setContext(securityContext);
    when(notificationTemplateService.resolveInlineTemplateWithParam(anyString(), any(Reader.class), any())).thenReturn("toDecode=decoded-value");
    when(parameterService.find(Key.API_PRIMARY_OWNER_MODE, ParameterReferenceType.ENVIRONMENT)).thenReturn("USER");
    MembershipEntity primaryOwner = new MembershipEntity();
    primaryOwner.setMemberType(MembershipMemberType.USER);
    when(membershipService.getPrimaryOwner(eq(MembershipReferenceType.API), any())).thenReturn(primaryOwner);
    reset(searchEngineService);
}
Also used : UpdateApiEntity(io.gravitee.rest.api.model.api.UpdateApiEntity) Reader(java.io.Reader) HttpEndpoint(io.gravitee.definition.model.endpoint.HttpEndpoint) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) HttpEndpoint(io.gravitee.definition.model.endpoint.HttpEndpoint) Authentication(org.springframework.security.core.Authentication) SecurityContext(org.springframework.security.core.context.SecurityContext) PropertyFilter(com.fasterxml.jackson.databind.ser.PropertyFilter) ApiPermissionFilter(io.gravitee.rest.api.service.jackson.filter.ApiPermissionFilter) Before(org.junit.Before)

Example 9 with ApiPermissionFilter

use of io.gravitee.rest.api.service.jackson.filter.ApiPermissionFilter in project gravitee-management-rest-api by gravitee-io.

the class ApiService_DeleteTest method setUp.

@Before
public void setUp() {
    PropertyFilter apiMembershipTypeFilter = new ApiPermissionFilter();
    objectMapper.setFilterProvider(new SimpleFilterProvider(Collections.singletonMap("apiMembershipTypeFilter", apiMembershipTypeFilter)));
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) PropertyFilter(com.fasterxml.jackson.databind.ser.PropertyFilter) ApiPermissionFilter(io.gravitee.rest.api.service.jackson.filter.ApiPermissionFilter) Before(org.junit.Before)

Example 10 with ApiPermissionFilter

use of io.gravitee.rest.api.service.jackson.filter.ApiPermissionFilter in project gravitee-management-rest-api by gravitee-io.

the class ApiService_FindByUserTest method setUp.

@Before
public void setUp() {
    PropertyFilter apiMembershipTypeFilter = new ApiPermissionFilter();
    objectMapper.setFilterProvider(new SimpleFilterProvider(Collections.singletonMap("apiMembershipTypeFilter", apiMembershipTypeFilter)));
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) PropertyFilter(com.fasterxml.jackson.databind.ser.PropertyFilter) ApiPermissionFilter(io.gravitee.rest.api.service.jackson.filter.ApiPermissionFilter) Before(org.junit.Before)

Aggregations

PropertyFilter (com.fasterxml.jackson.databind.ser.PropertyFilter)13 SimpleFilterProvider (com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)13 ApiPermissionFilter (io.gravitee.rest.api.service.jackson.filter.ApiPermissionFilter)13 Before (org.junit.Before)10 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)3 HttpEndpoint (io.gravitee.definition.model.endpoint.HttpEndpoint)3 ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)2 Reader (java.io.Reader)2 Authentication (org.springframework.security.core.Authentication)2 SecurityContext (org.springframework.security.core.context.SecurityContext)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 GraviteeMapper (io.gravitee.definition.jackson.datatype.GraviteeMapper)1 io.gravitee.definition.model (io.gravitee.definition.model)1 GrpcEndpoint (io.gravitee.definition.model.endpoint.GrpcEndpoint)1 io.gravitee.rest.api.model (io.gravitee.rest.api.model)1 UpdateApiEntity (io.gravitee.rest.api.model.api.UpdateApiEntity)1 Bean (org.springframework.context.annotation.Bean)1