Class AuthorizationControllerTest
- java.lang.Object
-
- org.springframework.test.context.testng.AbstractTestNGSpringContextTests
-
- net.shibboleth.idp.plugin.authn.oidc.rp.impl.AuthorizationControllerTest
-
- All Implemented Interfaces:
Aware,ApplicationContextAware,org.testng.IHookable,org.testng.ITestNGListener
@ContextConfiguration(classes={net.shibboleth.idp.plugin.authn.oidc.rp.impl.AuthorizationController.class,IdPPropertyConfigurer.class}) @WebAppConfiguration @TestPropertySource(properties="shibboleth.authn.OIDC.externalAuthnPath=/Authn/OIDC/RP") public class AuthorizationControllerTest extends AbstractTestNGSpringContextTests
Integration tests, using other 'live' actions, for the AuthorizationController.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classAuthorizationControllerTest.MockEncodeMessageMock EncodeMessage profile action.private classAuthorizationControllerTest.MockRedirectEncoderMock redirect encoder.private classAuthorizationControllerTest.NoOpMockRedirectResponseDecoderMock no-op redirect decoder.
-
Field Summary
Fields Modifier and Type Field Description private StringCLIENT_SECRETA client_secret to use.private ProfileRequestContextcontextThe PRC that has been setup.private StringENDPOINT_URIThe endpoint to redirect the user-agent to.private StringISSUERThe issuer or OP identifier.private MockMvcmockMvcThe mock MVC entry point for testing.private StringREDIRECT_URIThe redirect to direct the user-agent to after successful authentication.private javax.servlet.http.HttpServletRequestrequestThe mock http servlet request.private javax.servlet.http.HttpServletResponseresponseThe mock http servlet response.private javax.servlet.ServletContextservletContextThe mock servlet context.private WebApplicationContextwebApplicationContextThe web application context loaded by the test framework.-
Fields inherited from class org.springframework.test.context.testng.AbstractTestNGSpringContextTests
applicationContext, logger
-
-
Constructor Summary
Constructors Constructor Description AuthorizationControllerTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddPreEncodeMessageHandler(net.shibboleth.idp.plugin.authn.oidc.rp.context.OIDCAuthnContext authnContext)Add the standard set of pre encode message handlers e.g.private voidaddRequestObject(net.shibboleth.oidc.profile.core.OIDCAuthenticationRequest request)Add a simple RequestObject JWT to the authentication request.private voidaddSecurityParametersContext(ProfileRequestContext prc)A a security parameters context, almost always for request object signing/encryption by this point.private ProfileRequestContextbuildProfileRequestContext()Build a nestedProfileRequestContextby configuring a suitable context tree for external authentication e.g.private ProfileRequestContextexportServletContextAttributes()Export the FlowExecutor to the servlet context with the correct set of configured contexts.private net.shibboleth.idp.authn.context.ExternalAuthenticationContextextractExternalAuthContext()Create an external authentication context.voidsetUp()Setup.voidtestSuccessfulAuthorizeRequest()Test the correct 302 redirect is returned from the authorization controller.voidtestSuccessfulAuthorizeRequest_WithRequestObject()Test the correct 302 redirect is returned from the authorization controller.-
Methods inherited from class org.springframework.test.context.testng.AbstractTestNGSpringContextTests
run, setApplicationContext, springTestContextAfterTestClass, springTestContextAfterTestMethod, springTestContextBeforeTestClass, springTestContextBeforeTestMethod, springTestContextPrepareTestInstance
-
-
-
-
Field Detail
-
webApplicationContext
@Nonnull @Autowired private WebApplicationContext webApplicationContext
The web application context loaded by the test framework.
-
ENDPOINT_URI
@Nonnull private final String ENDPOINT_URI
The endpoint to redirect the user-agent to.- See Also:
- Constant Field Values
-
CLIENT_SECRET
@Nonnull private final String CLIENT_SECRET
A client_secret to use.- See Also:
- Constant Field Values
-
ISSUER
@Nonnull private final String ISSUER
The issuer or OP identifier.- See Also:
- Constant Field Values
-
REDIRECT_URI
@Nonnull private final String REDIRECT_URI
The redirect to direct the user-agent to after successful authentication.- See Also:
- Constant Field Values
-
mockMvc
@Nonnull private MockMvc mockMvc
The mock MVC entry point for testing.
-
servletContext
@Nonnull @Autowired private javax.servlet.ServletContext servletContext
The mock servlet context.
-
response
@Nonnull @Autowired private javax.servlet.http.HttpServletResponse response
The mock http servlet response.
-
request
@Nonnull @Autowired private javax.servlet.http.HttpServletRequest request
The mock http servlet request.
-
context
@Nullable private ProfileRequestContext context
The PRC that has been setup.
-
-
Method Detail
-
testSuccessfulAuthorizeRequest
public void testSuccessfulAuthorizeRequest() throws ExceptionTest the correct 302 redirect is returned from the authorization controller.- Throws:
Exception- on error
-
testSuccessfulAuthorizeRequest_WithRequestObject
public void testSuccessfulAuthorizeRequest_WithRequestObject() throws ExceptionTest the correct 302 redirect is returned from the authorization controller. Including a Request Object.- Throws:
Exception- on error
-
addRequestObject
private void addRequestObject(@Nonnull net.shibboleth.oidc.profile.core.OIDCAuthenticationRequest request)Add a simple RequestObject JWT to the authentication request.- Parameters:
request- the authentication request
-
exportServletContextAttributes
private ProfileRequestContext exportServletContextAttributes() throws Exception
Export the FlowExecutor to the servlet context with the correct set of configured contexts. Mimicking the IdP's configuration of theServletContextAttributeExporter.- Returns:
- the profile request context.
- Throws:
Exception- on error.
-
addPreEncodeMessageHandler
private void addPreEncodeMessageHandler(@Nonnull net.shibboleth.idp.plugin.authn.oidc.rp.context.OIDCAuthnContext authnContext) throws ComponentInitializationExceptionAdd the standard set of pre encode message handlers e.g. those to sign a request object if present.- Parameters:
authnContext- the authentication context- Throws:
ComponentInitializationException- on error
-
addSecurityParametersContext
private void addSecurityParametersContext(@Nonnull ProfileRequestContext prc) throws ExceptionA a security parameters context, almost always for request object signing/encryption by this point.- Parameters:
prc- the profile request context- Throws:
Exception- on error
-
buildProfileRequestContext
@Nonnull private ProfileRequestContext buildProfileRequestContext() throws Exception
Build a nestedProfileRequestContextby configuring a suitable context tree for external authentication e.g. aAuthenticationContextandExternalAuthenticationContext. Nest the proxy PRC under the authentication context.- Returns:
- a profile request context.
- Throws:
Exception- on error creating the duo client
-
extractExternalAuthContext
private net.shibboleth.idp.authn.context.ExternalAuthenticationContext extractExternalAuthContext()
Create an external authentication context.- Returns:
- external authentication context
-
-