use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class AttachmentHandlerTest method inline.
@Test
void inline() throws Exception {
this.request.setEndpointPath("/_/attachment/inline/123456/logo.png");
final PortalResponse res = (PortalResponse) this.handler.handle(this.request, PortalResponse.create().build(), null);
assertNotNull(res);
assertEquals(HttpStatus.OK, res.getStatus());
assertEquals(MediaType.PNG.withoutParameters(), res.getContentType());
assertNull(res.getHeaders().get("Content-Disposition"));
assertSame(this.mediaBytes, res.getBody());
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class IdProviderControllerServiceImplTest method executeWithoutVirtualHost.
@Test
public void executeWithoutVirtualHost() throws IOException {
final HttpServletRequest httpServletRequest = createHttpServletRequest();
final IdProviderControllerExecutionParams executionParams = IdProviderControllerExecutionParams.create().servletRequest(httpServletRequest).functionName("myfunction").build();
final PortalResponse portalResponse = idProviderControllerService.execute(executionParams);
assertNull(portalResponse);
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class IdProviderControllerServiceImplTest method executeIdProviderWithoutApplication.
@Test
public void executeIdProviderWithoutApplication() throws IOException {
final IdProviderControllerExecutionParams executionParams = IdProviderControllerExecutionParams.create().portalRequest(new PortalRequest()).idProviderKey(IdProviderKey.from("myemptyidprovider")).functionName("myfunction").build();
final PortalResponse portalResponse = idProviderControllerService.execute(executionParams);
assertNull(portalResponse);
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class IdProviderControllerServiceImplTest method execute.
@Test
public void execute() throws IOException {
final IdProviderControllerExecutionParams executionParams = IdProviderControllerExecutionParams.create().portalRequest(new PortalRequest()).idProviderKey(IdProviderKey.from("myidprovider")).functionName("myfunction").build();
final PortalResponse portalResponse = idProviderControllerService.execute(executionParams);
assertNotNull(portalResponse);
assertEquals(HttpStatus.OK, portalResponse.getStatus());
assertEquals("myapplication/myfunction", portalResponse.getBody());
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class IdProviderControllerServiceImplTest method executeWithVirtualHost.
@Test
public void executeWithVirtualHost() throws IOException {
final HttpServletRequest httpServletRequest = createHttpServletRequest();
final VirtualHost virtualHost = Mockito.mock(VirtualHost.class);
Mockito.when(virtualHost.getDefaultIdProviderKey()).thenReturn(IdProviderKey.from("myuserstore"));
Mockito.when(virtualHost.getTarget()).thenReturn("/");
Mockito.when(httpServletRequest.getAttribute(VirtualHost.class.getName())).thenReturn(virtualHost);
VirtualHostHelper.setVirtualHost(httpServletRequest, virtualHost);
final IdProviderControllerExecutionParams executionParams = IdProviderControllerExecutionParams.create().servletRequest(httpServletRequest).functionName("myfunction").build();
final PortalResponse portalResponse = idProviderControllerService.execute(executionParams);
assertNotNull(portalResponse);
assertEquals(HttpStatus.OK, portalResponse.getStatus());
assertEquals("myapplication/myfunction", portalResponse.getBody());
}
Aggregations