use of com.enonic.xp.portal.idprovider.IdProviderControllerExecutionParams in project xp by enonic.
the class IdProviderResponseWrapper method handleError.
private void handleError(final int sc) {
if (!errorHandled && isUnauthorizedError(sc) && !isErrorAlreadyHandled()) {
try {
final IdProviderControllerExecutionParams executionParams = IdProviderControllerExecutionParams.create().functionName("handle401").servletRequest(request).response(response).build();
final boolean responseSerialized = idProviderControllerService.execute(executionParams) != null;
if (responseSerialized) {
errorHandled = true;
}
} catch (IOException e) {
throw Exceptions.unchecked(e);
}
}
}
use of com.enonic.xp.portal.idprovider.IdProviderControllerExecutionParams 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.IdProviderControllerExecutionParams 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.idprovider.IdProviderControllerExecutionParams 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.idprovider.IdProviderControllerExecutionParams 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());
}
Aggregations