diff options
| author | Thomas <> | 2021-07-01 07:37:47 +0200 | 
|---|---|---|
| committer | Thomas <> | 2021-07-01 07:37:47 +0200 | 
| commit | a3088068b6d3f6d6719ca5943eec556d01c0655d (patch) | |
| tree | 7344db320628814fd83fce7549e78506b6b56ca9 /eaaf_core/src/test | |
| parent | 108df5e1cc640070d1b03fb2dfd99306e661b8fe (diff) | |
| download | EAAF-Components-a3088068b6d3f6d6719ca5943eec556d01c0655d.tar.gz EAAF-Components-a3088068b6d3f6d6719ca5943eec556d01c0655d.tar.bz2 EAAF-Components-a3088068b6d3f6d6719ca5943eec556d01c0655d.zip | |
add new 'errorHandling' type that illustrate any error on application side before forwarding to SP
Diffstat (limited to 'eaaf_core/src/test')
| -rw-r--r-- | eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java | 57 | 
1 files changed, 56 insertions, 1 deletions
| diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java index 8aa3e8a9..4341d141 100644 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java @@ -254,7 +254,62 @@ public class ProtocolFinalizationControllerTest {    } -  +  @Test +  public void performErrorHandlingWithoutTokenAndRedirect() throws EaafException, IOException {     +    MockHttpServletRequest httpReq = new MockHttpServletRequest("POST", "https://localhost/authhandler"); +    httpReq.addHeader("Accept", "application/json"); +    MockHttpServletResponse httpResp = new MockHttpServletResponse();     +    guiConfigFactory.setErrorGuiConfig( +        new DummyGuiBuilderConfig("https://localhost/authhandler", "jUnitView", "/junitSubmit")); +     +    String token = requestIdValidationStragegy.generateExternalPendingRequestId(); +    httpReq.setParameter(EaafConstants.PARAM_HTTP_ERROR_CODE, token); +     +    TestRequestImpl protocolRequest = new TestRequestImpl(); +    Map<String, String> spConfig = new HashMap<>(); +    spConfig.put(EaafConfigConstants.SERVICE_UNIQUEIDENTIFIER, RandomStringUtils.randomAlphabetic(10)); +     +    protocolRequest.setSpConfig(new DummySpConfiguration(spConfig, config)); +    protocolRequest.setTransactionId(RandomStringUtils.randomAlphanumeric(10)); +     +    Throwable throwable = new EaafException("internal.00"); +    final ExceptionContainer exceptionContainer = new ExceptionContainer(protocolRequest, throwable); +    final byte[] serialized = SerializationUtils.serialize(exceptionContainer); +    storage.put(token, serialized, -1); +     +    String secondErrorTicket = requestIdValidationStragegy.generateExternalPendingRequestId(); +    errorService.setErrorIdTokenForRedirect(secondErrorTicket); +    errorService.setTicketType(ActionType.ERRORPAGE); +     +    // perform test +    controller.errorHandling(httpReq, httpResp);     +     +    //validate state +    assertNull("Exception not removed from cache", storage.get( +        requestIdValidationStragegy.getPendingRequestIdWithOutChecks(token))); +     +    assertNotNull("No gui builder request", guiBuilder.getConfig()); +    assertFalse("No GUI form infos", guiBuilder.getConfig().getViewParameters().isEmpty()); +    assertTrue("No GUI form infos", guiBuilder.getConfig().getViewParameters().containsKey("msg"));     +    Map<String, Object> params = ((Map<String, Object>) guiBuilder.getConfig().getViewParameters().get("msg")); +    assertFalse("No GUI form infos", params.isEmpty());     +    assertEquals("wrong intErrorCode", "internal.00", params.get("errorCode")); +    assertTrue("wrong extErrorCode", ((String) params.get("extErrorCode")).contains("internal.00")); +            +    byte[] secondErrorSerialized = storage.get( +        requestIdValidationStragegy.getPendingRequestIdWithOutChecks(secondErrorTicket), byte[].class); +    assertNotNull("Exception not removed from cache", secondErrorSerialized); +    ExceptionContainer secondError = (ExceptionContainer)  SerializationUtils.deserialize(secondErrorSerialized); +    assertEquals("wrong pengingReq", protocolRequest.getUniqueTransactionIdentifier(),  +        secondError.getPendingRequest().getUniqueTransactionIdentifier()); +    assertEquals("wrong exception", throwable.getMessage(), secondError.getExceptionThrown().getMessage()); +     +    assertTrue("GUI sp redirect", guiBuilder.getConfig().getViewParameters() +        .containsKey(DummyDefaultErrorService.JUNIT_EL_SPREDIRECT)); +     +  } +   +      private class DummyGuiBuilderConfig extends AbstractGuiFormBuilderConfiguration         implements ModifyableGuiBuilderConfiguration { | 
