use of io.gravitee.management.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)));
}
use of io.gravitee.management.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)));
return objectMapper;
}
use of io.gravitee.management.service.jackson.filter.ApiPermissionFilter in project gravitee-management-rest-api by gravitee-io.
the class ApiService_ExportAsJsonTest method setUp.
@Before
public void setUp() throws TechnicalException {
PropertyFilter apiMembershipTypeFilter = new ApiPermissionFilter();
objectMapper.setFilterProvider(new SimpleFilterProvider(Collections.singletonMap("apiMembershipTypeFilter", apiMembershipTypeFilter)));
Api api = new Api();
api.setId(API_ID);
api.setDescription("Gravitee.io");
when(apiRepository.findById(API_ID)).thenReturn(Optional.of(api));
PageEntity page = new PageEntity();
page.setName("My Title");
page.setOrder(1);
page.setType(PageType.MARKDOWN.toString());
page.setContent("Read the doc");
when(pageService.findApiPagesByApi(API_ID)).thenReturn(Collections.singletonList(new PageListItem()));
when(pageService.findById(any())).thenReturn(page);
Membership membership = new Membership();
membership.setUserId("johndoe");
membership.setReferenceId(API_ID);
membership.setReferenceType(MembershipReferenceType.API);
membership.setRoles(Collections.singletonMap(RoleScope.API.getId(), SystemRole.PRIMARY_OWNER.name()));
when(membershipRepository.findByReferenceAndRole(eq(MembershipReferenceType.API), eq(API_ID), any(), any())).thenReturn(Collections.singleton(membership));
MemberEntity memberEntity = new MemberEntity();
memberEntity.setUsername(membership.getUserId());
memberEntity.setRole(SystemRole.PRIMARY_OWNER.name());
when(membershipService.getMembers(eq(MembershipReferenceType.API), eq(API_ID), eq(RoleScope.API))).thenReturn(Collections.singleton(memberEntity));
UserEntity userEntity = new UserEntity();
userEntity.setUsername(memberEntity.getId());
when(userService.findByUsername(memberEntity.getId(), false)).thenReturn(userEntity);
api.setGroups(Collections.singleton("my-group"));
GroupEntity groupEntity = new GroupEntity();
groupEntity.setId("my-group");
groupEntity.setName("My Group");
when(groupService.findByIds(api.getGroups())).thenReturn(Collections.singleton(groupEntity));
PlanEntity publishedPlan = new PlanEntity();
publishedPlan.setId("plan-id");
publishedPlan.setApis(Collections.singleton(API_ID));
publishedPlan.setDescription("free plan");
publishedPlan.setType(PlanType.API);
publishedPlan.setSecurity(PlanSecurityType.API_KEY);
publishedPlan.setValidation(PlanValidationType.AUTO);
publishedPlan.setStatus(PlanStatus.PUBLISHED);
Map<String, Path> paths = new HashMap<>();
Path path = new Path();
path.setPath("/");
io.gravitee.definition.model.Rule rule = new io.gravitee.definition.model.Rule();
rule.setEnabled(true);
rule.setMethods(Collections.singletonList(HttpMethod.GET));
Policy policy = new Policy();
policy.setName("rate-limit");
String ls = System.lineSeparator();
policy.setConfiguration("{" + ls + " \"rate\": {" + ls + " \"limit\": 1," + ls + " \"periodTime\": 1," + ls + " \"periodTimeUnit\": \"SECONDS\"" + ls + " }" + ls + " }");
rule.setPolicy(policy);
path.setRules(Collections.singletonList(rule));
paths.put("/", path);
publishedPlan.setPaths(paths);
PlanEntity closedPlan = new PlanEntity();
closedPlan.setId("closedPlan-id");
closedPlan.setApis(Collections.singleton(API_ID));
closedPlan.setDescription("free closedPlan");
closedPlan.setType(PlanType.API);
closedPlan.setSecurity(PlanSecurityType.API_KEY);
closedPlan.setValidation(PlanValidationType.AUTO);
closedPlan.setStatus(PlanStatus.CLOSED);
closedPlan.setPaths(paths);
Set<PlanEntity> set = new HashSet<>();
set.add(publishedPlan);
set.add(closedPlan);
when(planService.findByApi(API_ID)).thenReturn(set);
}
use of io.gravitee.management.service.jackson.filter.ApiPermissionFilter in project gravitee-management-rest-api by gravitee-io.
the class ApiService_StartTest method setUp.
@Before
public void setUp() {
PropertyFilter apiMembershipTypeFilter = new ApiPermissionFilter();
objectMapper.setFilterProvider(new SimpleFilterProvider(Collections.singletonMap("apiMembershipTypeFilter", apiMembershipTypeFilter)));
}
use of io.gravitee.management.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)));
}
Aggregations