use of com.enonic.xp.portal.idprovider.IdProviderControllerService in project xp by enonic.
the class IdentityHandlerTest method setup.
@BeforeEach
public final void setup() throws Exception {
this.request = new PortalRequest();
final ContentService contentService = Mockito.mock(ContentService.class);
final IdProviderControllerService idProviderControllerService = Mockito.mock(IdProviderControllerService.class);
final HttpServletRequest rawRequest = Mockito.mock(HttpServletRequest.class);
Mockito.when(idProviderControllerService.execute(Mockito.any())).thenAnswer(invocation -> {
Object[] args = invocation.getArguments();
final IdProviderControllerExecutionParams arg = (IdProviderControllerExecutionParams) args[0];
if (IdProviderKey.from("myidprovider").equals(arg.getIdProviderKey()) && "get".equals(arg.getFunctionName())) {
return PortalResponse.create().build();
}
return null;
});
this.handler = new IdentityHandler();
this.handler.setContentService(contentService);
this.handler.setIdProviderControllerService(idProviderControllerService);
this.request.setMethod(HttpMethod.GET);
this.request.setEndpointPath("/_/idprovider/myidprovider?param1=value1");
this.request.setRawPath("/site/draft/_/idprovider/myidprovider?param1=value1");
this.request.setRawRequest(rawRequest);
}
use of com.enonic.xp.portal.idprovider.IdProviderControllerService in project xp by enonic.
the class IdentityHandlerTest method testOptions.
@Test
public void testOptions() throws Exception {
final IdProviderControllerService idProviderControllerService = Mockito.mock(IdProviderControllerService.class);
final PortalResponse response = PortalResponse.create().status(HttpStatus.METHOD_NOT_ALLOWED).build();
Mockito.when(idProviderControllerService.execute(Mockito.any())).thenReturn(response);
this.handler.setIdProviderControllerService(idProviderControllerService);
this.request.setMethod(HttpMethod.OPTIONS);
final WebResponse res = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertNotNull(res);
assertEquals(HttpStatus.OK, res.getStatus());
assertEquals("GET,POST,HEAD,OPTIONS,PUT,DELETE,TRACE", res.getHeaders().get("Allow"));
}
use of com.enonic.xp.portal.idprovider.IdProviderControllerService in project xp by enonic.
the class IdProviderResponseWrapperTest method setup.
@BeforeEach
public void setup() throws IOException {
this.idProviderControllerService = Mockito.mock(IdProviderControllerService.class);
Mockito.when(idProviderControllerService.execute(Mockito.any())).thenReturn(PortalResponse.create().build());
final HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
final HttpServletResponse httpServletResponse = Mockito.mock(HttpServletResponse.class);
this.idProviderResponseWrapper = new IdProviderResponseWrapper(idProviderControllerService, httpServletRequest, httpServletResponse);
}
Aggregations