Search in sources :

Example 1 with MockX509CRL

use of org.apereo.cas.adaptors.x509.util.MockX509CRL in project cas by apereo.

the class ThresholdExpiredCRLRevocationPolicyTests method getTestParameters.

/**
     * Gets the unit test parameters.
     *
     * @return  Test parameter data.
     * @throws Exception if there is an exception getting the test parameters.
     */
@Parameters
public static Collection<Object[]> getTestParameters() throws Exception {
    final Collection<Object[]> params = new ArrayList<>();
    final ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
    final ZonedDateTime twoHoursAgo = now.minusHours(2);
    final ZonedDateTime oneHourAgo = now.minusHours(1);
    final ZonedDateTime halfHourAgo = now.minusMinutes(30);
    final X500Principal issuer = new X500Principal("CN=CAS");
    // Test case #1
    // Expect expired for zero leniency on CRL expiring 1ms ago
    final ThresholdExpiredCRLRevocationPolicy zeroThreshold = new ThresholdExpiredCRLRevocationPolicy(0);
    params.add(new Object[] { zeroThreshold, new MockX509CRL(issuer, DateTimeUtils.dateOf(oneHourAgo), DateTimeUtils.dateOf(now.minusSeconds(1))), new ExpiredCRLException("CN=CAS", ZonedDateTime.now(ZoneOffset.UTC)) });
    // Test case #2
    // Expect expired for 1h leniency on CRL expired 1 hour 1ms ago
    final ThresholdExpiredCRLRevocationPolicy oneHourThreshold = new ThresholdExpiredCRLRevocationPolicy(3600);
    params.add(new Object[] { oneHourThreshold, new MockX509CRL(issuer, DateTimeUtils.dateOf(twoHoursAgo), DateTimeUtils.dateOf(oneHourAgo.minusSeconds(1))), new ExpiredCRLException("CN=CAS", ZonedDateTime.now(ZoneOffset.UTC)) });
    // Test case #3
    // Expect valid for 1h leniency on CRL expired 30m ago
    params.add(new Object[] { oneHourThreshold, new MockX509CRL(issuer, DateTimeUtils.dateOf(twoHoursAgo), DateTimeUtils.dateOf(halfHourAgo)), null });
    return params;
}
Also used : ExpiredCRLException(org.apereo.cas.adaptors.x509.authentication.ExpiredCRLException) ZonedDateTime(java.time.ZonedDateTime) MockX509CRL(org.apereo.cas.adaptors.x509.util.MockX509CRL) ArrayList(java.util.ArrayList) X500Principal(javax.security.auth.x500.X500Principal) ThresholdExpiredCRLRevocationPolicy(org.apereo.cas.adaptors.x509.authentication.revocation.policy.ThresholdExpiredCRLRevocationPolicy) Parameters(org.junit.runners.Parameterized.Parameters)

Aggregations

ZonedDateTime (java.time.ZonedDateTime)1 ArrayList (java.util.ArrayList)1 X500Principal (javax.security.auth.x500.X500Principal)1 ExpiredCRLException (org.apereo.cas.adaptors.x509.authentication.ExpiredCRLException)1 ThresholdExpiredCRLRevocationPolicy (org.apereo.cas.adaptors.x509.authentication.revocation.policy.ThresholdExpiredCRLRevocationPolicy)1 MockX509CRL (org.apereo.cas.adaptors.x509.util.MockX509CRL)1 Parameters (org.junit.runners.Parameterized.Parameters)1