Search in sources :

Example 11 with ApiPermissionFilter

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

the class ApiService_SearchTest 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 12 with ApiPermissionFilter

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

the class ApiService_UpdateTest method setUp.

@Before
public void setUp() {
    PropertyFilter apiMembershipTypeFilter = new ApiPermissionFilter();
    objectMapper.setFilterProvider(new SimpleFilterProvider(Collections.singletonMap("apiMembershipTypeFilter", apiMembershipTypeFilter)));
    GraviteeContext.setCurrentEnvironment("DEFAULT");
    final SecurityContext securityContext = mock(SecurityContext.class);
    when(securityContext.getAuthentication()).thenReturn(mock(Authentication.class));
    SecurityContextHolder.setContext(securityContext);
    when(api.getId()).thenReturn(API_ID);
    when(api.getDefinition()).thenReturn("{\"id\": \"" + API_ID + "\",\"name\": \"" + API_NAME + "\",\"proxy\": {\"context_path\": \"/old\"}}");
    when(api.getEnvironmentId()).thenReturn("DEFAULT");
    when(notificationTemplateService.resolveInlineTemplateWithParam(anyString(), any(Reader.class), any())).thenReturn("toDecode=decoded-value");
    MembershipEntity primaryOwner = new MembershipEntity();
    primaryOwner.setMemberType(MembershipMemberType.USER);
    when(membershipService.getPrimaryOwner(eq(MembershipReferenceType.API), any())).thenReturn(primaryOwner);
    reset(searchEngineService);
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) Authentication(org.springframework.security.core.Authentication) SecurityContext(org.springframework.security.core.context.SecurityContext) Reader(java.io.Reader) PropertyFilter(com.fasterxml.jackson.databind.ser.PropertyFilter) ApiPermissionFilter(io.gravitee.rest.api.service.jackson.filter.ApiPermissionFilter) Before(org.junit.Before)

Example 13 with ApiPermissionFilter

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

the class ServiceConfiguration method objectMapper.

@Bean
public ObjectMapper objectMapper() {
    ObjectMapper objectMapper = new GraviteeMapper();
    PropertyFilter apiMembershipTypeFilter = new ApiPermissionFilter();
    objectMapper.setFilterProvider(new SimpleFilterProvider(Collections.singletonMap("apiMembershipTypeFilter", apiMembershipTypeFilter)));
    objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS);
    // register API serializer
    SimpleModule module = new SimpleModule();
    module.addSerializer(ApiEntity.class, apiSerializer());
    objectMapper.registerModule(module);
    return objectMapper;
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) GraviteeMapper(io.gravitee.definition.jackson.datatype.GraviteeMapper) PropertyFilter(com.fasterxml.jackson.databind.ser.PropertyFilter) ApiPermissionFilter(io.gravitee.rest.api.service.jackson.filter.ApiPermissionFilter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) Bean(org.springframework.context.annotation.Bean)

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