use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_ParseTest method shouldThrowUrlForbiddenException.
@Test(expected = UrlForbiddenException.class)
public void shouldThrowUrlForbiddenException() {
PageEntity pageEntity = new PageEntity();
pageEntity.setContent("http://localhost");
swaggerService.parse(pageEntity.getContent(), false);
}
use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_ParseTest method shouldReturnErrorMessageExceptionWhenParseSwaggerV2WithoutInfo_yaml.
@Test
public void shouldReturnErrorMessageExceptionWhenParseSwaggerV2WithoutInfo_yaml() throws IOException {
PageEntity pageEntity = getPage("io/gravitee/rest/api/management/service/swagger-v2-no-info.yaml", MediaType.TEXT_PLAIN);
OAIDescriptor descriptor = (OAIDescriptor) swaggerService.parse(pageEntity.getContent());
assertNotNull(descriptor.getMessages());
assertEquals("attribute info is missing", descriptor.getMessages().get(0));
}
use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_ParseTest method shouldThrowSwaggerDescriptorExceptionWhenParseSwaggerV3WithoutInfo_yaml.
@Test
public void shouldThrowSwaggerDescriptorExceptionWhenParseSwaggerV3WithoutInfo_yaml() throws IOException {
PageEntity pageEntity = getPage("io/gravitee/rest/api/management/service/openapi-no-info.yaml", MediaType.TEXT_PLAIN);
OAIDescriptor descriptor = (OAIDescriptor) swaggerService.parse(pageEntity.getContent());
assertNotNull(descriptor.getMessages());
assertEquals("attribute info is missing", descriptor.getMessages().get(0));
}
use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_ParseTest method shouldNotThrowAnythingWhenFailIfErrorsFalse.
@Test
public void shouldNotThrowAnythingWhenFailIfErrorsFalse() throws IOException {
PageEntity pageEntity = getPage("io/gravitee/rest/api/management/service/swagger-v2-no-info-name.json", MediaType.APPLICATION_JSON);
SwaggerDescriptor descriptor = swaggerService.parse(pageEntity.getContent());
assertNotNull(descriptor);
}
use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiPagesResourceNotAdminTest method shouldNotGetPrivateApiPublishedPage.
@Test
public void shouldNotGetPrivateApiPublishedPage() {
reset(apiService, pageService, membershipService);
final ApiEntity apiMock = mock(ApiEntity.class);
when(apiMock.getVisibility()).thenReturn(Visibility.PRIVATE);
when(apiMock.getName()).thenReturn(API_NAME);
doReturn(apiMock).when(apiService).findById(API_NAME);
final PageEntity pageMock = new PageEntity();
pageMock.setPublished(true);
pageMock.setName(PAGE_NAME);
doReturn(pageMock).when(pageService).findById(PAGE_NAME, null);
doReturn(true).when(roleService).hasPermission(any(), eq(ApiPermission.DOCUMENTATION), eq(new RolePermissionAction[] { RolePermissionAction.READ }));
when(permissionService.hasPermission(any(), any(), any())).thenReturn(true);
final Response response = envTarget().request().get();
assertEquals(UNAUTHORIZED_401, response.getStatus());
verify(apiService, atLeastOnce()).findById(API_NAME);
verify(pageService, times(1)).findById(PAGE_NAME, null);
}
Aggregations