Package net.shibboleth.idp.ui.csrf.impl
Class CSRFTokenFlowExecutionListenerTest
java.lang.Object
net.shibboleth.idp.ui.csrf.BaseCSRFTest
net.shibboleth.idp.ui.csrf.impl.CSRFTokenFlowExecutionListenerTest
Test the
CSRFTokenFlowExecutionListener.-
Nested Class Summary
Nested classes/interfaces inherited from class net.shibboleth.idp.ui.csrf.BaseCSRFTest
BaseCSRFTest.MockView, BaseCSRFTest.MockViewState -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringthe HTTP request parameter name that holds the CSRF token.private net.shibboleth.idp.ui.csrf.impl.CSRFTokenFlowExecutionListenerThe listener instance to test.private ObjectSomething to spoof the null checker.Fields inherited from class net.shibboleth.idp.ui.csrf.BaseCSRFTest
EXCLUDED_VIEWSTATES_FIELDNAME, INCLUDE_ALL_VIEWSTATES_FIELDNAME, INCLUDED_VIEWSTATES_FIELDNAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetup()voidTest the listener adds the CSRF token to the viewScope on view rendering.voidTest the listener does not throw anInvalidCSRFTokenExceptioneven though the tokens do not match, because the listener is disabled.voidTest the listener gracefully (no exception) handles a non view-state.voidTest the listener does not test the CSRF token if called from in a non view-state.voidTest the listener throws anInvalidCSRFTokenExceptionif no CSRF token is present in the Http request.voidTest the listener throws anInvalidCSRFTokenExceptionif the viewScope and request token do not match.voidTest the listener does throw anInvalidCSRFTokenExceptionas the tokens do not match.voidTest the listener throws anInvalidCSRFTokenExceptionif no CSRF token is present in the viewscope.voidTest setting a CSRF token manager.voidTest setting the listener's enabled property.voidTest setting a null CSRF token manager triggers aConstraintViolationException.voidTest setting a null event requires csrf validation predicate triggers aConstraintViolationException.voidTest setting a null view requires csrf token predicate triggers aConstraintViolationException.voidTest the listener does not add CSRF token to the viewScope on view rendering, as listener disabled.voidTests theInvalidCSRFTokenExceptionis thrown when the view scoped token is the wrong type - String rather thanCSRFToken.(package private) voidTest an unset csrf token manager triggers an initialisation exception.(package private) voidTest an unset ViewRequiresCSRFToken predicate triggers an initialisation exception.(package private) voidTest an unset EventRequiresCSRFTokenValidation predicate triggers an initialisation exception.voidTest anInvalidCSRFTokenExceptionis not thrown if the token in the request and viewscope matches.voidTest the listener does not thrown anInvalidCSRFTokenException.
-
Field Details
-
CSRF_PARAM_NAME
the HTTP request parameter name that holds the CSRF token.- See Also:
-
listener
private net.shibboleth.idp.ui.csrf.impl.CSRFTokenFlowExecutionListener listenerThe listener instance to test. -
nullObj
Something to spoof the null checker.
-
-
Constructor Details
-
CSRFTokenFlowExecutionListenerTest
public CSRFTokenFlowExecutionListenerTest()
-
-
Method Details
-
setup
- Throws:
ComponentInitializationException
-
testAddingCsrfTokenToViewScopeOnRendering
Test the listener adds the CSRF token to the viewScope on view rendering.- Throws:
ComponentInitializationException- ...
-
testInvalidToken
Test the listener throws anInvalidCSRFTokenExceptionif the viewScope and request token do not match. View is not excluded.- Throws:
ComponentInitializationException- ...
-
testValidToken
Test anInvalidCSRFTokenExceptionis not thrown if the token in the request and viewscope matches.- Throws:
ComponentInitializationException- ...
-
testViewExcluded
Test the listener does not thrown anInvalidCSRFTokenException. The tokens do not match, but the specific view is excluded.- Throws:
ComponentInitializationException- ...
-
testDisabled
Test the listener does not throw anInvalidCSRFTokenExceptioneven though the tokens do not match, because the listener is disabled.- Throws:
ComponentInitializationException- ...
-
testDoesNotAddTokenToNonViewState
Test the listener gracefully (no exception) handles a non view-state. Note this should really not happen in production, as SWF should not call the viewRendering method unless in a view-state.- Throws:
ComponentInitializationException- ...
-
testDoesNotTestTokenInNonViewState
Test the listener does not test the CSRF token if called from in a non view-state. No exception should be thrown. Note, if it did test the tokens, as none are present, an exception would be thrown - which is undesirable.- Throws:
ComponentInitializationException- ...
-
testHttpRequestTokenException
Test the listener throws anInvalidCSRFTokenExceptionif no CSRF token is present in the Http request.- Throws:
ComponentInitializationException- ...
-
testInvalidTokenUsingNewEventRequiresCSRFTokenValidationPredicate
public void testInvalidTokenUsingNewEventRequiresCSRFTokenValidationPredicate() throws ComponentInitializationExceptionTest the listener does throw anInvalidCSRFTokenExceptionas the tokens do not match. A newBiPredicateis created to match by eventId.- Throws:
ComponentInitializationException- ...
-
testNoViewScopeTokenException
Test the listener throws anInvalidCSRFTokenExceptionif no CSRF token is present in the viewscope.- Throws:
ComponentInitializationException- ...
-
testSetCsrfTokenManager
Test setting a CSRF token manager.- Throws:
ComponentInitializationException- ...
-
testSetEnabled
public void testSetEnabled()Test setting the listener's enabled property. -
testTokenNotAddedToViewScopeOnRenderingWhenDisabled
public void testTokenNotAddedToViewScopeOnRenderingWhenDisabled() throws ComponentInitializationExceptionTest the listener does not add CSRF token to the viewScope on view rendering, as listener disabled.- Throws:
ComponentInitializationException- ...
-
testSetNullCsrfTokenManager
public void testSetNullCsrfTokenManager()Test setting a null CSRF token manager triggers aConstraintViolationException. -
testSetNullEventRequiresCSRFValidationPredicate
public void testSetNullEventRequiresCSRFValidationPredicate()Test setting a null event requires csrf validation predicate triggers aConstraintViolationException. -
testSetNullViewRequiresCSRFTokenPredicate
public void testSetNullViewRequiresCSRFTokenPredicate()Test setting a null view requires csrf token predicate triggers aConstraintViolationException. -
testTokenWrongType
Tests theInvalidCSRFTokenExceptionis thrown when the view scoped token is the wrong type - String rather thanCSRFToken.- Throws:
ComponentInitializationException- ...
-
testUnsetCsrfTokenManager
Test an unset csrf token manager triggers an initialisation exception.- Throws:
ComponentInitializationException- ...
-
testUnsetEventRequiresCSRFValidationPredicate
Test an unset ViewRequiresCSRFToken predicate triggers an initialisation exception.- Throws:
ComponentInitializationException- ...
-
testUnsetViewRequiresCSRFTokenPredicate
Test an unset EventRequiresCSRFTokenValidation predicate triggers an initialisation exception.- Throws:
ComponentInitializationException- ...
-