Package org.shredzone.acme4j.connector
Class DefaultConnectionTest
java.lang.Object
org.shredzone.acme4j.connector.DefaultConnectionTest
Unit tests for
DefaultConnection
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
setup
(com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo wmRuntimeInfo) void
Test if no exception is thrown on a standard request.void
Test if anAcmeServerException
is thrown on an acme problem.void
Test if anAcmeException
is thrown if there is no error type.void
Test if anAcmeServerException
is thrown on another problem.void
Test if anAcmeRateLimitedException
is thrown on an acme problem.void
Test if anAcmeException
is thrown if there is a generic error.void
Test if anAcmeUserActionRequiredException
is thrown on an acme problem.void
void
void
void
void
void
void
Test thatDefaultConnection.getExpiration()
returns valid dates.void
Test that an absolute Location header is evaluated.void
Test that absolute and relative Link headers are evaluated.void
Test that multiple link headers are evaluated.void
Test that no link headers are properly handled.void
Test thatDefaultConnection.getNonce()
extracts aReplay-Nonce
header correctly.void
Test that a relative Location header is evaluated.void
Test if Retry-After header with absolute date is correctly parsed.void
Test if Retry-After header with relative timespan is correctly parsed.void
Test if no Retry-After header is correctly handled.void
Test thatDefaultConnection.getNonce()
fails on an invalidReplay-Nonce
header.void
void
void
Test thatDefaultConnection.getLastModified()
returns valid dates.void
Test that no Location header returnsnull
.void
Test thatDefaultConnection.getNonce()
is empty if there is noReplay-Nonce
header.void
Test that a bad certificate throws an exception.void
Test that a certificate is downloaded correctly.void
Test getting a JSON response.void
Test thatDefaultConnection.resetNonce(Session)
fetches a new nonce via new-nonce resource and a HEAD request.void
Test thatDefaultConnection.resetNonce(Session)
throws an exception if there is no nonce header.void
Test certificate POST-as-GET requests.void
Test GET requests.void
Test GET requests with If-Modified-Since.void
Test signed POST-as-GET requests.void
Test signed POST requests.void
Test signed POST requests without KeyIdentifier.void
Test signed POST requests if there is no nonce.
-
Constructor Details
-
DefaultConnectionTest
public DefaultConnectionTest()
-
-
Method Details
-
setup
@BeforeEach public void setup(com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo wmRuntimeInfo) throws Exception - Throws:
Exception
-
testNoNonceFromHeader
Test thatDefaultConnection.getNonce()
is empty if there is noReplay-Nonce
header.- Throws:
AcmeException
-
testGetNonceFromHeader
Test thatDefaultConnection.getNonce()
extracts aReplay-Nonce
header correctly.- Throws:
AcmeException
-
testInvalidNonceFromHeader
Test thatDefaultConnection.getNonce()
fails on an invalidReplay-Nonce
header. -
testResetNonceSucceedsIfNoncePresent
Test thatDefaultConnection.resetNonce(Session)
fetches a new nonce via new-nonce resource and a HEAD request.- Throws:
AcmeException
-
testResetNonceThrowsException
Test thatDefaultConnection.resetNonce(Session)
throws an exception if there is no nonce header. -
testGetAbsoluteLocation
Test that an absolute Location header is evaluated.- Throws:
Exception
-
testGetRelativeLocation
Test that a relative Location header is evaluated.- Throws:
Exception
-
testGetLink
Test that absolute and relative Link headers are evaluated.- Throws:
Exception
-
testGetMultiLink
Test that multiple link headers are evaluated.- Throws:
AcmeException
-
testGetNoLink
Test that no link headers are properly handled.- Throws:
AcmeException
-
testNoLocation
Test that no Location header returnsnull
.- Throws:
AcmeException
-
testHandleRetryAfterHeaderDate
Test if Retry-After header with absolute date is correctly parsed.- Throws:
AcmeException
-
testHandleRetryAfterHeaderDelta
Test if Retry-After header with relative timespan is correctly parsed.- Throws:
AcmeException
-
testHandleRetryAfterHeaderNull
Test if no Retry-After header is correctly handled.- Throws:
AcmeException
-
testAccept
Test if no exception is thrown on a standard request.- Throws:
AcmeException
-
testAcceptThrowsException
Test if anAcmeServerException
is thrown on an acme problem. -
testAcceptThrowsUserActionRequiredException
Test if anAcmeUserActionRequiredException
is thrown on an acme problem. -
testAcceptThrowsRateLimitedException
Test if anAcmeRateLimitedException
is thrown on an acme problem. -
testAcceptThrowsOtherException
Test if anAcmeServerException
is thrown on another problem. -
testAcceptThrowsNoTypeException
Test if anAcmeException
is thrown if there is no error type. -
testAcceptThrowsServerException
Test if anAcmeException
is thrown if there is a generic error. -
testSendRequest
Test GET requests.- Throws:
AcmeException
-
testSendRequestIfModifiedSince
Test GET requests with If-Modified-Since.- Throws:
AcmeException
-
testSendSignedRequest
Test signed POST requests.- Throws:
Exception
-
testSendSignedPostAsGetRequest
Test signed POST-as-GET requests.- Throws:
Exception
-
testSendCertificateRequest
Test certificate POST-as-GET requests.- Throws:
AcmeException
-
testSendSignedRequestNoKid
Test signed POST requests without KeyIdentifier.- Throws:
Exception
-
testSendSignedRequestNoNonce
Test signed POST requests if there is no nonce. -
testReadJsonResponse
Test getting a JSON response.- Throws:
AcmeException
-
testReadCertificate
Test that a certificate is downloaded correctly.- Throws:
Exception
-
testReadBadCertificate
Test that a bad certificate throws an exception.- Throws:
Exception
-
testLastModifiedUnset
Test thatDefaultConnection.getLastModified()
returns valid dates.- Throws:
AcmeException
-
testLastModifiedSet
- Throws:
AcmeException
-
testLastModifiedInvalid
- Throws:
AcmeException
-
testExpirationUnset
Test thatDefaultConnection.getExpiration()
returns valid dates.- Throws:
AcmeException
-
testExpirationNoCache
- Throws:
AcmeException
-
testExpirationMaxAgeZero
- Throws:
AcmeException
-
testExpirationMaxAgeButNoCache
- Throws:
AcmeException
-
testExpirationMaxAge
- Throws:
AcmeException
-
testExpirationExpires
- Throws:
AcmeException
-
testExpirationInvalidExpires
- Throws:
AcmeException
-