Class NimbusClientTest
- java.lang.Object
-
- net.shibboleth.idp.plugin.authn.duo.nimbus.impl.NimbusClientTest
-
public class NimbusClientTest extends Object
Tests for the NimbusClient class.
-
-
Field Summary
Fields Modifier and Type Field Description private net.shibboleth.idp.plugin.authn.duo.nimbus.impl.NimbusClientclientThe Nimbus client to test.private StringHEALTH_CHECK_REPONSEA normal health check response.private StringHEALTH_CHECK_REPONSE_ERRORA normal health check response.private StringHEALTH_CHECK_REPONSE_MORE_FIELDSA health check response with more fields than in the model.private StringID_TOKEN_REPONSE_NULLA null token response, to mock an internal server error e.g.private StringID_TOKEN_RESPONSEReal but valid OAuth JSON token response that has an INVALID signature.private StringID_TOKEN_RESPONSE_ERRORReal token response error message.private DefaultDuoOIDCIntegrationintegThe default OIDC integration params.
-
Constructor Summary
Constructors Constructor Description NimbusClientTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsetup()voidtestAuthURL()Test the auth URL is constructed correctly.voidtestAuthURLWithOverrideRedirect()Test the auth URL is constructed correctly when an override redirectURI is supplied.voidtestHealthCheck()Test the health check using a mocked HTTP client and response.voidtestHealthCheckError()Test the health check using a mocked HTTP client and response.voidtestHealthCheckMoreFields()Test the health check using a mocked HTTP client and response.voidtestHealthEndpointTimeout()voidtestTokenExchange()Test the token exchange works using a mocked HTTP client and response.voidtestTokenExchangeInternalServerErrorResponse()Test an exception is thrown if a non-OK http response is returned.
-
-
-
Field Detail
-
client
@Nonnull private net.shibboleth.idp.plugin.authn.duo.nimbus.impl.NimbusClient client
The Nimbus client to test.
-
integ
@Nonnull private DefaultDuoOIDCIntegration integ
The default OIDC integration params.
-
ID_TOKEN_RESPONSE
@Nonnull @NotEmpty private final String ID_TOKEN_RESPONSE
Real but valid OAuth JSON token response that has an INVALID signature.- See Also:
- Constant Field Values
-
ID_TOKEN_RESPONSE_ERROR
@Nonnull @NotEmpty private final String ID_TOKEN_RESPONSE_ERROR
Real token response error message.- See Also:
- Constant Field Values
-
ID_TOKEN_REPONSE_NULL
@Nonnull @NotEmpty private final String ID_TOKEN_REPONSE_NULL
A null token response, to mock an internal server error e.g. non-OK http status response.- See Also:
- Constant Field Values
-
HEALTH_CHECK_REPONSE
@Nonnull @NotEmpty private final String HEALTH_CHECK_REPONSE
A normal health check response.- See Also:
- Constant Field Values
-
HEALTH_CHECK_REPONSE_ERROR
@Nonnull @NotEmpty private final String HEALTH_CHECK_REPONSE_ERROR
A normal health check response.- See Also:
- Constant Field Values
-
HEALTH_CHECK_REPONSE_MORE_FIELDS
@Nonnull @NotEmpty private final String HEALTH_CHECK_REPONSE_MORE_FIELDS
A health check response with more fields than in the model.- See Also:
- Constant Field Values
-
-
Method Detail
-
testTokenExchange
public void testTokenExchange() throws ExceptionTest the token exchange works using a mocked HTTP client and response. Does not check the signature is valid. Given the amount of mocking, is not a very thorough test.- Throws:
Exception- on error.
-
testTokenExchangeInternalServerErrorResponse
public void testTokenExchangeInternalServerErrorResponse() throws ExceptionTest an exception is thrown if a non-OK http response is returned. There is no known response body, so an empty one is used.- Throws:
Exception- on error.
-
testHealthCheck
public void testHealthCheck() throws ExceptionTest the health check using a mocked HTTP client and response. Given the amount of mocking, is not a very thorough test.- Throws:
Exception- on error
-
testHealthCheckMoreFields
public void testHealthCheckMoreFields() throws ExceptionTest the health check using a mocked HTTP client and response. Given the amount of mocking, is not a very thorough test. The response contains more fields than known, should not fail.- Throws:
Exception- on error
-
testHealthCheckError
public void testHealthCheckError() throws ExceptionTest the health check using a mocked HTTP client and response. Given the amount of mocking, is not a very thorough test. The response shows a failure.- Throws:
Exception- on error
-
testHealthEndpointTimeout
public void testHealthEndpointTimeout() throws Exception- Throws:
Exception
-
testAuthURL
public void testAuthURL() throws DuoClientExceptionTest the auth URL is constructed correctly.- Throws:
DuoClientException- on error.
-
testAuthURLWithOverrideRedirect
public void testAuthURLWithOverrideRedirect() throws DuoClientException, UnsupportedEncodingExceptionTest the auth URL is constructed correctly when an override redirectURI is supplied.- Throws:
DuoClientException- on error.UnsupportedEncodingException- on error.
-
-