Search in sources :

Example 11 with PageEntity

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);
}
Also used : PageEntity(io.gravitee.rest.api.model.PageEntity) Test(org.junit.Test)

Example 12 with PageEntity

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));
}
Also used : PageEntity(io.gravitee.rest.api.model.PageEntity) OAIDescriptor(io.gravitee.rest.api.service.swagger.OAIDescriptor) Test(org.junit.Test)

Example 13 with PageEntity

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));
}
Also used : PageEntity(io.gravitee.rest.api.model.PageEntity) OAIDescriptor(io.gravitee.rest.api.service.swagger.OAIDescriptor) Test(org.junit.Test)

Example 14 with PageEntity

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);
}
Also used : PageEntity(io.gravitee.rest.api.model.PageEntity) SwaggerDescriptor(io.gravitee.rest.api.service.swagger.SwaggerDescriptor) Test(org.junit.Test)

Example 15 with PageEntity

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);
}
Also used : PageEntity(io.gravitee.rest.api.model.PageEntity) Response(javax.ws.rs.core.Response) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) RolePermissionAction(io.gravitee.rest.api.model.permissions.RolePermissionAction) Test(org.junit.Test)

Aggregations

PageEntity (io.gravitee.rest.api.model.PageEntity)67 Test (org.junit.Test)48 ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)15 OAIDescriptor (io.gravitee.rest.api.service.swagger.OAIDescriptor)15 Page (io.gravitee.rest.api.portal.rest.model.Page)13 Response (javax.ws.rs.core.Response)13 UpdatePageEntity (io.gravitee.rest.api.model.UpdatePageEntity)9 PageConfigurationOAITransformer (io.gravitee.rest.api.service.impl.swagger.transformer.page.PageConfigurationOAITransformer)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 Permissions (io.gravitee.rest.api.management.rest.security.Permissions)6 EntrypointsOAITransformer (io.gravitee.rest.api.service.impl.swagger.transformer.entrypoints.EntrypointsOAITransformer)6 SwaggerDescriptor (io.gravitee.rest.api.service.swagger.SwaggerDescriptor)5 Before (org.junit.Before)5 Page (io.gravitee.repository.management.model.Page)4 NewPageEntity (io.gravitee.rest.api.model.NewPageEntity)4 PageNotFoundException (io.gravitee.rest.api.service.exceptions.PageNotFoundException)4 ArgumentMatchers (org.mockito.ArgumentMatchers)4 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)3 PageRepository (io.gravitee.repository.management.api.PageRepository)3 PageReferenceType (io.gravitee.repository.management.model.PageReferenceType)3